Skip to content

Instantly share code, notes, and snippets.

@alexkuttig
Created March 24, 2018 13:47
Show Gist options
  • Save alexkuttig/8db561c0d8286ec9c2485b931fb20e34 to your computer and use it in GitHub Desktop.
Save alexkuttig/8db561c0d8286ec9c2485b931fb20e34 to your computer and use it in GitHub Desktop.
DimensionsHelper for react-native
// @flow
'use strict';
import {
Platform,
StatusBar,
Dimensions
} from 'react-native';
import { isIphoneX } from 'react-native-iphone-x-helper';
export const statusBarHeight = Platform.OS === 'ios' ? (isIphoneX() ? 44 : 20) : StatusBar.currentHeight;
export const headerHeight = Platform.OS === 'ios' ? 44 : 56;
export const paddingBottomHeight = Platform.OS === 'ios' ? (isIphoneX() ? 34 : 0) : 0;
export const SafeAreaWithHeader: {vh: number, vw: number} = {
vh: (Dimensions.get('window').height - statusBarHeight - headerHeight - paddingBottomHeight) / 100,
vw: Dimensions.get('window').width / 100
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment