(props: SafeAreaProps)
| 11 | } |
| 12 | |
| 13 | const SafeArea = (props: SafeAreaProps) => { |
| 14 | const { style, floatingButtonHeight, ignoreTopInset = false, ...otherProps } = props; |
| 15 | const { colors } = useTheme(); |
| 16 | const insets = useSafeAreaInsets(); |
| 17 | |
| 18 | const padding = useMemo( |
| 19 | () => |
| 20 | props.orientation === 'portrait' |
| 21 | ? { |
| 22 | paddingTop: ignoreTopInset ? 0 : insets.top, |
| 23 | paddingBottom: insets.bottom, |
| 24 | } |
| 25 | : { |
| 26 | paddingTop: ignoreTopInset ? 0 : insets.top, |
| 27 | paddingBottom: insets.bottom + (floatingButtonHeight ?? 0), |
| 28 | paddingLeft: insets.left, |
| 29 | paddingRight: insets.right, |
| 30 | }, |
| 31 | [insets, props.orientation, floatingButtonHeight, ignoreTopInset], |
| 32 | ); |
| 33 | |
| 34 | const componentStyle = useMemo(() => { |
| 35 | return StyleSheet.compose( |
| 36 | { |
| 37 | flex: 1, |
| 38 | backgroundColor: colors.background, |
| 39 | ...padding, |
| 40 | }, |
| 41 | style, |
| 42 | ); |
| 43 | }, [colors.background, padding, style]); |
| 44 | |
| 45 | return <View style={componentStyle} {...otherProps} />; |
| 46 | }; |
| 47 | |
| 48 | export default SafeArea; |
nothing calls this directly
no test coverage detected