-
Notifications
You must be signed in to change notification settings - Fork 131
/
index.js
58 lines (48 loc) · 1.28 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
import { NativeModules, Platform } from 'react-native';
export function get(dim) {
if (Platform.OS !== 'android') {
console.warn('react-native-extra-dimensions-android is only available on Android. Trying to access', dim);
return 0;
} else { // android
try {
if (!NativeModules.ExtraDimensions) {
throw "ExtraDimensions not defined. Try rebuilding your project. e.g. react-native run-android";
}
const result = NativeModules.ExtraDimensions[dim];
if (typeof result !== 'number') {
return result;
}
return result;
} catch (e) {
console.error(e);
}
}
}
export function getRealWindowHeight() {
return get('REAL_WINDOW_HEIGHT');
}
export function getRealWindowWidth() {
return get('REAL_WINDOW_WIDTH');
}
export function getStatusBarHeight() {
return get('STATUS_BAR_HEIGHT');
}
export function getSoftMenuBarHeight() {
return get('SOFT_MENU_BAR_HEIGHT');
}
export function getSmartBarHeight() {
return get('SMART_BAR_HEIGHT');
}
export function isSoftMenuBarEnabled() {
return get('SOFT_MENU_BAR_ENABLED');
}
// stay compatible with pre-es6 exports
export default {
get,
getRealWindowHeight,
getRealWindowWidth,
getStatusBarHeight,
getSoftMenuBarHeight,
getSmartBarHeight,
isSoftMenuBarEnabled
}