diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-10-14 22:09:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-14 22:09:47 +0300 |
commit | 2d88463453abfad1e9e45bbd6cdbcd5824a7e770 (patch) | |
tree | 40c411208b5e0c68d02814d5f525243c27cce306 /src/components/Layout.tsx | |
parent | 0f40013963aaf4f3ac893ce58958ea30bc7a1efd (diff) | |
download | voidsky-2d88463453abfad1e9e45bbd6cdbcd5824a7e770.tar.zst |
Remove top padding from shell, move down into individual screens (#5548)
Diffstat (limited to 'src/components/Layout.tsx')
-rw-r--r-- | src/components/Layout.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx new file mode 100644 index 000000000..57e373164 --- /dev/null +++ b/src/components/Layout.tsx @@ -0,0 +1,41 @@ +import React from 'react' +import {View, ViewStyle} from 'react-native' +import {StyleProp} from 'react-native' +import {useSafeAreaInsets} from 'react-native-safe-area-context' + +import {atoms as a} from '#/alf' + +// Every screen should have a Layout component wrapping it. +// This component provides a default padding for the top of the screen. +// This allows certain screens to avoid the top padding if they want to. +// +// In a future PR I will add a unified header component to this file and +// things like a preconfigured scrollview. + +/** + * Every screen should have a Layout.Screen component wrapping it. + * This component provides a default padding for the top of the screen + * and height/minHeight + */ +let Screen = ({ + disableTopPadding, + style, + ...props +}: React.ComponentProps<typeof View> & { + disableTopPadding?: boolean + style?: StyleProp<ViewStyle> +}): React.ReactNode => { + const {top} = useSafeAreaInsets() + return ( + <View + style={[ + {paddingTop: disableTopPadding ? 0 : top}, + a.util_screen_outer, + style, + ]} + {...props} + /> + ) +} +Screen = React.memo(Screen) +export {Screen} |