refactor(mobile): clearer language select

This commit is contained in:
Stephen Zhou
2025-04-02 10:14:37 +08:00
parent 584b2b500d
commit 9e4b7a50cf
3 changed files with 10 additions and 4 deletions
@@ -10,7 +10,7 @@ import { accentColor } from "@/src/theme/colors"
import { FormLabel } from "./Label"
interface SelectProps<T> {
options: { label: string; value: T }[]
options: { label: string; value: T; subLabel?: string }[]
value: T
onValueChange: (value: T) => void
@@ -86,6 +86,9 @@ export function Select<T>({
onSelect={handleSelect}
>
<DropdownMenu.ItemTitle>{option.label}</DropdownMenu.ItemTitle>
{!!option.subLabel && (
<DropdownMenu.ItemSubtitle>{option.subLabel}</DropdownMenu.ItemSubtitle>
)}
</DropdownMenu.CheckboxItem>
)
})}
@@ -1,3 +1,4 @@
import type { SupportedLanguage } from "@follow/shared"
import { LANGUAGE_MAP } from "@follow/shared"
import i18next from "i18next"
import { useMemo } from "react"
@@ -24,8 +25,9 @@ import type { NavigationControllerView } from "@/src/lib/navigation/types"
function LanguageSelect({ settingKey }: { settingKey: "language" | "actionLanguage" }) {
const { t } = useTranslation("lang")
const languageMapWithTranslation = useMemo(() => {
const data = Object.entries(LANGUAGE_MAP).map(([key, { label }]) => ({
label: `${t(`langs.${key}` as any)} (${label})`,
const data = (Object.keys(LANGUAGE_MAP) as SupportedLanguage[]).map((key) => ({
subLabel: t(`langs.${key}`, { lng: key }),
label: t(`langs.${key}`),
value: key,
}))
+2 -1
View File
@@ -2,8 +2,9 @@ import type { z } from "zod"
import type { languageSchema } from "./hono"
export type SupportedLanguage = z.infer<typeof languageSchema>
export const LANGUAGE_MAP: Record<
z.infer<typeof languageSchema>,
SupportedLanguage,
{
label: string
value: string