From cbe4149bf5069e581e21454e60bb112c11c0ab46 Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 27 Feb 2025 14:28:28 +0800 Subject: [PATCH] feat(mobile): improve navigation and UI components - Add NavigationHeaderBackButton component - Adjust SafeNavigationScrollView scroll and inset settings - Update TimelineSelectorProvider header actions - Change delete account text color to red - Modify EntryTitle padding Signed-off-by: Innei --- .../views/SafeNavigationScrollView.tsx | 30 ++++++++++++------- .../src/components/ui/button/UIBarButton.tsx | 1 + .../src/modules/entry-content/EntryTitle.tsx | 2 +- .../screen/TimelineSelectorProvider.tsx | 11 +++++-- .../src/modules/settings/routes/Account.tsx | 2 +- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx b/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx index 664221576..ee6406e47 100644 --- a/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx +++ b/apps/mobile/src/components/layouts/views/SafeNavigationScrollView.tsx @@ -73,6 +73,12 @@ export const SafeNavigationScrollView: FC = ({ onScroll={RNAnimated.event([{ nativeEvent: { contentOffset: { y: scrollY } } }], { useNativeDriver: true, })} + automaticallyAdjustContentInsets={false} + automaticallyAdjustsScrollIndicatorInsets={false} + scrollIndicatorInsets={{ + top: headerHeight, + bottom: tabBarHeight, + }} {...props} > @@ -98,8 +104,6 @@ export const NavigationBlurEffectHeader = ({ headerHideableBottom?: () => React.ReactNode headerTitleAbsolute?: boolean }) => { - const label = useColor("label") - const canBack = useNavigation().canGoBack() const navigationContext = useContext(NavigationContext)! @@ -115,15 +119,7 @@ export const NavigationBlurEffectHeader = ({ headerTransparent: true, headerShown: true, - headerLeft: - headerLeft ?? - (canBack - ? () => ( - router.back()}> - - - ) - : undefined), + headerLeft: headerLeft ?? (canBack ? () => : undefined), header: useTypeScriptHappyCallback( ({ options }) => ( @@ -151,3 +147,15 @@ export const NavigationBlurEffectHeader = ({ /> ) } + +export const NavigationHeaderBackButton = () => { + return +} +const NavigationHeaderBackButtonImpl = () => { + const label = useColor("label") + return ( + router.back()}> + + + ) +} diff --git a/apps/mobile/src/components/ui/button/UIBarButton.tsx b/apps/mobile/src/components/ui/button/UIBarButton.tsx index 5c31a4011..61fe08cc9 100644 --- a/apps/mobile/src/components/ui/button/UIBarButton.tsx +++ b/apps/mobile/src/components/ui/button/UIBarButton.tsx @@ -12,6 +12,7 @@ interface UIBarButtonProps extends PressableProps { overlay?: boolean } + export const UIBarButton = ({ normalIcon, selectedIcon, diff --git a/apps/mobile/src/modules/entry-content/EntryTitle.tsx b/apps/mobile/src/modules/entry-content/EntryTitle.tsx index f67479fce..5cb249b4a 100644 --- a/apps/mobile/src/modules/entry-content/EntryTitle.tsx +++ b/apps/mobile/src/modules/entry-content/EntryTitle.tsx @@ -106,7 +106,7 @@ export const EntryTitle = ({ title, entryId }: { title: string; entryId: string setTitleHeight(titleHeight) }} > - {title} + {title} ) diff --git a/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx b/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx index 7a79e09f5..5a9c51ff2 100644 --- a/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx +++ b/apps/mobile/src/modules/screen/TimelineSelectorProvider.tsx @@ -4,7 +4,10 @@ import { Share, useAnimatedValue, View } from "react-native" import { useColor } from "react-native-uikit-colors" import { NavigationContext } from "@/src/components/layouts/views/NavigationContext" -import { NavigationBlurEffectHeader } from "@/src/components/layouts/views/SafeNavigationScrollView" +import { + NavigationBlurEffectHeader, + NavigationHeaderBackButton, +} from "@/src/components/layouts/views/SafeNavigationScrollView" import { UIBarButton } from "@/src/components/ui/button/UIBarButton" import { TIMELINE_VIEW_SELECTOR_HEIGHT } from "@/src/constants/ui" import { Share3CuteReIcon } from "@/src/icons/share_3_cute_re" @@ -41,7 +44,11 @@ export function TimelineSelectorProvider({ children }: { children: React.ReactNo ) - : undefined, + : () => ( + + + + ), [isTimeline, isSubscriptions], )} headerRight={useMemo(() => { diff --git a/apps/mobile/src/modules/settings/routes/Account.tsx b/apps/mobile/src/modules/settings/routes/Account.tsx index 897c0191d..9f94d9a59 100644 --- a/apps/mobile/src/modules/settings/routes/Account.tsx +++ b/apps/mobile/src/modules/settings/routes/Account.tsx @@ -30,7 +30,7 @@ export const AccountScreen = () => { await expo.reloadAppAsync("User sign out") }} > - Delete account + Delete account