File tree 3 files changed +24
-0
lines changed
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,25 @@ import * as React from 'react';
2
2
import {
3
3
SafeAreaProvider ,
4
4
SafeAreaConsumer ,
5
+ initialWindowSafeAreaInsets ,
5
6
} from 'react-native-safe-area-context' ;
6
7
import {
7
8
getStatusBarHeight ,
8
9
getBottomSpace ,
9
10
} from 'react-native-iphone-x-helper' ;
10
11
12
+ // The provider component for safe area initializes asynchornously
13
+ // Until the insets are available, there'll be blank screen
14
+ // To avoid the blank screen, we specify some initial values
11
15
const initialSafeAreaInsets = {
16
+ // Approximate values which are good enough for most cases
12
17
top : getStatusBarHeight ( true ) ,
13
18
bottom : getBottomSpace ( ) ,
14
19
right : 0 ,
15
20
left : 0 ,
21
+ // If we are on a newer version of the library, we can get the correct window insets
22
+ // The component might not be filling the window, but this is good enough for most cases
23
+ ...initialWindowSafeAreaInsets ,
16
24
} ;
17
25
18
26
type Props = {
Original file line number Diff line number Diff line change @@ -2,17 +2,25 @@ import * as React from 'react';
2
2
import {
3
3
SafeAreaProvider ,
4
4
SafeAreaConsumer ,
5
+ initialWindowSafeAreaInsets ,
5
6
} from 'react-native-safe-area-context' ;
6
7
import {
7
8
getStatusBarHeight ,
8
9
getBottomSpace ,
9
10
} from 'react-native-iphone-x-helper' ;
10
11
12
+ // The provider component for safe area initializes asynchornously
13
+ // Until the insets are available, there'll be blank screen
14
+ // To avoid the blank screen, we specify some initial values
11
15
const initialSafeAreaInsets = {
16
+ // Approximate values which are good enough for most cases
12
17
top : getStatusBarHeight ( true ) ,
13
18
bottom : getBottomSpace ( ) ,
14
19
right : 0 ,
15
20
left : 0 ,
21
+ // If we are on a newer version of the library, we can get the correct window insets
22
+ // The component might not be filling the window, but this is good enough for most cases
23
+ ...initialWindowSafeAreaInsets ,
16
24
} ;
17
25
18
26
type Props = {
Original file line number Diff line number Diff line change @@ -2,17 +2,25 @@ import * as React from 'react';
2
2
import {
3
3
SafeAreaProvider ,
4
4
SafeAreaConsumer ,
5
+ initialWindowSafeAreaInsets ,
5
6
} from 'react-native-safe-area-context' ;
6
7
import {
7
8
getStatusBarHeight ,
8
9
getBottomSpace ,
9
10
} from 'react-native-iphone-x-helper' ;
10
11
12
+ // The provider component for safe area initializes asynchornously
13
+ // Until the insets are available, there'll be blank screen
14
+ // To avoid the blank screen, we specify some initial values
11
15
const initialSafeAreaInsets = {
16
+ // Approximate values which are good enough for most cases
12
17
top : getStatusBarHeight ( true ) ,
13
18
bottom : getBottomSpace ( ) ,
14
19
right : 0 ,
15
20
left : 0 ,
21
+ // If we are on a newer version of the library, we can get the correct window insets
22
+ // The component might not be filling the window, but this is good enough for most cases
23
+ ...initialWindowSafeAreaInsets ,
16
24
} ;
17
25
18
26
type Props = {
You can’t perform that action at this time.
0 commit comments