123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- import React, {Component} from 'react';
- import {AppRegistry, NativeModules} from 'react-native';
- import _ from 'lodash';
- import PropRegistry from './PropRegistry';
-
- const NativeReactModule = NativeModules.NavigationReactModule;
-
- function startApp(activityParams) {
- savePassProps(activityParams);
- NativeReactModule.startApp(activityParams);
- }
-
- function push(screenParams) {
- savePassProps(screenParams);
- NativeReactModule.push(screenParams);
- }
-
- function pop(screenParams) {
- NativeReactModule.pop(screenParams);
- }
-
- function popToRoot(screenParams) {
- NativeReactModule.popToRoot(screenParams);
- }
-
- function newStack(screenParams) {
- savePassProps(screenParams);
- NativeReactModule.newStack(screenParams);
- }
-
- function toggleTopBarVisible(screenInstanceID, visible, animated) {
- NativeReactModule.setTopBarVisible(screenInstanceID, visible, animated);
- }
-
- function toggleBottomTabsVisible(visible, animated) {
- NativeReactModule.setBottomTabsVisible(visible, animated);
- }
-
- function setScreenTitleBarTitle(screenInstanceID, title) {
- NativeReactModule.setScreenTitleBarTitle(screenInstanceID, title);
- }
-
- function setScreenTitleBarSubtitle(screenInstanceID, subtitle) {
- NativeReactModule.setScreenTitleBarSubtitle(screenInstanceID, subtitle);
- }
-
- function setScreenButtons(screenInstanceID, navigatorEventID, rightButtons, leftButton, fab) {
- NativeReactModule.setScreenButtons(screenInstanceID, navigatorEventID, rightButtons, leftButton, fab);
- }
-
- function showModal(screenParams) {
- savePassProps(screenParams);
- NativeReactModule.showModal(screenParams);
- }
-
- function showLightBox(params) {
- savePassProps(params);
- NativeReactModule.showLightBox(params);
- }
-
- function dismissLightBox() {
- NativeReactModule.dismissLightBox();
- }
-
- function dismissTopModal() {
- NativeReactModule.dismissTopModal();
- }
-
- function dismissAllModals() {
- NativeReactModule.dismissAllModals();
- }
-
- function showInAppNotification(params) {
- savePassProps(params);
- NativeReactModule.showSlidingOverlay(params);
- }
-
- function dismissInAppNotification(params) {
- NativeReactModule.hideSlidingOverlay(params);
- }
-
- function savePassProps(params) {
- if (params.navigationParams && params.passProps) {
- PropRegistry.save(params.navigationParams.screenInstanceID, params.passProps);
- }
-
- if (params.screen && params.screen.passProps) {
- PropRegistry.save(params.screen.navigationParams.screenInstanceID, params.screen.passProps);
- }
-
- if (_.get(params, 'screen.topTabs')) {
- _.forEach(params.screen.topTabs, (tab) => savePassProps(tab));
- }
-
- if (params.topTabs) {
- _.forEach(params.topTabs, (tab) => savePassProps(tab));
- }
-
- if (params.tabs) {
- _.forEach(params.tabs, (tab) => {
- if (!tab.passProps) {
- tab.passProps = params.passProps;
- }
- savePassProps(tab);
- });
- }
-
- if (params.sideMenu && params.sideMenu.left) {
- PropRegistry.save(params.sideMenu.left.navigationParams.screenInstanceID, params.sideMenu.left.passProps);
- }
- if (params.sideMenu && params.sideMenu.right) {
- PropRegistry.save(params.sideMenu.right.navigationParams.screenInstanceID, params.sideMenu.right.passProps);
- }
- }
-
- function toggleSideMenuVisible(animated, side) {
- NativeReactModule.toggleSideMenuVisible(animated, side);
- }
-
- function setSideMenuVisible(animated, visible, side) {
- NativeReactModule.setSideMenuVisible(animated, visible, side);
- }
-
- function setSideMenuEnabled(enabled, side) {
- NativeReactModule.setSideMenuEnabled(enabled, side);
- }
-
- function selectTopTabByTabIndex(screenInstanceId, index) {
- NativeReactModule.selectTopTabByTabIndex(screenInstanceId, index);
- }
-
- function selectTopTabByScreen(screenInstanceId) {
- NativeReactModule.selectTopTabByScreen(screenInstanceId);
- }
-
- function selectBottomTabByNavigatorId(navigatorId) {
- NativeReactModule.selectBottomTabByNavigatorId(navigatorId);
- }
-
- function selectBottomTabByTabIndex(index) {
- NativeReactModule.selectBottomTabByTabIndex(index);
- }
-
- function setBottomTabBadgeByIndex(index, badge) {
- NativeReactModule.setBottomTabBadgeByIndex(index, badge);
- }
-
- function setBottomTabBadgeByNavigatorId(navigatorId, badge) {
- NativeReactModule.setBottomTabBadgeByNavigatorId(navigatorId, badge);
- }
-
- function setBottomTabButtonByIndex(index, params) {
- NativeReactModule.setBottomTabButtonByIndex(index, params);
- }
-
- function setBottomTabButtonByNavigatorId(navigatorId, params) {
- NativeReactModule.setBottomTabButtonByNavigatorId(navigatorId, params);
- }
-
- function showSnackbar(params) {
- NativeReactModule.showSnackbar(params);
- }
-
- function dismissSnackbar() {
- NativeReactModule.dismissSnackbar();
- }
-
- function showContextualMenu(screenInstanceID, params, onButtonPressed) {
- NativeReactModule.showContextualMenu(screenInstanceID, params, onButtonPressed);
- }
-
- function dismissContextualMenu(screenInstanceID) {
- NativeReactModule.dismissContextualMenu(screenInstanceID);
- }
-
- function setScreenStyle(screenInstanceId, style) {
- NativeReactModule.setScreenStyle(screenInstanceId, style);
- }
-
- async function isAppLaunched() {
- return await NativeReactModule.isAppLaunched();
- }
-
- async function isRootLaunched() {
- return await NativeReactModule.isRootLaunched();
- }
-
- async function getCurrentlyVisibleScreenId() {
- return await NativeReactModule.getCurrentlyVisibleScreenId();
- }
-
- module.exports = {
- startApp,
- push,
- pop,
- popToRoot,
- newStack,
- toggleTopBarVisible,
- toggleBottomTabsVisible,
- setScreenTitleBarTitle,
- setScreenTitleBarSubtitle,
- setScreenButtons,
- showModal,
- dismissTopModal,
- dismissAllModals,
- showLightBox,
- dismissLightBox,
- selectTopTabByScreen,
- selectTopTabByTabIndex,
- showInAppNotification,
- dismissInAppNotification,
- toggleSideMenuVisible,
- setSideMenuVisible,
- setSideMenuEnabled,
- selectBottomTabByNavigatorId,
- selectBottomTabByTabIndex,
- setBottomTabBadgeByNavigatorId,
- setBottomTabBadgeByIndex,
- setBottomTabButtonByNavigatorId,
- setBottomTabButtonByIndex,
- showSnackbar,
- dismissSnackbar,
- showContextualMenu,
- dismissContextualMenu,
- setScreenStyle,
- isAppLaunched,
- isRootLaunched,
- getCurrentlyVisibleScreenId
- };
|