feat(mobile): translation for edit profile

This commit is contained in:
Stephen Zhou
2025-04-03 22:32:32 +08:00
parent 3a6a09e393
commit 927ae4ce9e
4 changed files with 40 additions and 14 deletions
@@ -1,5 +1,6 @@
import { cn, withOpacity } from "@follow/utils"
import { useCallback } from "react"
import { useTranslation } from "react-i18next"
import { Text, TouchableOpacity, View } from "react-native"
import { useSafeAreaInsets } from "react-native-safe-area-context"
@@ -73,10 +74,12 @@ export const HeaderSubmitTextButton = ({
isValid,
onPress,
isLoading,
label = "Submit",
label,
}: ModalHeaderSubmitButtonProps & {
label?: string
}) => {
const { t } = useTranslation("common")
const labelColor = useColor("label")
return (
<UINavigationHeaderActionButton onPress={onPress} disabled={!isValid || isLoading}>
@@ -92,7 +95,7 @@ export const HeaderSubmitTextButton = ({
isLoading && "opacity-0",
)}
>
{label}
{label ?? t("words.submit")}
</Text>
</UINavigationHeaderActionButton>
)
@@ -1,6 +1,7 @@
import { useMutation } from "@tanstack/react-query"
import type { FC } from "react"
import { useState } from "react"
import { useTranslation } from "react-i18next"
import { Text, TouchableOpacity, TouchableWithoutFeedback, View } from "react-native"
import { KeyboardController } from "react-native-keyboard-controller"
@@ -33,6 +34,7 @@ import { setAvatar } from "../utils"
export const EditProfileScreen = () => {
const whoami = useWhoami()
const { t } = useTranslation("settings")
if (!whoami) {
return (
@@ -44,7 +46,7 @@ export const EditProfileScreen = () => {
return (
<SafeNavigationScrollView className="bg-system-grouped-background">
<NavigationBlurEffectHeader title="Edit Profile" />
<NavigationBlurEffectHeader title={t("profile.edit_profile")} />
<AvatarSection whoami={whoami} />
<ProfileForm whoami={whoami} />
</SafeNavigationScrollView>
@@ -54,6 +56,7 @@ export const EditProfileScreen = () => {
const AvatarSection: FC<{
whoami: MeModel
}> = ({ whoami }) => {
const { t } = useTranslation("settings")
return (
<View className="mt-6 items-center justify-center">
<UserAvatar
@@ -64,7 +67,7 @@ const AvatarSection: FC<{
/>
<TouchableOpacity className="mt-2" hitSlop={10} onPress={setAvatar}>
<Text className="text-accent text-lg">Set Avatar</Text>
<Text className="text-accent text-lg">{t("profile.set_avatar")}</Text>
</TouchableOpacity>
</View>
)
@@ -73,6 +76,8 @@ const AvatarSection: FC<{
const ProfileForm: FC<{
whoami: MeModel
}> = ({ whoami }) => {
const { t } = useTranslation("settings")
const [dirtyFields, setDirtyFields] = useState<Partial<UserProfileEditable>>({})
const { mutateAsync: updateProfile, isPending } = useMutation({
@@ -93,14 +98,14 @@ const ProfileForm: FC<{
<NavigationBlurEffectHeader
headerRight={
<HeaderSubmitTextButton
label="Save"
label={t("words.save", { ns: "common" })}
isValid={isPending || Object.keys(dirtyFields).length === 0}
onPress={() => {
updateProfile()
}}
/>
}
title="Edit Profile"
title={t("profile.edit_profile")}
/>
<TouchableWithoutFeedback
@@ -111,7 +116,7 @@ const ProfileForm: FC<{
<View className="w-full">
<GroupedInsetListCard>
<GroupedInsetListCell
label="Display Name"
label={t("profile.name.label")}
leftClassName="flex-none"
rightClassName="flex-1"
>
@@ -128,11 +133,15 @@ const ProfileForm: FC<{
</View>
</GroupedInsetListCell>
</GroupedInsetListCard>
<GroupedOutlineDescription description="This is the name that will be displayed to other users." />
<GroupedOutlineDescription description={t("profile.name.description")} />
{/* User name */}
<GroupedInsetListCard className="mt-4">
<GroupedInsetListCell label="Handle" leftClassName="flex-none" rightClassName="flex-1">
<GroupedInsetListCell
label={t("profile.handle.label")}
leftClassName="flex-none"
rightClassName="flex-1"
>
<View className="flex-1">
<PlainTextField
className="text-secondary-label w-full flex-1 text-right"
@@ -146,12 +155,12 @@ const ProfileForm: FC<{
</View>
</GroupedInsetListCell>
</GroupedInsetListCard>
<GroupedOutlineDescription description="Your handle is used to identify you on Folo." />
<GroupedOutlineDescription description={t("profile.handle.description")} />
{/* Email */}
<GroupedInsetListCard className="mt-4">
<GroupedInsetListNavigationLink
label="Email"
label={t("profile.email.label")}
onPress={() => {
navigation.presentControllerView(EditEmailScreen)
}}
+12 -3
View File
@@ -1,5 +1,6 @@
import { useMutation } from "@tanstack/react-query"
import { useMemo, useState } from "react"
import { useTranslation } from "react-i18next"
import { View } from "react-native"
import { HeaderSubmitTextButton } from "@/src/components/layouts/header/HeaderElements"
@@ -21,6 +22,8 @@ import { useWhoami } from "@/src/store/user/hooks"
import { userSyncService } from "@/src/store/user/store"
export const EditEmailScreen: NavigationControllerView = () => {
const { t } = useTranslation("settings")
const whoami = useWhoami()
const [email, setEmail] = useState(whoami?.email ?? "")
@@ -48,7 +51,7 @@ export const EditEmailScreen: NavigationControllerView = () => {
return (
<SafeNavigationScrollView className="bg-system-grouped-background">
<NavigationBlurEffectHeader
title="Edit Email"
title={t("profile.edit_email")}
headerRight={
<HeaderSubmitTextButton
isLoading={isPending}
@@ -62,7 +65,11 @@ export const EditEmailScreen: NavigationControllerView = () => {
<View className="mt-4 w-full">
<GroupedInsetListCard>
<GroupedInsetListCell label="Email" rightClassName="flex-1" leftClassName="flex-none">
<GroupedInsetListCell
label={t("profile.email.label")}
rightClassName="flex-1"
leftClassName="flex-none"
>
<PlainTextField
autoCapitalize="none"
value={email}
@@ -76,7 +83,9 @@ export const EditEmailScreen: NavigationControllerView = () => {
</GroupedInsetListCell>
</GroupedInsetListCard>
<GroupedOutlineDescription
description={`Your email is ${isValidate ? "verified" : "not verified"}. \n\nIf you want to change your email, you should verify your new email.`}
description={`${t("profile.email.verify_status", {
status: isValidate ? t("profile.email.verified") : t("profile.email.unverified"),
})}\n\n${t("profile.email.change_note")}`}
/>
{/* Buttons */}
+5
View File
@@ -324,7 +324,10 @@
"profile.current_password.label": "Current Password",
"profile.danger_zone": "Danger Zone",
"profile.delete_account.label": "Delete Account",
"profile.edit_email": "Edit Email",
"profile.edit_profile": "Edit Profile",
"profile.email.change": "Change Email",
"profile.email.change_note": "If you want to change your email, you should verify your new email.",
"profile.email.changed": "Email changed.",
"profile.email.changed_verification_sent": "Email to verify the new email has been sent.",
"profile.email.label": "Email",
@@ -333,6 +336,7 @@
"profile.email.verification_sent": "Email verification sent",
"profile.email.verified": "Verified",
"profile.email.verify_email": "Please verify your email ({{email_address}}) to continue",
"profile.email.verify_status": "Your email is {{status}}",
"profile.handle.description": "Your unique identifier.",
"profile.handle.label": "Handle",
"profile.link_social.authentication": "Authentication",
@@ -345,6 +349,7 @@
"profile.password.label": "Password",
"profile.reset_password_mail_sent": "Reset password mail sent.",
"profile.security": "Security",
"profile.set_avatar": "Set Avatar",
"profile.sidebar_title": "Profile",
"profile.submit": "Submit",
"profile.title": "Profile Settings",