Browse Source

Expose statusBarHeight in Navigation.constants

Guy Carmeli 6 years ago
parent
commit
6a3df31009

+ 1
- 0
lib/android/app/src/main/java/com/reactnativenavigation/react/Constants.java View File

@@ -3,4 +3,5 @@ package com.reactnativenavigation.react;
3 3
 public class Constants {
4 4
     public static final String BACK_BUTTON_JS_KEY = "backButton";
5 5
     public static final String BACK_BUTTON_ID = "RNN.back";
6
+    public static final String STATUS_BAR_HEIGHT_KEY = "statusBarHeight";
6 7
 }

+ 2
- 0
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java View File

@@ -18,6 +18,7 @@ import com.reactnativenavigation.utils.NativeCommandListener;
18 18
 import com.reactnativenavigation.utils.Now;
19 19
 import com.reactnativenavigation.utils.TypefaceLoader;
20 20
 import com.reactnativenavigation.utils.UiThread;
21
+import com.reactnativenavigation.utils.UiUtils;
21 22
 import com.reactnativenavigation.viewcontrollers.Navigator;
22 23
 import com.reactnativenavigation.viewcontrollers.ViewController;
23 24
 import com.reactnativenavigation.viewcontrollers.externalcomponent.ExternalComponentCreator;
@@ -50,6 +51,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
50 51
     public Map<String, Object> getConstants() {
51 52
         final Map<String, Object> constants = new HashMap<>();
52 53
         constants.put(Constants.BACK_BUTTON_JS_KEY, Constants.BACK_BUTTON_ID);
54
+        constants.put(Constants.STATUS_BAR_HEIGHT_KEY, UiUtils.getStatusBarHeight(getReactApplicationContext()));
53 55
         return constants;
54 56
     }
55 57
 

+ 6
- 1
lib/src/constants/Constants.test.ts View File

@@ -1,7 +1,8 @@
1 1
 import { Constants } from './Constants';
2 2
 
3 3
 const NavigationModule = {
4
-  backButton: 'backButton'
4
+  backButton: 'RNN.back',
5
+  statusBarHeight: 63
5 6
 };
6 7
 
7 8
 describe('Constants', () => {
@@ -14,4 +15,8 @@ describe('Constants', () => {
14 15
   it('backButton', () => {
15 16
     expect(uut.backButton).toEqual(NavigationModule.backButton);
16 17
   });
18
+
19
+  it('statusBarHeight', () => {
20
+    expect(uut.statusBarHeight).toEqual(NavigationModule.statusBarHeight);
21
+  });
17 22
 });

+ 2
- 0
lib/src/constants/Constants.ts View File

@@ -1,7 +1,9 @@
1 1
 export class Constants {
2 2
   public readonly backButton;
3
+  public readonly statusBarHeight;
3 4
 
4 5
   constructor(navigationModule) {
5 6
     this.backButton = navigationModule.backButton;
7
+    this.statusBarHeight = navigationModule.statusBarHeight;
6 8
   }
7 9
 }