blob: 3bdbf7e33481cf420d3975283009c1c191bb216e (
plain) (
blame)
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
|
import { Dimensions, Platform, StatusBar } from 'react-native';
export function isIphoneX() {
const dimen = Dimensions.get('window');
return (
Platform.OS === 'ios' &&
!Platform.isPad &&
!Platform.isTVOS &&
((dimen.height === 812 || dimen.width === 812) || (dimen.height === 896 || dimen.width === 896))
);
}
export function ifIphoneX(iphoneXStyle, regularStyle) {
if (isIphoneX()) {
return iphoneXStyle;
}
return regularStyle;
}
export function getStatusBarHeight(safe) {
return Platform.select({
ios: ifIphoneX(safe ? 44 : 30, 20),
android: StatusBar.currentHeight
});
}
export function getBottomSpace() {
return isIphoneX() ? 34 : 0;
}
export function timeConverter(UNIX_timestamp) {
var a = new Date(UNIX_timestamp * 1000);
var year = a.getFullYear();
var month = a.getMonth() + 1;
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = formatInt(hour) + ':' + formatInt(min) + ':' + formatInt(sec) + ' ' + formatInt(date) + '.' + formatInt(month) + '.' + year;
return time;
}
function formatInt(num) {
return ("00" + num).slice(-2)
}
|