Skip to content

Commit 53dca64

Browse files
nitzanyizsivantha96
andcommitted
fix: 🐛 status bar manager issue with new rn fabric (#3425)
* fix: 🐛 status bar manager issue with new rn fabric * added handling for backwards support * reverted test change --------- Co-authored-by: Sivantha Paranavithana <[email protected]>
1 parent 953d13d commit 53dca64

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/commons/Constants.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
NativeModules,
55
I18nManager,
66
AccessibilityInfo,
7-
AccessibilityChangeEvent
7+
AccessibilityChangeEvent,
8+
StatusBar
89
} from 'react-native';
910

1011
export enum orientations {
@@ -34,14 +35,14 @@ let breakpoints: Breakpoint[];
3435
let defaultMargin = 0;
3536

3637
const isSubWindow = windowWidth < screenWidth;
37-
//@ts-ignore
38-
isTablet = Platform.isPad || (getAspectRatio() < 1.6 && Math.max(screenWidth, screenHeight) >= 900);
38+
isTablet =
39+
(Platform.OS === 'ios' && Platform.isPad) || (getAspectRatio() < 1.6 && Math.max(screenWidth, screenHeight) >= 900);
3940

4041
function setStatusBarHeight() {
4142
const {StatusBarManager} = NativeModules;
42-
statusBarHeight = StatusBarManager?.HEIGHT || 0; // So there will be a value for any case
43-
44-
if (isIOS) {
43+
statusBarHeight = (StatusBar.currentHeight ?? StatusBarManager?.HEIGHT) || 0;
44+
45+
if (isIOS && StatusBarManager) {
4546
// override guesstimate height with the actual height from StatusBarManager
4647
StatusBarManager.getHeight((data:{height:number}) => (statusBarHeight = data.height));
4748
}
@@ -125,7 +126,7 @@ const constants = {
125126
return screenHeight <= 600;
126127
},
127128
get isWideScreen() {
128-
return isTablet && !isSubWindow || this.isLandscape;
129+
return (isTablet && !isSubWindow) || this.isLandscape;
129130
},
130131
get screenAspectRatio() {
131132
return getAspectRatio();

0 commit comments

Comments
 (0)