@@ -6,14 +6,14 @@ const orientations = {
6
6
LANDSCAPE : 'landscape'
7
7
} ;
8
8
9
- const isAndroid = Platform . OS === 'android' ;
10
- const isIOS = Platform . OS === 'ios' ;
9
+ const isAndroid : boolean = Platform . OS === 'android' ;
10
+ const isIOS : boolean = Platform . OS === 'ios' ;
11
11
let isTablet : boolean ;
12
12
let statusBarHeight : number ;
13
- let screenHeight = Dimensions . get ( 'screen' ) . height ;
14
- let screenWidth = Dimensions . get ( 'screen' ) . width ;
15
- let windowHeight = Dimensions . get ( 'window' ) . height ;
16
- let windowWidth = Dimensions . get ( 'window' ) . width ;
13
+ let screenHeight : number = Dimensions . get ( 'screen' ) . height ;
14
+ let screenWidth : number = Dimensions . get ( 'screen' ) . width ;
15
+ let windowHeight : number = Dimensions . get ( 'window' ) . height ;
16
+ let windowWidth : number = Dimensions . get ( 'window' ) . width ;
17
17
18
18
//@ts -ignore
19
19
isTablet = Platform . isPad || ( getAspectRatio ( ) < 1.6 && Math . max ( screenWidth , screenHeight ) >= 900 ) ;
@@ -29,17 +29,13 @@ function setStatusBarHeight() {
29
29
}
30
30
31
31
function getAspectRatio ( ) {
32
- return screenWidth < screenHeight
33
- ? screenHeight / screenWidth
34
- : screenWidth / screenHeight ;
32
+ return screenWidth < screenHeight ? screenHeight / screenWidth : screenWidth / screenHeight ;
35
33
}
36
34
37
-
38
35
function getOrientation ( height : number , width : number ) {
39
36
return width < height ? orientations . PORTRAIT : orientations . LANDSCAPE ;
40
37
}
41
38
42
-
43
39
export function updateConstants ( dimensions : any ) {
44
40
screenHeight = dimensions . screen . height ;
45
41
screenWidth = dimensions . screen . width ;
@@ -49,17 +45,16 @@ export function updateConstants(dimensions: any) {
49
45
setStatusBarHeight ( ) ;
50
46
}
51
47
52
-
53
-
54
-
55
48
const accessibility = {
56
49
isScreenReaderEnabled : false
57
50
} ;
51
+
58
52
function handleScreenReaderChanged ( isScreenReaderEnabled : AccessibilityEvent ) {
59
53
accessibility . isScreenReaderEnabled = isScreenReaderEnabled as boolean ;
60
54
}
61
55
62
56
AccessibilityInfo . addEventListener ( 'screenReaderChanged' , handleScreenReaderChanged ) ;
57
+
63
58
function setAccessibility ( ) {
64
59
AccessibilityInfo . isScreenReaderEnabled ( ) . then ( isScreenReaderEnabled => {
65
60
accessibility . isScreenReaderEnabled = isScreenReaderEnabled ;
@@ -134,25 +129,17 @@ const constants = {
134
129
addDimensionsEventListener : ( callback : any ) => {
135
130
Dimensions . addEventListener ( 'change' , callback ) ;
136
131
} ,
137
-
132
+ /* Dimensions */
138
133
removeDimensionsEventListener : ( callback : any ) => {
139
134
Dimensions . removeEventListener ( 'change' , callback ) ;
140
135
} ,
141
- // Accessibility
136
+ /* Accessibility */
142
137
get accessibility ( ) {
143
138
return accessibility ;
144
139
}
145
140
} ;
146
141
147
-
148
-
149
142
setStatusBarHeight ( ) ;
150
-
151
-
152
-
153
-
154
143
Dimensions . addEventListener ( 'change' , updateConstants ) ;
155
144
156
-
157
-
158
145
export default constants ;
0 commit comments