react-native-iphone-x-xr-xs-xsmax
Version:
A small library that checks the size of the iPhone screen and determines if it is iPhone X, XR, XS or XS MAX
21 lines (16 loc) • 454 B
JavaScript
import { Dimensions, Platform } from 'react-native'
export function isIphoneX() {
const dim = Dimensions.get('window')
return (
// This has to be iOS
Platform.OS === 'ios' &&
// Check either, iPhone X or XR
(isIPhoneXSize(dim) || isIPhoneXrSize(dim))
)
}
export function isIPhoneXSize(dim) {
return dim.height == 812 || dim.width == 812
}
export function isIPhoneXrSize(dim) {
return dim.height == 896 || dim.width == 896
}