The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { T, useGT } from "gt-react-native"; |
| 2 | import { NavigationRouteContext } from "@react-navigation/native"; |
| 3 | import { Activity, useState, type ReactNode } from "react"; |
| 4 | import { View } from "react-native"; |
| 5 | |
| 6 | import { AppText } from "../../components/ui/AppText"; |
| 7 | import { PaneContext } from "../../components/ui/Pane"; |
| 8 | import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context"; |
| 9 | import { useAndroidWorkspaceRoot } from "../layout/workspace/AndroidWorkspaceTabsProvider"; |
| 10 | import { SettingsListScreen } from "./SettingsRouteScreen"; |
| 11 | import { SettingsScreen } from "./components/SettingsScreen"; |
| 12 | |
| 13 | const SETTINGS_LIST_ROUTE = { key: "settings-sidebar", name: "Settings" }; |
| 14 | |
| 15 | export function SettingsWorkspaceLayout(props: { readonly children: ReactNode }) { |
| 16 | const gt = useGT(); |
| 17 | const root = useAndroidWorkspaceRoot(); |
| 18 | const { layout } = useAdaptiveWorkspaceLayout(); |
| 19 | const split = root?.settingsOpen === true && layout.usesSplitView; |
| 20 | const [visited, setVisited] = useState(split); |
| 21 | if (split && !visited) setVisited(true); |
| 22 | const emptyDetail = split && root.settingsPage === null; |
| 23 | const route = root?.settingsRoute ?? SETTINGS_LIST_ROUTE; |
| 24 | |
| 25 | return ( |
| 26 | <View className="flex-1 flex-row"> |
| 27 | {visited ? ( |
| 28 | <Activity mode={split ? "visible" : "hidden"}> |
| 29 | <View style={{ width: layout.listPaneWidth ?? 0, marginRight: layout.listPaneGap ?? 0 }}> |
| 30 | <PaneContext value="sidebar"> |
| 31 | <NavigationRouteContext value={route}> |
| 32 | <SettingsListScreen sidebar selected={root?.settingsPage ?? null} /> |
| 33 | </NavigationRouteContext> |
| 34 | </PaneContext> |
| 35 | </View> |
| 36 | </Activity> |
| 37 | ) : null} |
| 38 | {/* A push slides the page underneath to the left; keep it out of the list beside it. */} |
| 39 | <View className="flex-1 overflow-hidden"> |
| 40 | <View |
| 41 | className="flex-1" |
| 42 | pointerEvents={emptyDetail ? "none" : "auto"} |
| 43 | accessibilityElementsHidden={emptyDetail} |
| 44 | importantForAccessibility={emptyDetail ? "no-hide-descendants" : "auto"} |
| 45 | style={emptyDetail ? { opacity: 0 } : undefined} |
| 46 | > |
| 47 | {props.children} |
| 48 | </View> |
| 49 | {emptyDetail ? ( |
| 50 | <View className="absolute inset-0"> |
| 51 | <NavigationRouteContext value={route}> |
| 52 | <SettingsScreen title={gt("Settings")} workspaceRoot> |
| 53 | <View className="flex-1 items-center justify-center p-6"> |
| 54 | <AppText className="text-foreground-muted"> |
| 55 | <T>Select a setting</T> |
| 56 | </AppText> |
| 57 | </View> |
| 58 | </SettingsScreen> |
| 59 | </NavigationRouteContext> |
| 60 | </View> |
| 61 | ) : null} |
| 62 | </View> |
| 63 | </View> |
| 64 | ); |
| 65 | } |