forked from GertjanReynaert/react-native-device
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevice.js
More file actions
33 lines (29 loc) · 945 Bytes
/
Copy pathDevice.js
File metadata and controls
33 lines (29 loc) · 945 Bytes
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
var { NativeModules, Dimensions, Platform } = require('react-native');
var DeviceUtil = NativeModules.DeviceUtil;
// Forked. Only use isIpad/isiPhone. Case added to compile on android.
class Device {
constructor() {
this.width = Dimensions.get('window').width;
this.height = Dimensions.get('window').height;
if ( Platform.OS === 'ios') {
this.model = DeviceUtil.model;
this.deviceName = DeviceUtil.name;
this.systemName = DeviceUtil.systemName;
this.systemVersion = DeviceUtil.systemVersion;
this.deviceVersion = DeviceUtil.deviceVersion;
} else {
this.model = "non-ios";
this.deviceName = "non-ios";
this.systemName = "non-ios";
this.systemVersion = "non-ios";
this.deviceVersion = "non-ios";
}
}
isIpad() {
return this.model.indexOf('iPad') >= 0;
}
isIphone() {
return this.model.indexOf('iPhone') >= 0;
}
}
module.exports = new Device();