Skip to content

Commit 2bbab7b

Browse files
committed
use StatusBarManager to get the actual ios device status bar (since the value is different for iphoneX)
1 parent 95f58c9 commit 2bbab7b

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

jest-setup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import {NativeModules} from 'react-native';
2+
3+
NativeModules.StatusBarManager = {getHeight: jest.fn()};

package.json

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-ui-lib",
3-
"version": "3.3.33",
3+
"version": "3.3.34",
44
"main": "index.js",
55
"author": "Ethan Sharabi <[email protected]>",
66
"publishConfig": {
@@ -71,22 +71,16 @@
7171
},
7272
"jest": {
7373
"preset": "react-native",
74-
"testPathIgnorePatterns": [
75-
"/e2e/",
76-
"/node_modules/"
77-
]
74+
"testPathIgnorePatterns": ["/e2e/", "/node_modules/"],
75+
"setupFiles": ["./jest-setup.js"]
7876
},
7977
"babel": {
8078
"env": {
8179
"test": {
82-
"presets": [
83-
"react-native"
84-
],
80+
"presets": ["react-native"],
8581
"retainLines": true
8682
}
8783
},
88-
"plugins": [
89-
"transform-inline-environment-variables"
90-
]
84+
"plugins": ["transform-inline-environment-variables"]
9185
}
9286
}

src/helpers/Constants.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import {Platform, Dimensions, NativeModules} from 'react-native';
22

3-
const { StatusBarManager } = NativeModules;
3+
const {StatusBarManager} = NativeModules;
44
const {height, width} = Dimensions.get('window');
55

66
export const isAndroid = Platform.OS === 'android';
77
export const isIOS = Platform.OS === 'ios';
88
export const screenWidth = width;
99
export const screenHeight = height;
10-
export const isSmallScreen = isIOS ? (screenWidth <= 320) : (screenWidth <= 360);
10+
export const isSmallScreen = isIOS ? screenWidth <= 320 : screenWidth <= 360;
1111
export const isShortScreen = screenHeight <= 600;
12-
export const statusBarHeight = isIOS ? 20 : StatusBarManager.HEIGHT;
12+
export let statusBarHeight = isIOS ? 20 : StatusBarManager.HEIGHT; // eslint-disable-line
1313
export const isIphoneX = isIOS && !Platform.isPad && !Platform.isTVOS && (screenHeight === 812 || screenWidth === 812);
14+
15+
// override guesstimate height with the actual height from StatusBarManager
16+
if (isIOS) {
17+
StatusBarManager.getHeight(data => (statusBarHeight = data.height));
18+
}

0 commit comments

Comments
 (0)