From 55a7b2ec6788a541ce64697362984be1d5d3fec1 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 2 Dec 2024 14:05:53 -0600 Subject: [PATCH] Clean up new header --- src/components/Layout/Header/index.tsx | 127 ++++++++++++++++++ .../{Layout.tsx => Layout/index.tsx} | 103 +------------- src/screens/Settings/AccountSettings.tsx | 8 +- 3 files changed, 135 insertions(+), 103 deletions(-) create mode 100644 src/components/Layout/Header/index.tsx rename src/components/{Layout.tsx => Layout/index.tsx} (69%) diff --git a/src/components/Layout/Header/index.tsx b/src/components/Layout/Header/index.tsx new file mode 100644 index 0000000000..171f81df75 --- /dev/null +++ b/src/components/Layout/Header/index.tsx @@ -0,0 +1,127 @@ +import React from 'react' +import {View} from 'react-native' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' +import {useNavigation} from '@react-navigation/native' + +import {NavigationProp} from '#/lib/routes/types' +import {isIOS} from '#/platform/detection' +import {useSetDrawerOpen} from '#/state/shell' +import {atoms as a, useBreakpoints, useGutterStyles, useTheme} from '#/alf' +import {Button, ButtonIcon} from '#/components/Button' +import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeft} from '#/components/icons/Arrow' +import {Menu_Stroke2_Corner0_Rounded as Menu} from '#/components/icons/Menu' +import {Text} from '#/components/Typography' + +const BUTTON_VISUAL_ALIGNMENT_OFFSET = 3 + +export function Outer({children}: {children: React.ReactNode}) { + const t = useTheme() + const gutter = useGutterStyles() + + return ( + + {children} + + ) +} + +export function Content({children}: {children: React.ReactNode}) { + return ( + + {children} + + ) +} + +export function Slot({children}: {children: React.ReactNode}) { + return {children} +} + +export function BackButton() { + const {_} = useLingui() + const navigation = useNavigation() + + const onPressBack = React.useCallback(() => { + if (navigation.canGoBack()) { + navigation.goBack() + } else { + navigation.navigate('Home') + } + }, [navigation]) + + return ( + + + + ) +} + +export function MenuButton() { + const {_} = useLingui() + const setDrawerOpen = useSetDrawerOpen() + const {gtMobile} = useBreakpoints() + + const onPress = React.useCallback(() => { + setDrawerOpen(true) + }, [setDrawerOpen]) + + return gtMobile ? null : ( + + + + ) +} + +export function TitleText({children}: {children: React.ReactNode}) { + const {gtMobile} = useBreakpoints() + return ( + + {children} + + ) +} + +export function SubtitleText({children}: {children: React.ReactNode}) { + const t = useTheme() + return ( + + {children} + + ) +} diff --git a/src/components/Layout.tsx b/src/components/Layout/index.tsx similarity index 69% rename from src/components/Layout.tsx rename to src/components/Layout/index.tsx index 8d5ed56af2..136535f7c7 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout/index.tsx @@ -7,18 +7,13 @@ import { } from 'react-native-keyboard-controller' import Animated, {AnimatedScrollViewProps} from 'react-native-reanimated' import {useSafeAreaInsets} from 'react-native-safe-area-context' -import {msg} from '@lingui/macro' -import {useLingui} from '@lingui/react' -import {useNavigation} from '@react-navigation/native' -import {NavigationProp} from '#/lib/routes/types' import {isWeb} from '#/platform/detection' import {ViewHeader} from '#/view/com/util/ViewHeader' import {CenteredView} from '#/view/com/util/Views' -import {atoms as a, useBreakpoints, useGutterStyles,useTheme} from '#/alf' -import {Button, ButtonIcon} from '#/components/Button' -import {ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeft} from '#/components/icons/Chevron' -import {Text} from '#/components/Typography' +import {atoms as a, useBreakpoints, useTheme} from '#/alf' + +export * as HeaderNew from './Header' // Every screen should have a Layout component wrapping it. // This component provides a default padding for the top of the screen. @@ -197,98 +192,6 @@ export const Center = React.forwardRef(function LayoutContent( ) }) -export function HeaderNew({children}: {children: React.ReactNode}) { - const t = useTheme() - const gutter = useGutterStyles({top: true, bottom: true}) - - return ( - - - {children} - - - ) -} - -HeaderNew.BackButton = function HeaderBackButton() { - const {_} = useLingui() - const navigation = useNavigation() - - const onPressBack = React.useCallback(() => { - if (navigation.canGoBack()) { - navigation.goBack() - } else { - navigation.navigate('Home') - } - }, [navigation]) - - return ( - - ) -} - -HeaderNew.Content = function HeaderContent({ - children, - right, -}: { - children: React.ReactNode - right?: React.ReactNode -}) { - return ( - - {children} - {right && {right}} - - ) -} - -HeaderNew.TitleText = function HeaderTitleText({ - children, -}: { - children: React.ReactNode -}) { - const {gtMobile} = useBreakpoints() - return ( - - {children} - - ) -} - -HeaderNew.SubtitleText = function HeaderSubtitleText({ - children, -}: { - children: React.ReactNode -}) { - const t = useTheme() - return ( - - {children} - - ) -} - const styles = StyleSheet.create({ scrollViewCommonStyles: { width: '100%', diff --git a/src/screens/Settings/AccountSettings.tsx b/src/screens/Settings/AccountSettings.tsx index 0c2d488b39..b3ae139c2b 100644 --- a/src/screens/Settings/AccountSettings.tsx +++ b/src/screens/Settings/AccountSettings.tsx @@ -39,12 +39,14 @@ export function AccountSettingsScreen({}: Props) { return ( - + - Account + + Account + - +