Skip to content

Instantly share code, notes, and snippets.

@steniowagner
Last active January 26, 2019 00:40
Show Gist options
  • Save steniowagner/86bb59e409fcb83782a9fbc5f7d2053d to your computer and use it in GitHub Desktop.
Save steniowagner/86bb59e409fcb83782a9fbc5f7d2053d to your computer and use it in GitHub Desktop.
// @flow
import { Dimensions, Platform } from 'react-native';
const screenWidth = Dimensions.get('window').width;
const screenHeight = Dimensions.get('window').height;
const IPHONEX_WIDTH = 375;
const IPHONEX_HEIGHT = 812;
const isIphoneX = (): boolean => {
const isIphoneXInPortraitMode = screenHeight === IPHONEX_HEIGHT && screenWidth === IPHONEX_WIDTH;
const isIphoneXInLandscapeMode = screenHeight === IPHONEX_WIDTH && screenWidth === IPHONEX_HEIGHT;
return (
Platform.OS === 'ios'
&& (isIphoneXInPortraitMode || isIphoneXInLandscapeMode)
);
};
export default isIphoneX;
/**
* USAGE
* tabBarOptions: {
style: {
paddingBottom: isIphoneX() ? 30 : 0,
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment