-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (46 loc) · 1.18 KB
/
index.js
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
import { Dimensions, Platform } from 'react-native';
/**
* iOS
* =============================================================================
*/
const iPhoneXHeight = 812;
const iPhoneXRHeight = 896;
/**
* Check Platform OS is iOS
*/
export const isIOS = Platform.OS === 'ios';
/**
* Check is iPhone
*/
export const isIPhone = isIOS && !Platform.isPad && !Platform.isTVOS;
/**
* Check is iPhone X size. For iPhone X and XS have 812px height
* @param {Object} dim Dimensions
*/
export function isIPhoneXSize(dim) {
return dim.height == iPhoneXHeight || dim.width == iPhoneXHeight;
}
/**
* Check is iPhone XR size. For iPhone XS Max and XR have 896px height.
* @param {Object} dim Dimensions
*/
export function isIPhoneXRSize(dim) {
return dim.height == iPhoneXRHeight || dim.width == iPhoneXRHeight;
}
/**
* Check is iPhoneX device
*/
export function isIphoneX() {
const dim = Dimensions.get('window');
return (
isIPhone && (isIPhoneXSize(dim) || isIPhoneXRSize(dim))
);
}
/**
* Android
* =============================================================================
*/
/**
* Check Platform OS is Android
*/
export const isAndroid = Platform.OS === 'android';