From 45b607d8fab4d045e8f35d181f002ba0649c7e67 Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 3 Nov 2025 22:42:31 +0800 Subject: [PATCH] fix(header): adjust header and banner styles for modal presentation Updated the header and user banner components to conditionally adjust styles based on modal presentation state. The header now accounts for modal visibility when setting padding, and the user banner adjusts its margin and padding accordingly to enhance layout consistency in modal views. Signed-off-by: Innei --- .../components/layouts/header/NavigationHeader.tsx | 7 ++++++- apps/mobile/src/components/layouts/utils/index.tsx | 2 +- .../src/modules/settings/UserHeaderBanner.tsx | 9 ++++++--- apps/mobile/src/screens/(modal)/ProfileScreen.tsx | 13 +++---------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/mobile/src/components/layouts/header/NavigationHeader.tsx b/apps/mobile/src/components/layouts/header/NavigationHeader.tsx index c2047cce7..9dac49556 100644 --- a/apps/mobile/src/components/layouts/header/NavigationHeader.tsx +++ b/apps/mobile/src/components/layouts/header/NavigationHeader.tsx @@ -33,6 +33,7 @@ import { useCanDismiss, useIsTopRouteInGroup, useNavigation, + useScreenIsInModal, useScreenIsInSheetModal, } from "@/src/lib/navigation/hooks" import { ScreenItemContext } from "@/src/lib/navigation/ScreenItemContext" @@ -228,15 +229,19 @@ export const InternalNavigationHeader = ({ defaultHeight, hideableBottomHeight, ) + + const isModal = useScreenIsInModal() + const rootTitleBarStyle = useAnimatedStyle(() => { const styles = { - paddingTop: insets.top, + paddingTop: isModal ? 0 : insets.top, position: "relative", overflow: "hidden", } satisfies DefaultStyle if (hideableBottom) { ;(styles as DefaultStyle).height = largeHeaderHeight.value } + return styles }) diff --git a/apps/mobile/src/components/layouts/utils/index.tsx b/apps/mobile/src/components/layouts/utils/index.tsx index 5a09d432d..1fd29439b 100644 --- a/apps/mobile/src/components/layouts/utils/index.tsx +++ b/apps/mobile/src/components/layouts/utils/index.tsx @@ -40,5 +40,5 @@ export function getDefaultHeaderHeight({ headerHeight = 64 } - return headerHeight + statusBarHeight + return headerHeight + (modalPresentation ? 0 : statusBarHeight) } diff --git a/apps/mobile/src/modules/settings/UserHeaderBanner.tsx b/apps/mobile/src/modules/settings/UserHeaderBanner.tsx index 476f84b4a..d432e82b1 100644 --- a/apps/mobile/src/modules/settings/UserHeaderBanner.tsx +++ b/apps/mobile/src/modules/settings/UserHeaderBanner.tsx @@ -23,7 +23,7 @@ import { PowerIcon } from "@/src/icons/power" import { TwitterCuteFiIcon } from "@/src/icons/twitter_cute_fi" import { WebCuteReIcon } from "@/src/icons/web_cute_re" import { YoutubeCuteFiIcon } from "@/src/icons/youtube_cute_fi" -import { useNavigation } from "@/src/lib/navigation/hooks" +import { useNavigation, useScreenIsInSheetModal } from "@/src/lib/navigation/hooks" import { LoginScreen } from "@/src/screens/(modal)/LoginScreen" import { usePrefetchImageColors } from "@/src/store/image/hooks" import { accentColor } from "@/src/theme/colors" @@ -171,11 +171,14 @@ export const UserHeaderBanner = ({ } }) const navigation = useNavigation() + + const sheetModal = useScreenIsInSheetModal() return ( diff --git a/apps/mobile/src/screens/(modal)/ProfileScreen.tsx b/apps/mobile/src/screens/(modal)/ProfileScreen.tsx index d8726a483..9d2afb827 100644 --- a/apps/mobile/src/screens/(modal)/ProfileScreen.tsx +++ b/apps/mobile/src/screens/(modal)/ProfileScreen.tsx @@ -13,7 +13,7 @@ import Animated, { useAnimatedStyle, useSharedValue, } from "react-native-reanimated" -import { useSafeAreaFrame, useSafeAreaInsets } from "react-native-safe-area-context" +import { useSafeAreaInsets } from "react-native-safe-area-context" import { ReAnimatedScrollView } from "@/src/components/common/AnimatedComponents" import { BlurEffect } from "@/src/components/common/BlurEffect" @@ -22,7 +22,6 @@ import { InternalNavigationHeader, UINavigationHeaderActionButton, } from "@/src/components/layouts/header/NavigationHeader" -import { getDefaultHeaderHeight } from "@/src/components/layouts/utils" import { GROUPED_ICON_TEXT_GAP, GROUPED_LIST_ITEM_PADDING, @@ -101,12 +100,7 @@ function ProfileScreenImpl(props: { userId: string }) { title: `Folo | ${user.name}'s Profile`, }) }, [user?.id, user?.name]) - const frame = useSafeAreaFrame() - const headerHeight = getDefaultHeaderHeight({ - landscape: frame.width > frame.height, - modalPresentation: false, - topInset: 0, - }) + const whoami = useWhoami() const isMyProfile = user?.id === whoami?.id const actionCtx = useMemo( @@ -115,6 +109,7 @@ function ProfileScreenImpl(props: { userId: string }) { }), [removeItemById], ) + return (