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 <tukon479@gmail.com>
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
|
||||
@@ -40,5 +40,5 @@ export function getDefaultHeaderHeight({
|
||||
headerHeight = 64
|
||||
}
|
||||
|
||||
return headerHeight + statusBarHeight
|
||||
return headerHeight + (modalPresentation ? 0 : statusBarHeight)
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<View
|
||||
className="relative items-center justify-center pt-[22px]"
|
||||
className="relative items-center justify-center"
|
||||
style={{
|
||||
marginTop: -insets.top - 22,
|
||||
marginTop: sheetModal ? 0 : -insets.top - 22,
|
||||
paddingTop: sheetModal ? 48 : 22,
|
||||
}}
|
||||
>
|
||||
<ReAnimated.View entering={FadeIn} className="absolute inset-0" style={styles}>
|
||||
|
||||
@@ -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 (
|
||||
<View className="flex-1 bg-system-grouped-background">
|
||||
<Animated.View
|
||||
@@ -142,8 +137,6 @@ function ProfileScreenImpl(props: { userId: string }) {
|
||||
onScroll={scrollHandler}
|
||||
contentContainerStyle={{
|
||||
paddingBottom: insets.bottom + 24,
|
||||
paddingTop: headerHeight + 22,
|
||||
marginTop: -22,
|
||||
}}
|
||||
>
|
||||
<UserHeaderBanner scrollY={scrollY} userId={props.userId} />
|
||||
|
||||
Reference in New Issue
Block a user