react-native-navigation的迁移库

1234567891011121314151617181920212223242526
  1. import { NativeModules } from 'react-native';
  2. export class Constants {
  3. static async get(): Promise<any> {
  4. if (!this.instance) {
  5. const constants = await NativeModules.RNNBridgeModule.getConstants();
  6. this.instance = new Constants(constants);
  7. }
  8. return this.instance;
  9. }
  10. private static instance: Constants;
  11. public readonly statusBarHeight: number;
  12. public readonly backButtonId: string;
  13. public readonly topBarHeight: number;
  14. public readonly bottomTabsHeight: number;
  15. private constructor(constants) {
  16. this.statusBarHeight = constants.statusBarHeight;
  17. this.topBarHeight = constants.topBarHeight;
  18. this.backButtonId = constants.backButtonId;
  19. this.bottomTabsHeight = constants.bottomTabsHeight;
  20. }
  21. }