Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 9a8941a

Browse files
committed
Use getStatusBarHeight
1 parent 2661f48 commit 9a8941a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Header.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { Animated, Dimensions, Platform, StatusBar, StyleSheet, View } from 'react-native';
33
import { withNavigation, HeaderBackButton } from 'react-navigation';
4+
import { getStatusBarHeight } from 'react-native-safe-area-view';
45
import { isIphoneX } from 'react-native-iphone-x-helper'
56

67
// @todo: make this work properly when in landscape
@@ -11,8 +12,10 @@ const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56;
1112

1213
// @todo: this is static and we don't know if it's visible or not on iOS.
1314
// need to use a more reliable and cross-platform API when one exists, like
14-
// LayoutContext.
15-
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? (hasNotch ? 40 : 25) : StatusBar.currentHeight;
15+
// LayoutContext. We also don't know if it's translucent or not on Android
16+
// and depend on react-native-safe-area-view to tell us.
17+
const ANDROID_STATUS_BAR_HEIGHT = getStatusBarHeight ? getStatusBarHeight() : StatusBar.currentHeight;
18+
const STATUSBAR_HEIGHT = Platform.OS === 'ios' ? (hasNotch ? 40 : 25) : ANDROID_STATUS_BAR_HEIGHT;
1619

1720
@withNavigation
1821
export default class Header extends React.PureComponent {

0 commit comments

Comments
 (0)