Skip to content

Instantly share code, notes, and snippets.

@janicduplessis
Created August 14, 2019 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janicduplessis/0f7e4d2bcd46ac80f8b8cf415f91a1e5 to your computer and use it in GitHub Desktop.
Save janicduplessis/0f7e4d2bcd46ac80f8b8cf415f91a1e5 to your computer and use it in GitHub Desktop.
const CompatSafeAreaView = ({
forceInsets = {},
children,
}: {
forceInsets?: {
top?: boolean;
right?: boolean;
bottom?: boolean;
left?: boolean;
};
children?: React.ReactNode;
}) => {
return (
<SafeAreaView>
{insets => {
const top = forceInsets.top === true ? 0 : insets.top;
const right = forceInsets.right === true ? 0 : insets.right;
const bottom = forceInsets.bottom === true ? 0 : insets.bottom;
const left = forceInsets.left === true ? 0 : insets.left;
return (
<View
style={{
flex: 1,
paddingTop: top,
paddingRight: right,
paddingBottom: bottom,
paddingLeft: left,
}}
>
{children}
</View>
);
}}
</SafeAreaView>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment