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 { msg, useGT, useMessages } from "gt-react-native"; |
| 2 | import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView"; |
| 3 | import { useAtomValue } from "@effect/atom-react"; |
| 4 | import type { SidebarProjectGroupingMode } from "@t3tools/contracts"; |
| 5 | import { AsyncResult } from "effect/reactivity"; |
| 6 | import { useSafeAreaInsets } from "react-native-safe-area-context"; |
| 7 | |
| 8 | import { SettingsScreen } from "./components/SettingsScreen"; |
| 9 | import { |
| 10 | mobileProjectGroupingModePatch, |
| 11 | resolveMobileProjectGroupingSettings, |
| 12 | } from "../../state/project-grouping"; |
| 13 | import { mobilePreferencesAtom, saveMobilePreferences } from "../../state/preferences"; |
| 14 | import { useAtomCommand } from "../../state/use-atom-command"; |
| 15 | import { ListChoiceRow as SettingsChoiceRow } from "../../components/ui/ListChoiceRow"; |
| 16 | import { SettingsSection } from "./components/SettingsSection"; |
| 17 | import { LanguageSettingsSection } from "./SettingsLanguageRouteScreen"; |
| 18 | import { NewThreadSettingsSection, WorkingSectionSettings } from "./ThreadSettingsSections"; |
| 19 | |
| 20 | const GROUPING_OPTIONS: ReadonlyArray<{ |
| 21 | readonly mode: SidebarProjectGroupingMode; |
| 22 | readonly label: string; |
| 23 | readonly description: string; |
| 24 | }> = [ |
| 25 | { |
| 26 | mode: "repository", |
| 27 | label: msg("Group by repository"), |
| 28 | description: msg("Matching repositories appear as one project."), |
| 29 | }, |
| 30 | { |
| 31 | mode: "repository_path", |
| 32 | label: msg("Group by repository path"), |
| 33 | description: msg("Keep monorepo paths separate."), |
| 34 | }, |
| 35 | { |
| 36 | mode: "separate", |
| 37 | label: msg("Keep separate"), |
| 38 | description: msg("Show every workspace as its own project."), |
| 39 | }, |
| 40 | ]; |
| 41 | |
| 42 | export function SettingsProjectGroupingRouteScreen() { |
| 43 | const gt = useGT(); |
| 44 | const m = useMessages(); |
| 45 | const insets = useSafeAreaInsets(); |
| 46 | const preferencesResult = useAtomValue(mobilePreferencesAtom); |
| 47 | const savePreferences = useAtomCommand(saveMobilePreferences); |
| 48 | const preferencesReady = AsyncResult.isSuccess(preferencesResult) && !preferencesResult.waiting; |
| 49 | const selectedMode = AsyncResult.isSuccess(preferencesResult) |
| 50 | ? resolveMobileProjectGroupingSettings(preferencesResult.value).sidebarProjectGroupingMode |
| 51 | : null; |
| 52 | |
| 53 | return ( |
| 54 | <SettingsScreen title={gt("General")}> |
| 55 | <ScrollView |
| 56 | contentInsetAdjustmentBehavior="automatic" |
| 57 | showsVerticalScrollIndicator={false} |
| 58 | className="flex-1" |
| 59 | contentContainerClassName="gap-3 px-5 pt-4" |
| 60 | contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }} |
| 61 | > |
| 62 | <LanguageSettingsSection /> |
| 63 | <SettingsSection title={gt("Project grouping")}> |
| 64 | {GROUPING_OPTIONS.map((option, index) => ( |
| 65 | <SettingsChoiceRow |
| 66 | key={option.mode} |
| 67 | label={m(option.label)} |
| 68 | description={m(option.description)} |
| 69 | selected={selectedMode === option.mode} |
| 70 | separated={index > 0} |
| 71 | disabled={!preferencesReady} |
| 72 | onPress={() => { |
| 73 | void savePreferences(mobileProjectGroupingModePatch(option.mode)); |
| 74 | }} |
| 75 | /> |
| 76 | ))} |
| 77 | </SettingsSection> |
| 78 | <WorkingSectionSettings /> |
| 79 | <NewThreadSettingsSection /> |
| 80 | </ScrollView> |
| 81 | </SettingsScreen> |
| 82 | ); |
| 83 | } |