Skip to content

Commit 7160a51

Browse files
committed
chore: set initial insets for safe areas
1 parent ae680a1 commit 7160a51

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

packages/bottom-tabs/src/views/SafeAreaProviderCompat.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@ import * as React from 'react';
22
import {
33
SafeAreaProvider,
44
SafeAreaConsumer,
5+
initialWindowSafeAreaInsets,
56
} from 'react-native-safe-area-context';
67
import {
78
getStatusBarHeight,
89
getBottomSpace,
910
} from 'react-native-iphone-x-helper';
1011

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
1115
const initialSafeAreaInsets = {
16+
// Approximate values which are good enough for most cases
1217
top: getStatusBarHeight(true),
1318
bottom: getBottomSpace(),
1419
right: 0,
1520
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,
1624
};
1725

1826
type Props = {

packages/drawer/src/views/SafeAreaProviderCompat.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@ import * as React from 'react';
22
import {
33
SafeAreaProvider,
44
SafeAreaConsumer,
5+
initialWindowSafeAreaInsets,
56
} from 'react-native-safe-area-context';
67
import {
78
getStatusBarHeight,
89
getBottomSpace,
910
} from 'react-native-iphone-x-helper';
1011

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
1115
const initialSafeAreaInsets = {
16+
// Approximate values which are good enough for most cases
1217
top: getStatusBarHeight(true),
1318
bottom: getBottomSpace(),
1419
right: 0,
1520
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,
1624
};
1725

1826
type Props = {

packages/stack/src/views/SafeAreaProviderCompat.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@ import * as React from 'react';
22
import {
33
SafeAreaProvider,
44
SafeAreaConsumer,
5+
initialWindowSafeAreaInsets,
56
} from 'react-native-safe-area-context';
67
import {
78
getStatusBarHeight,
89
getBottomSpace,
910
} from 'react-native-iphone-x-helper';
1011

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
1115
const initialSafeAreaInsets = {
16+
// Approximate values which are good enough for most cases
1217
top: getStatusBarHeight(true),
1318
bottom: getBottomSpace(),
1419
right: 0,
1520
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,
1624
};
1725

1826
type Props = {

0 commit comments

Comments
 (0)