Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: provide initial values for safe area to prevent blank screen (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 authored and osdnk committed Jan 3, 2020
1 parent 6b9b999 commit 77b7570
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"react-dom": "~16.9.0",
"react-native": "~0.61.5",
"react-native-gesture-handler": "~1.5.0",
"react-native-iphone-x-helper": "^1.2.1",
"react-native-paper": "^3.3.0",
"react-native-reanimated": "^1.4.0",
"react-native-safe-area-context": "^0.6.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/bottom-tabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.19",
"color": "^3.1.2"
"color": "^3.1.2",
"react-native-iphone-x-helper": "^1.2.1"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
Expand Down
17 changes: 16 additions & 1 deletion packages/bottom-tabs/src/views/SafeAreaProviderCompat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import {
SafeAreaProvider,
SafeAreaConsumer,
} from 'react-native-safe-area-context';
import {
getStatusBarHeight,
getBottomSpace,
} from 'react-native-iphone-x-helper';

const initialSafeAreaInsets = {
top: getStatusBarHeight(true),
bottom: getBottomSpace(),
right: 0,
left: 0,
};

type Props = {
children: React.ReactNode;
Expand All @@ -19,7 +30,11 @@ export default function SafeAreaProviderCompat({ children }: Props) {
return children;
}

return <SafeAreaProvider>{children}</SafeAreaProvider>;
return (
<SafeAreaProvider initialSafeAreaInsets={initialSafeAreaInsets}>
{children}
</SafeAreaProvider>
);
}}
</SafeAreaConsumer>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/drawer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.19",
"color": "^3.1.2"
"color": "^3.1.2",
"react-native-iphone-x-helper": "^1.2.1"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
Expand Down
17 changes: 16 additions & 1 deletion packages/drawer/src/views/SafeAreaProviderCompat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import {
SafeAreaProvider,
SafeAreaConsumer,
} from 'react-native-safe-area-context';
import {
getStatusBarHeight,
getBottomSpace,
} from 'react-native-iphone-x-helper';

const initialSafeAreaInsets = {
top: getStatusBarHeight(true),
bottom: getBottomSpace(),
right: 0,
left: 0,
};

type Props = {
children: React.ReactNode;
Expand All @@ -19,7 +30,11 @@ export default function SafeAreaProviderCompat({ children }: Props) {
return children;
}

return <SafeAreaProvider>{children}</SafeAreaProvider>;
return (
<SafeAreaProvider initialSafeAreaInsets={initialSafeAreaInsets}>
{children}
</SafeAreaProvider>
);
}}
</SafeAreaConsumer>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/stack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
"dependencies": {
"@react-navigation/routers": "^5.0.0-alpha.19",
"color": "^3.1.2"
"color": "^3.1.2",
"react-native-iphone-x-helper": "^1.2.1"
},
"devDependencies": {
"@react-native-community/bob": "^0.7.0",
Expand Down
17 changes: 16 additions & 1 deletion packages/stack/src/views/SafeAreaProviderCompat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import {
SafeAreaProvider,
SafeAreaConsumer,
} from 'react-native-safe-area-context';
import {
getStatusBarHeight,
getBottomSpace,
} from 'react-native-iphone-x-helper';

const initialSafeAreaInsets = {
top: getStatusBarHeight(true),
bottom: getBottomSpace(),
right: 0,
left: 0,
};

type Props = {
children: React.ReactNode;
Expand All @@ -19,7 +30,11 @@ export default function SafeAreaProviderCompat({ children }: Props) {
return children;
}

return <SafeAreaProvider>{children}</SafeAreaProvider>;
return (
<SafeAreaProvider initialSafeAreaInsets={initialSafeAreaInsets}>
{children}
</SafeAreaProvider>
);
}}
</SafeAreaConsumer>
);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13191,6 +13191,11 @@ react-native-gesture-handler@^1.5.0, react-native-gesture-handler@~1.5.0:
invariant "^2.2.4"
prop-types "^15.7.2"

react-native-iphone-x-helper@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.2.1.tgz#645e2ffbbb49e80844bb4cbbe34a126fda1e6772"
integrity sha512-/VbpIEp8tSNNHIvstuA3Swx610whci1Zpc9mqNkqn14DkMbw+ORviln2u0XyHG1kPvvwTNGZY6QpeFwxYaSdbQ==

react-native-paper@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/react-native-paper/-/react-native-paper-3.3.0.tgz#c2a1e9b793b7063aa1848c1ce7db5719912e215a"
Expand Down

0 comments on commit 77b7570

Please sign in to comment.