The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView"; |
| 2 | import { useAtomValue } from "@effect/atom-react"; |
| 3 | import { AsyncResult } from "effect/reactivity"; |
| 4 | import { useSafeAreaInsets } from "react-native-safe-area-context"; |
| 5 | |
| 6 | import { useGT } from "gt-react-native"; |
| 7 | import { useLanguagePreference } from "../../i18n/I18nProvider"; |
| 8 | import { SYSTEM_LANGUAGE, nativeLanguageName } from "@t3tools/client-runtime/locales"; |
| 9 | import { SUPPORTED_LOCALES } from "../../i18n/locales"; |
| 10 | import { mobilePreferencesAtom, saveMobilePreferences } from "../../state/preferences"; |
| 11 | import { useAtomCommand } from "../../state/use-atom-command"; |
| 12 | import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow"; |
| 13 | import { SettingsRow } from "./components/SettingsRow"; |
| 14 | import { SettingsSection } from "./components/SettingsSection"; |
| 15 | import { SettingsScreen } from "./components/SettingsScreen"; |
| 16 | |
| 17 | /** General's row that opens the language picker, showing the current choice. */ |
| 18 | export function LanguageSettingsSection() { |
| 19 | const gt = useGT(); |
| 20 | const language = useLanguagePreference(); |
| 21 | return ( |
| 22 | <SettingsSection> |
| 23 | <SettingsRow |
| 24 | icon="globe" |
| 25 | label={gt("Language")} |
| 26 | value={ |
| 27 | SUPPORTED_LOCALES.includes(language) ? nativeLanguageName(language) : gt("System default") |
| 28 | } |
| 29 | target="SettingsLanguage" |
| 30 | /> |
| 31 | </SettingsSection> |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | export function SettingsLanguageRouteScreen() { |
| 36 | const gt = useGT(); |
| 37 | const insets = useSafeAreaInsets(); |
| 38 | const preferencesResult = useAtomValue(mobilePreferencesAtom); |
| 39 | const savePreferences = useAtomCommand(saveMobilePreferences); |
| 40 | const preferencesReady = AsyncResult.isSuccess(preferencesResult) && !preferencesResult.waiting; |
| 41 | const language = useLanguagePreference(); |
| 42 | const options = [ |
| 43 | { language: SYSTEM_LANGUAGE, label: gt("System default") }, |
| 44 | ...SUPPORTED_LOCALES.map((locale) => ({ language: locale, label: nativeLanguageName(locale) })), |
| 45 | ]; |
| 46 | |
| 47 | return ( |
| 48 | <SettingsScreen title={gt("Language")}> |
| 49 | <ScrollView |
| 50 | contentInsetAdjustmentBehavior="automatic" |
| 51 | showsVerticalScrollIndicator={false} |
| 52 | className="flex-1" |
| 53 | contentContainerClassName="gap-3 px-5 pt-4" |
| 54 | contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }} |
| 55 | > |
| 56 | <SettingsSection> |
| 57 | {options.map((option, index) => ( |
| 58 | <SettingsChoiceRow |
| 59 | key={option.language} |
| 60 | label={option.label} |
| 61 | selected={preferencesReady && language === option.language} |
| 62 | separated={index > 0} |
| 63 | disabled={!preferencesReady} |
| 64 | onPress={() => { |
| 65 | void savePreferences({ language: option.language }); |
| 66 | }} |
| 67 | /> |
| 68 | ))} |
| 69 | </SettingsSection> |
| 70 | </ScrollView> |
| 71 | </SettingsScreen> |
| 72 | ); |
| 73 | } |