Procházet zdrojové kódy

Expose statusBarHeight in Navigation.constants

Guy Carmeli před 6 roky
rodič
revize
6a3df31009

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

3
 public class Constants {
3
 public class Constants {
4
     public static final String BACK_BUTTON_JS_KEY = "backButton";
4
     public static final String BACK_BUTTON_JS_KEY = "backButton";
5
     public static final String BACK_BUTTON_ID = "RNN.back";
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 Zobrazit soubor

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

+ 6
- 1
lib/src/constants/Constants.test.ts Zobrazit soubor

1
 import { Constants } from './Constants';
1
 import { Constants } from './Constants';
2
 
2
 
3
 const NavigationModule = {
3
 const NavigationModule = {
4
-  backButton: 'backButton'
4
+  backButton: 'RNN.back',
5
+  statusBarHeight: 63
5
 };
6
 };
6
 
7
 
7
 describe('Constants', () => {
8
 describe('Constants', () => {
14
   it('backButton', () => {
15
   it('backButton', () => {
15
     expect(uut.backButton).toEqual(NavigationModule.backButton);
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 Zobrazit soubor

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