How to use the react-native-navigation.Navigation.constants function in react-native-navigation

To help you get started, we’ve selected a few react-native-navigation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / react-native-navigation_v3.x.x / flow_v0.104.x- / test_react-native-navigation.js View on Github external
it('should raises an error when cast to wrong type', () => {
    Navigation.constants().then(result => {
      // $ExpectError - backButtonId is string
      (result.backButtonId: boolean);
      // $ExpectError - backButtonId is number
      (result.bottomTabsHeight: string);
      // $ExpectError - backButtonId is number
      (result.statusBarHeight: string);
      // $ExpectError - backButtonId is number
      (result.topBarHeight: string);
    });
  });
});
github birkir / kvikmyndr-app / src / theme.ts View on Github external
async update() {
    // Add device width and height
    const { width, height } = Dimensions.get('window');
    setVar('--window-width', width);
    setVar('--window-height', height);

    // Add navigation constants
    const res = await Navigation.constants();
    setVar('--bottom-tabs-height', res.bottomTabsHeight);
    setVar('--status-bar-height', res.statusBarHeight);
    setVar('--top-bar-height', res.topBarHeight);

    // Add dynamic variables here
    // ...
    return true;
  },
};
github kanzitelli / react-native-navigation-starter / srcRedux / screens / Home.tsx View on Github external
const getStatusBarHeight = async () => {
        const navConstants = await Navigation.constants();

        // for more info - https://stackoverflow.com/a/48759750
        if (Platform.OS === 'ios') {
            setKeyboardVerticalOffset(navConstants.statusBarHeight + navConstants.topBarHeight);
        }
    };
github flow-typed / flow-typed / definitions / npm / react-native-navigation_v3.x.x / flow_v0.91.1-v0.103.x / test_react-native-navigation.js View on Github external
it('should return constants', () => {
    Navigation.constants().then(result => {
      (result.backButtonId: string);
      (result.bottomTabsHeight: number);
      (result.statusBarHeight: number);
      (result.topBarHeight: number);
    });
  });
github RN-ONE / RNFrameWorkNew / app / util / CommonUtil.js View on Github external
static async getConstFromNavigation() {
        if (Platform.OS === 'android') {
            let constants = await Navigation.constants();
            CommonUtil.topBarHeight = constants.topBarHeight;
            CommonUtil.bottomTabsHeight = constants.bottomTabsHeight;
            CommonUtil.statusBarHeight = constants.statusBarHeight;
        } else {
            //自己写的才可以
            let constants = await NativeModules.Utils.addEventRNNConst();
            console.log({constants});
            CommonUtil.topBarHeight = constants.topBarHeight;
            CommonUtil.bottomTabsHeight = constants.bottomTabsHeight;
            CommonUtil.statusBarHeight = constants.statusBarHeight;
        }
    }
github birkir / hekla / src / stores / UI.ts View on Github external
return flow(function* () {
        const { width, height } = window;
        const isX = Platform.OS === 'ios' && ((width === 375 && height === 812) || (width === 812 && height === 375));
        const isLandscape = width > height;
        self.layout.inset = (isX && isLandscape) ? 44 : 0;
        self.layout.width = width;
        self.layout.height = height;
        const constants = yield (Platform.OS === 'android') ? Navigation.constants() : RNHekla.getHeights(self.componentId);
        if (constants) {
          self.layout.bottomTabsHeight = constants.bottomTabsHeight;
          self.layout.topBarHeight = constants.topBarHeight;
          self.layout.statusBarHeight = constants.statusBarHeight;
        }
      })();
    },
github NordicMuseum / Nordic-Museum-Audio-Guide / v2 / src / index.js View on Github external
text: translate('museumScreen_Title'),
                  icon: require('../src/assets/museumTab.png'),
                  selectedIcon: require('../src/assets/museumTabSelected.png'),
                  textColor: OFF_WHITE,
                  selectedTextColor: 'white',
                  fontSize: 12,
                },
              },
            },
          },
        ],
      },
    },
  });

  const constants = await Navigation.constants();
  setBottomTabsHeight(constants.bottomTabsHeight);

  const shouldShowTutorial = museumMode || newVersion || showWelcomeScreen;
  if (shouldShowTutorial) {
    store.dispatch(showTutorial({ showWelcomeScreen }));
  }
});
github crownstone / CrownstoneApp / js / views / styles.tsx View on Github external
export const stylesUpdateConstants = () =>  {
  Navigation.constants()
    .then((constants) => {
      let tmpStatusBarHeight = constants.statusBarHeight > 0 ? constants.statusBarHeight : statusBarHeight;
      statusBarHeight = tmpStatusBarHeight;

      topBarHeight = constants.topBarHeight > 0 ? constants.topBarHeight : topBarHeight;
      tabBarHeight = constants.bottomTabsHeight > 0 ? constants.bottomTabsHeight : tabBarHeight;

      availableScreenHeight = screenHeight - topBarHeight - tabBarHeight;
      availableModalHeight = screenHeight - topBarHeight - 0.5 * tabBarMargin;
    })
}
github BulletTrainHQ / bullet-train-frontend / mobile / app / components / withNavbarInfo.js View on Github external
componentWillMount() {
            if (!nav) {
                Navigation.constants().then(({ statusBarHeight, topBarHeight }) => {
                    nav = { statusBarHeight, topBarHeight };
                    this.setState({ nav });
                });
            }
        }