utils.js
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Created by DEV005 on 2017/8/31.
*/
import{
Dimensions,
Platform
} from 'react-native';
import Toast from 'react-native-root-toast';
import {zoomW,zoomH} from './getSize';
//是否 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/zoomH);
}else if(Platform.OS === 'ios') {
if(isIphoneX()){
return (88/zoomH);
}else {
return (64/zoomH);
}
}
}
//设置头部上边距
export function getHeaderPadding(){
if( Platform.OS === 'android'){
return 0;
}else if(Platform.OS === 'ios'){
if(isIphoneX()){
return (44/zoomH);
}else {
return (20/zoomH);
}
}
}
//设置底部填充高度
export function getFooterBottom(){
if( Platform.OS === 'android'){
return 0;
}else if(Platform.OS === 'ios'){
if(isIphoneX()){
return 34;
}else {
return 0;
}
}
}
//Toast
export const xnToast = (content) => {
setTimeout(() =>{
if(global.toast !== undefined){
Toast.hide(toast);
}
global.toast = Toast.show(content.toString(),{
duration:Toast.durations.LONG,
position:Toast.positions.CENTER,
shadow:true,
animation:true,
hideOnPress:true,
delay:0
});
},500);
};