|
|
@@ -1,53 +0,0 @@
|
|
1
|
|
-// @flow
|
|
2
|
|
-
|
|
3
|
|
-import { Dimensions } from 'react-native';
|
|
4
|
|
-
|
|
5
|
|
-import Platform from './Platform';
|
|
6
|
|
-
|
|
7
|
|
-const IPHONEX_HEIGHT = 812;
|
|
8
|
|
-const IPHONEX_WIDTH = 375;
|
|
9
|
|
-const IPHONE_OFFSET = 20;
|
|
10
|
|
-const IPHONEX_OFFSET = 44;
|
|
11
|
|
-
|
|
12
|
|
-/**
|
|
13
|
|
- * Determines the offset to be used for the device. This uses a custom
|
|
14
|
|
- * implementation to minimize empty area around screen, especially on iPhone X.
|
|
15
|
|
- *
|
|
16
|
|
- * @returns {number}
|
|
17
|
|
- */
|
|
18
|
|
-export function getSafetyOffset() {
|
|
19
|
|
- if (Platform.OS === 'android') {
|
|
20
|
|
- // Android doesn't need offset, except the Essential phone. Should be
|
|
21
|
|
- // addressed later with a generic solution.
|
|
22
|
|
- return 0;
|
|
23
|
|
- }
|
|
24
|
|
-
|
|
25
|
|
- return isIPhoneX() ? IPHONEX_OFFSET : IPHONE_OFFSET;
|
|
26
|
|
-}
|
|
27
|
|
-
|
|
28
|
|
-/**
|
|
29
|
|
- * Determines if the device is an iPad or not.
|
|
30
|
|
- *
|
|
31
|
|
- * @returns {boolean}
|
|
32
|
|
- */
|
|
33
|
|
-export function isIPad() {
|
|
34
|
|
- const { height, width } = Dimensions.get('window');
|
|
35
|
|
-
|
|
36
|
|
- return (
|
|
37
|
|
- Platform.OS === 'ios'
|
|
38
|
|
- && (Math.max(height, width) / Math.min(height, width)) < 1.6);
|
|
39
|
|
-}
|
|
40
|
|
-
|
|
41
|
|
-/**
|
|
42
|
|
- * Determines if it's an iPhone X or not.
|
|
43
|
|
- *
|
|
44
|
|
- * @returns {boolean}
|
|
45
|
|
- */
|
|
46
|
|
-export function isIPhoneX() {
|
|
47
|
|
- const { height, width } = Dimensions.get('window');
|
|
48
|
|
-
|
|
49
|
|
- return (
|
|
50
|
|
- Platform.OS === 'ios'
|
|
51
|
|
- && ((height === IPHONEX_HEIGHT && width === IPHONEX_WIDTH)
|
|
52
|
|
- || (height === IPHONEX_WIDTH && width === IPHONEX_HEIGHT)));
|
|
53
|
|
-}
|