123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- "use strict"
- import {Dimensions, StatusBar, Platform, PixelRatio} from 'react-native'
- const designWidth = 750
- const designHeight = 1334
- export const width = Dimensions.get('window').width;
- export const height = Dimensions.get('window').height;
- export const unitWidth = width / designWidth
- export const unitHeight = height / designHeight
- export const statusBarHeight = getStatusBarHeight();
- export const safeAreaViewHeight = isIphoneX() ? 34 : 0
- export const titleHeight = unitWidth * 100 + statusBarHeight;
- export const fontscale = PixelRatio.getFontScale()
- export function isIphoneX() {
- const X_WIDTH = 375;
- const X_HEIGHT = 812;
- return Platform.OS == 'ios' && (height == X_HEIGHT && width == X_WIDTH)
- }
- export function getStatusBarHeight() {
- if (Platform.OS == 'android') return StatusBar.currentHeight;
- if (isIphoneX()) {
- return 44
- }
- return 20
- }
|