import { Dimensions, Platform, StatusBar } from 'react-native'; const X_WIDTH = 375; const X_HEIGHT = 812; const XSMAX_WIDTH = 414; const XSMAX_HEIGHT = 896; const { height, width } = Dimensions.get('window'); export const isIPhoneX = () => { if (Platform.OS === 'ios' && !Platform.isPad && !Platform.isTV) { return ( (width === X_WIDTH && height === X_HEIGHT) || (width === XSMAX_WIDTH && height === XSMAX_HEIGHT) ); } return false; }; export const StatusBarHeight = Platform.select({ ios: isIPhoneX() ? 44 : 20, android: StatusBar.currentHeight, default: 20 }); export type LayoutType = { width: number; height: number }; export function getDefaultHeaderHeight( layout: LayoutType, modalPresentation: boolean, statusBarHeight: number ): number { let headerHeight; const isLandscape = layout.width > layout.height; if (Platform.OS === 'ios') { if (Platform.isPad || Platform.isTV) { if (modalPresentation) { headerHeight = 56; } else { headerHeight = 50; } } else { if (isLandscape) { headerHeight = 32; } else { if (modalPresentation) { headerHeight = 56; } else { headerHeight = 44; } } } } else if (Platform.OS === 'android') { headerHeight = 56; } else { headerHeight = 64; } return headerHeight + statusBarHeight; }