UNPKG

@qianmi/rnboat-framework

Version:

57 lines (51 loc) 1.56 kB
import { NativeModules } from 'react-native'; import { default as GlobalConfig } from "./globalConfig" const push = (key, launchOptions) => { GlobalConfig.getAppScenes().then(r => { r = r ? JSON.parse(r) : []; console.log('push', r); for (let i = 0; i < r.length; i++) { if (r[i].key == key) { NativeModules.Navigation.push({ openType: r[i].type && (r[i].type.toLowerCase() == 'rn') ? 'native' : r[i].type, componentName: 'rnboat', bundlePath: r[i].asseturl, launchOptions: launchOptions }); break; } } }); } const pop = () => { NativeModules.Navigation.pop({}); } const popToRoot = () => { NativeModules.Navigation.popToRoot({}); } const hideLoadingDialog = (triggerNumber) => { triggerNumber = triggerNumber ? triggerNumber : 0; NativeModules.Navigation.hideLoadingDialog(triggerNumber) } const reLaunch = (key, launchOptions) => { GlobalConfig.getAppScenes().then(r => { r = r ? JSON.parse(r) : []; console.log('reLaunch', r); for (let i = 0; i < r.length; i++) { if (r[i].key == key) { NativeModules.Navigation.reLaunch({ bundlePath: r[i].asseturl, launchOptions: launchOptions }); break; } } }); } export default { push, pop, popToRoot, hideLoadingDialog, reLaunch };