utils.js 1.1 KB
/**
 * Created by DEV005 on 2017/8/31.
 */
import{
    Dimensions,
    Platform
} from 'react-native';
//是否 isIphoneX
export function isIphoneX(){
    let dimen = Dimensions.get('window');
    return (
        Platform.OS === 'ios' &&
        !Platform.isPad &&
        !Platform.isTVOS &&
        (dimen.height === 812 || dimen.width === 812)
    );
}
//设置头部填充高度
export function getHeaderHeight(){
    if( Platform.OS === 'android'){
        return 48;
    }else if(Platform.OS === 'ios') {
        if(isIphoneX()){
            return 88;
        }else {
            return 64;
        }
    }
}
//设置头部上边距
export function getHeaderPadding(){
    if( Platform.OS === 'android'){
        return 0;
    }else if(Platform.OS === 'ios'){
        if(isIphoneX()){
            return 44;
        }else {
            return 20;
        }
    }
}
//设置底部填充高度
export function getFooterBottom(){
    if( Platform.OS === 'android'){
        return 0;
    }else if(Platform.OS === 'ios'){
        if(isIphoneX()){
            return 34;
        }else {
            return 0;
        }
    }
}