@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
tsx 142 lines 5.88 KB
Raw
1 import { useGT, useMessages } from "gt-react-native";
2 import { useAtomValue } from "@effect/atom-react";
3 import { AsyncResult } from "effect/reactivity";
4 import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
5 import { Platform, View } from "react-native";
6 import { useSafeAreaInsets } from "react-native-safe-area-context";
7 import {
8 moveNavigationTab,
9 navigationCustomizationAvailable,
10 toggleNavigationTabVisibility,
11 } from "../layout/workspace/navigation-tab-order";
12 import { AppText as Text } from "../../components/ui/AppText";
13 import { IconButton } from "../../components/ui/IconButton";
14 import { Button } from "../../components/ui/Button";
15 import { ScreenScrollView } from "../../components/ui/ScreenScrollView";
16 import { SymbolView } from "../../components/ui/AppSymbol";
17 import { mobilePreferencesAtom, saveMobilePreferences } from "../../state/preferences";
18 import { useAtomCommand } from "../../state/use-atom-command";
19 import {
20 NAVIGATION_TAB_ICONS,
21 WORKSPACE_TAB_LABELS,
22 useNavigationTabOrder,
23 useHiddenNavigationTabs,
24 useEnabledNavigationTabs,
25 } from "../layout/workspace/navigation-tabs";
26 import { SettingsScreen } from "./components/SettingsScreen";
27 import { SettingsSection } from "./components/SettingsSection";
28 import { resolveWorkspaceTabOrder } from "../layout/workspace/workspace-tabs-state";
29
30 export function SettingsNavigationRouteScreen() {
31 const gt = useGT();
32 const m = useMessages();
33 const insets = useSafeAreaInsets();
34 const order = useNavigationTabOrder();
35 const { layout } = useAdaptiveWorkspaceLayout();
36 const capacity = Platform.OS === "android" && layout.usesSplitView ? 5 : 4;
37 const hidden = useHiddenNavigationTabs();
38 const enabled = useEnabledNavigationTabs();
39 const preferences = useAtomValue(mobilePreferencesAtom);
40 const customizable = navigationCustomizationAvailable();
41 const ready = customizable && AsyncResult.isSuccess(preferences) && !preferences.waiting;
42 const save = useAtomCommand(saveMobilePreferences);
43 return (
44 <SettingsScreen title={gt("Navigation tabs")}>
45 <ScreenScrollView
46 contentInsetAdjustmentBehavior="automatic"
47 contentContainerClassName="gap-4 px-5 pt-4"
48 contentContainerStyle={{ paddingBottom: insets.bottom + 24 }}
49 >
50 <Text className="px-2 text-sm text-foreground-muted">
51 {customizable
52 ? gt(
53 "Phones show the first four enabled sections; Android tablet rails show all enabled sections. Remaining sections appear at the top of Settings. Hidden sections appear only here. Settings always stays last. Saved on this device.",
54 )
55 : gt(
56 "Tab customization becomes available when there are six sections, including Settings.",
57 )}
58 </Text>
59 <SettingsSection title={gt("Tab order")}>
60 {order.map((tab, index) => (
61 <View key={tab} className="flex-row items-center gap-3 px-4 py-3">
62 <SymbolView
63 name={NAVIGATION_TAB_ICONS[tab]}
64 size={22}
65 tintColorClassName="accent-icon"
66 />
67 <View className="flex-1">
68 <Text>{m(WORKSPACE_TAB_LABELS[tab])}</Text>
69 <Text className="text-xs text-foreground-muted">
70 {hidden.includes(tab)
71 ? gt("Hidden", { $context: "navigation tab visibility status" })
72 : enabled.indexOf(tab) < capacity
73 ? gt("Tab {position}", { position: enabled.indexOf(tab) + 1 })
74 : gt("In Settings")}
75 </Text>
76 </View>
77 <IconButton
78 icon={hidden.includes(tab) ? "eye.slash" : "eye"}
79 accessibilityLabel={
80 hidden.includes(tab)
81 ? gt("Show {tab}", { tab: m(WORKSPACE_TAB_LABELS[tab]) })
82 : gt("Hide {tab}", { tab: m(WORKSPACE_TAB_LABELS[tab]) })
83 }
84 disabled={!ready}
85 onPress={() => {
86 void save({
87 transform: (current) => ({
88 hiddenNavigationTabs: toggleNavigationTabVisibility(
89 current.hiddenNavigationTabs,
90 tab,
91 ),
92 }),
93 });
94 }}
95 />
96 <IconButton
97 icon="arrow.up"
98 accessibilityLabel={gt("Move {tab} up", { tab: m(WORKSPACE_TAB_LABELS[tab]) })}
99 disabled={!ready || index === 0}
100 onPress={() => {
101 void save({
102 transform: (current) => ({
103 navigationTabOrder: moveNavigationTab(
104 resolveWorkspaceTabOrder(current.navigationTabOrder),
105 tab,
106 index - 1,
107 ),
108 }),
109 });
110 }}
111 />
112 <IconButton
113 icon="arrow.down"
114 accessibilityLabel={gt("Move {tab} down", { tab: m(WORKSPACE_TAB_LABELS[tab]) })}
115 disabled={!ready || index === order.length - 1}
116 onPress={() => {
117 void save({
118 transform: (current) => ({
119 navigationTabOrder: moveNavigationTab(
120 resolveWorkspaceTabOrder(current.navigationTabOrder),
121 tab,
122 index + 1,
123 ),
124 }),
125 });
126 }}
127 />
128 </View>
129 ))}
130 </SettingsSection>
131 <Button
132 label={gt("Reset tabs")}
133 tone="text"
134 disabled={!ready}
135 onPress={() => {
136 void save({ navigationTabOrder: [], hiddenNavigationTabs: [] });
137 }}
138 />
139 </ScreenScrollView>
140 </SettingsScreen>
141 );
142 }