Created
September 25, 2018 14:47
-
-
Save MacKentoch/c9ef21f3f4a1937fd25895520b2e58e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Dimensions, Platform, StatusBar } from 'react-native'; | |
// NOTE: | |
// const iPhoneXSMax = { width: 414, height: 896 }; | |
// const iphoneXS = { width: 375, scale: 3, height: 812 }; | |
// const iphoneXR = { width: 414, height: 896 }; | |
export function isIphoneX() { | |
const dimen = Dimensions.get('window'); | |
return ( | |
Platform.OS === 'ios' && | |
!Platform.isPad && | |
!Platform.isTVOS && | |
(dimen.height >= 812 || dimen.width >= 812) | |
); | |
} | |
export function ifIphoneX(iphoneXStyle, regularStyle) { | |
if (isIphoneX()) { | |
return iphoneXStyle; | |
} | |
return regularStyle; | |
} | |
export function getStatusBarHeightOffset() { | |
return Platform.select({ | |
ios: ifIphoneX(30, 0), | |
android: StatusBar.currentHeight, | |
}); | |
} | |
export function getBottomSpaceOffset() { | |
return isIphoneX() ? 34 : 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment