-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
index.js
97 lines (75 loc) · 2.11 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use strict';
import { Dimensions, Platform } from 'react-native';
import { hasNotch, getApiLevel } from 'react-native-device-info';
export default class Device {
static getDeviceWidth() {
return Dimensions.get('window').width;
}
static getDeviceHeight() {
return Dimensions.get('window').height;
}
static isIos() {
return Platform.OS === 'ios';
}
static isAndroid() {
return Platform.OS === 'android';
}
static isIpad() {
return this.getDeviceWidth() >= 1000 || this.getDeviceHeight() >= 1000;
}
static isLandscape() {
return this.getDeviceWidth() > this.getDeviceHeight();
}
static isIphone5() {
return this.getDeviceWidth() === 320;
}
static isIphone5S() {
return this.getDeviceWidth() === 320;
}
static isIphone6() {
return this.getDeviceWidth() === 375;
}
static isIphone6Plus() {
return this.getDeviceWidth() === 414;
}
static isIphone6SPlus() {
return this.getDeviceWidth() === 414;
}
static isIphoneX() {
return this.getDeviceWidth() >= 375 && this.getDeviceHeight() >= 812;
}
static isIpadPortrait9_7() {
return this.getDeviceHeight() === 1024 && this.getDeviceWidth() === 736;
}
static isIpadLandscape9_7() {
return this.getDeviceHeight() === 736 && this.getDeviceWidth() === 1024;
}
static isIpadPortrait10_5() {
return this.getDeviceHeight() === 1112 && this.getDeviceWidth() === 834;
}
static isIpadLandscape10_5() {
return this.getDeviceWidth() === 1112 && this.getDeviceHeight() === 834;
}
static isIpadPortrait12_9() {
return this.getDeviceWidth() === 1024 && this.getDeviceHeight() === 1366;
}
static isIpadLandscape12_9() {
return this.getDeviceWidth() === 1366 && this.getDeviceHeight() === 1024;
}
static isSmallDevice() {
return this.getDeviceHeight() < 600;
}
static isMediumDevice() {
return this.getDeviceHeight() < 736;
}
static isLargeDevice() {
return this.getDeviceHeight() > 736;
}
static hasNotch() {
return hasNotch();
}
static async getDeviceAPILevel() {
const apiLevel = await getApiLevel();
return apiLevel;
}
}