diff --git a/index.js b/index.js index 23878f9..85a253f 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ // @flow -import { Dimensions, Platform, StatusBar } from 'react-native'; +import { Dimensions, PixelRatio, Platform, StatusBar } from "react-native"; const X_WIDTH = 375; const X_HEIGHT = 812; @@ -7,18 +7,36 @@ const X_HEIGHT = 812; const XSMAX_WIDTH = 414; const XSMAX_HEIGHT = 896; -const { height: W_HEIGHT, width: W_WIDTH } = Dimensions.get('window'); +const { height: W_HEIGHT, width: W_WIDTH } = Dimensions.get("window"); let isIPhoneX = false; +let isIPhoneXR = false; -if (Platform.OS === 'ios' && !Platform.isPad && !Platform.isTVOS) { - isIPhoneX = W_WIDTH === X_WIDTH && W_HEIGHT === X_HEIGHT || W_WIDTH === XSMAX_WIDTH && W_HEIGHT === XSMAX_HEIGHT; +if (Platform.OS === "ios" && !Platform.isPad && !Platform.isTVOS) { + isIPhoneX = + (W_WIDTH === X_WIDTH && W_HEIGHT === X_HEIGHT) || + (W_WIDTH === XSMAX_WIDTH && W_HEIGHT === XSMAX_HEIGHT); } -export function getStatusBarHeight(skipAndroid: boolean = false): number { - return Platform.select({ - ios: isIPhoneX ? 44 : 20, - android: skipAndroid ? 0 : StatusBar.currentHeight, - default: 0 - }) +isIPhoneXR = PixelRatio.get() === 3; + +let iosBottomBarHeight = 0; + +if (isIPhoneX) iosBottomBarHeight = 102* 0,75 ; +else if (isIPhoneXR) iosBottomBarHeight = 68* 0,75; + +export function getStatusBarHeight(skipAndroid = false) { + return Platform.select({ + ios: isIPhoneX ? 44 : 20, + android: skipAndroid ? 0 : StatusBar.currentHeight, + default: 0 + }); +} + +export function getHomeIndicatorHeight() { + return Platform.select({ + ios: iosBottomBarHeight, + android: 0, + default: 0 + }); }