Created
August 14, 2019 22:00
-
-
Save janicduplessis/0f7e4d2bcd46ac80f8b8cf415f91a1e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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