fix(mobile): attach to safe navigation scroll header

- Replaced instances of NavigationBlurEffectHeader with NavigationBlurEffectHeaderView across multiple screens for consistency in header design.
- Introduced useViewDidAppear hook to manage view appearance events using Jotai for state management.
- Updated About screen to dynamically include commitSha with app version and build ID.

These changes improve the visual consistency of navigation headers and enhance the functionality of screen hooks.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-04-08 21:27:16 +08:00
parent 63b39a08c9
commit 6054ec9795
10 changed files with 76 additions and 58 deletions
@@ -136,7 +136,6 @@ export const WrappedScreenItem: FC<
...defaultHeaderConfig,
...headerConfig,
}}
nativeID=""
key={screenId}
screenId={screenId}
ref={ref}
+16 -1
View File
@@ -1,5 +1,7 @@
import { useContext } from "react"
import { useAtomValue } from "jotai"
import { useContext, useEffect } from "react"
import type { StackPresentationTypes } from "react-native-screens"
import { useEventCallback } from "usehooks-ts"
import { GroupedNavigationRouteContext } from "./GroupedNavigationRouteContext"
import { NavigationInstanceContext } from "./NavigationInstanceContext"
@@ -84,3 +86,16 @@ export const useIsTopRouteInGroup = () => {
return routeGroup.at(0)?.screenOptions?.id === screenId
}
export const useViewDidAppear = (fn: () => void) => {
const { isAppearedAtom } = useContext(ScreenItemContext)
const isAppeared = useAtomValue(isAppearedAtom)
const fnEvent = useEventCallback(fn)
useEffect(() => {
if (isAppeared) {
fnEvent()
}
}, [fnEvent, isAppeared])
}
+2 -2
View File
@@ -8,7 +8,7 @@ import { z } from "zod"
import { HeaderSubmitTextButton } from "@/src/components/layouts/header/HeaderElements"
import {
NavigationBlurEffectHeader,
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
import { FormProvider } from "@/src/components/ui/form/FormProvider"
@@ -129,7 +129,7 @@ function FollowImpl(props: { feedId: string }) {
contentViewClassName="gap-y-4 mt-2"
contentContainerStyle={{ paddingBottom: insets.bottom }}
Header={
<NavigationBlurEffectHeader
<NavigationBlurEffectHeaderView
title={`${isSubscribed ? "Edit" : "Follow"} - ${feed?.title}`}
headerRight={
<HeaderSubmitTextButton
+14 -13
View File
@@ -8,7 +8,7 @@ import { z } from "zod"
import { HeaderSubmitTextButton } from "@/src/components/layouts/header/HeaderElements"
import {
NavigationBlurEffectHeader,
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
import { FormProvider } from "@/src/components/ui/form/FormProvider"
@@ -129,19 +129,20 @@ const Impl = (props: { id: string }) => {
<SafeNavigationScrollView
className="bg-system-grouped-background"
contentViewClassName="gap-y-4 mt-2"
Header={
<NavigationBlurEffectHeaderView
title={`${isSubscribed ? "Edit" : "Follow"} - ${list?.title}`}
headerRight={
<HeaderSubmitTextButton
isValid={isValid}
onPress={form.handleSubmit(submit)}
isLoading={isLoading}
label={isSubscribed ? "Save" : "Follow"}
/>
}
/>
}
>
<NavigationBlurEffectHeader
title={`${isSubscribed ? "Edit" : "Follow"} - ${list?.title}`}
headerRight={
<HeaderSubmitTextButton
isValid={isValid}
onPress={form.handleSubmit(submit)}
isLoading={isLoading}
label={isSubscribed ? "Save" : "Follow"}
/>
}
/>
<GroupedInsetListCard className="px-5 py-4">
<View className="flex flex-row gap-4">
<View className="size-[50px] overflow-hidden rounded-lg">
@@ -72,8 +72,7 @@ export const AboutScreen = () => {
)}
values={{
appName: "Folo",
// TODO: add commitSha
commitSha: "",
commitSha: `${appVersion}-${buildId}`,
}}
components={{
OpenIssueLink: (
@@ -7,7 +7,6 @@ import { KeyboardController } from "react-native-keyboard-controller"
import { HeaderSubmitTextButton } from "@/src/components/layouts/header/HeaderElements"
import {
NavigationBlurEffectHeader,
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
@@ -76,7 +75,6 @@ export const EditProfileScreen = () => {
}
className="bg-system-grouped-background"
>
<NavigationBlurEffectHeader title={t("profile.edit_profile")} />
<AvatarSection whoami={whoami} />
<ProfileForm whoami={whoami} dirtyFields={dirtyFields} setDirtyFields={setDirtyFields} />
</SafeNavigationScrollView>
+2 -3
View File
@@ -1,5 +1,5 @@
import {
NavigationBlurEffectHeader,
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
import { Markdown } from "@/src/components/ui/typography/Markdown"
@@ -97,9 +97,8 @@ export const TermsScreen: NavigationControllerView = () => {
<SafeNavigationScrollView
className="bg-system-background"
contentInsetAdjustmentBehavior="never"
Header={<NavigationBlurEffectHeaderView title="Terms of Service" />}
>
<NavigationBlurEffectHeader title="Terms of Service" />
<TermsMarkdown />
</SafeNavigationScrollView>
)
+18 -15
View File
@@ -5,7 +5,7 @@ import { View } from "react-native"
import { HeaderSubmitTextButton } from "@/src/components/layouts/header/HeaderElements"
import {
NavigationBlurEffectHeader,
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
import { PlainTextField } from "@/src/components/ui/form/TextField"
@@ -49,20 +49,23 @@ export const EditEmailScreen: NavigationControllerView = () => {
const [isSendingVerificationEmail, setIsSendingVerificationEmail] = useState(false)
return (
<SafeNavigationScrollView className="bg-system-grouped-background">
<NavigationBlurEffectHeader
title={t("profile.edit_email")}
headerRight={
<HeaderSubmitTextButton
isLoading={isPending}
isValid={!!(email && newEmailIsValid && isDirty)}
onPress={() => {
updateEmail()
}}
/>
}
/>
<SafeNavigationScrollView
Header={
<NavigationBlurEffectHeaderView
title={t("profile.edit_email")}
headerRight={
<HeaderSubmitTextButton
isLoading={isPending}
isValid={!!(email && newEmailIsValid && isDirty)}
onPress={() => {
updateEmail()
}}
/>
}
/>
}
className="bg-system-grouped-background"
>
<View className="mt-4 w-full">
<GroupedInsetListCard>
<GroupedInsetListCell
+18 -15
View File
@@ -4,7 +4,7 @@ import { View } from "react-native"
import { HeaderSubmitButton } from "@/src/components/layouts/header/HeaderElements"
import {
NavigationBlurEffectHeader,
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
import { PlainTextField } from "@/src/components/ui/form/TextField"
@@ -36,20 +36,23 @@ export const InvitationScreen: NavigationControllerView = () => {
})
return (
<SafeNavigationScrollView className="bg-system-grouped-background">
<NavigationBlurEffectHeader
title="Enter Invitation Code"
headerRight={
<HeaderSubmitButton
isLoading={isPending}
isValid={!!code}
onPress={() => {
applyInvitationCode()
}}
/>
}
/>
<SafeNavigationScrollView
Header={
<NavigationBlurEffectHeaderView
title="Enter Invitation Code"
headerRight={
<HeaderSubmitButton
isLoading={isPending}
isValid={!!code}
onPress={() => {
applyInvitationCode()
}}
/>
}
/>
}
className="bg-system-grouped-background"
>
<View className="mt-8 w-full">
<GroupedInsetListCard>
<GroupedInsetListCell
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"
import { Pressable, Text, View } from "react-native"
import {
NavigationBlurEffectHeader,
NavigationBlurEffectHeaderView,
SafeNavigationScrollView,
} from "@/src/components/layouts/views/SafeNavigationScrollView"
import { GroupedInsetListNavigationLinkIcon } from "@/src/components/ui/grouped/GroupedList"
@@ -19,9 +19,10 @@ export const SelectReadingModeScreen: NavigationControllerView = () => {
const { behavior, updateSettings } = useReadingBehavior()
return (
<SafeNavigationScrollView className="bg-system-grouped-background">
<NavigationBlurEffectHeader title={t("onboarding.reading_preferences")} />
<SafeNavigationScrollView
className="bg-system-grouped-background"
Header={<NavigationBlurEffectHeaderView title={t("onboarding.reading_preferences")} />}
>
<View className="mt-8 flex w-full gap-4">
<Card
icon={