npmchenwei111
Version:
test1111
30 lines (23 loc) • 609 B
JavaScript
/**
* Created by chenwei on 2017/7/16.
*/
import React from 'react'
import { Dimensions, Platform } from 'react-native'
import { px } from './Px2dp'
class Device {
width = Dimensions.get('window').width
height = Dimensions.get('window').height
statusBarPx = Platform.OS === 'ios' ? 44 : 48
androidStatusBarHeight = 24
statusBarHeight () {
if (Platform.OS === 'ios')
return px(20)
if (Platform.Version < 19)
return 0
return px(this.androidStatusBarHeight)
}
withStatusBar (height) {
return px(height) + this.statusBarHeight()
}
}
export default new Device()