Skip to content

Commit 6053a2d

Browse files
Make Constants.statusBarHeight dynamic on phone orientation change (#3257)
* Make Constants.statusBarHeight dynamic on phone orientation change * Fix StatusBarManager mock --------- Co-authored-by: Ethan Sharabi <[email protected]>
1 parent 00f6a62 commit 6053a2d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

jestSetup/jest-setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Object.defineProperties = (obj, props) => {
1818

1919
global._UILIB_TESTING = true;
2020

21-
NativeModules.StatusBarManager = {getHeight: jest.fn()};
2221
jest.spyOn(AccessibilityInfo, 'isScreenReaderEnabled').mockImplementation(() => Promise.resolve(false));
2322

2423
// mock native modules
@@ -98,6 +97,7 @@ jest.mock('react-native-gesture-handler',
9897
jest.mock('react-native', () => {
9998
const reactNative = jest.requireActual('react-native');
10099
reactNative.NativeModules.KeyboardTrackingViewTempManager = {};
100+
reactNative.NativeModules.StatusBarManager = {getHeight: jest.fn()};
101101
const OriginalModal = reactNative.Modal;
102102
const React = jest.requireActual('react');
103103
const useDidUpdate = require('./useDidUpdate').default;

src/commons/Constants.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ isTablet = Platform.isPad || (getAspectRatio() < 1.6 && Math.max(screenWidth, sc
4040
function setStatusBarHeight() {
4141
const {StatusBarManager} = NativeModules;
4242
statusBarHeight = StatusBarManager?.HEIGHT || 0; // So there will be a value for any case
43-
// statusBarHeight = isIOS ? 20 : StatusBarManager.HEIGHT;
44-
// if (isIOS) {
45-
// // override guesstimate height with the actual height from StatusBarManager
46-
// StatusBarManager.getHeight((data: any) => (statusBarHeight = data.height));
47-
// }
43+
44+
if (isIOS) {
45+
// override guesstimate height with the actual height from StatusBarManager
46+
StatusBarManager.getHeight((data:{height:number}) => (statusBarHeight = data.height));
47+
}
4848
}
4949

5050
function getAspectRatio() {

0 commit comments

Comments
 (0)