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