Browse Source

Added typed interface for all known constants (#4452)

Adam Pietrasiak 6 years ago
parent
commit
a71e7311e2
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      lib/src/adapters/Constants.ts

+ 10
- 3
lib/src/adapters/Constants.ts View File

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