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 { useRoute } from "@react-navigation/native"; |
| 2 | import type { ReactNode } from "react"; |
| 3 | import { View } from "react-native"; |
| 4 | |
| 5 | import type { AppBarProps } from "../../../components/ui/AppBar.types"; |
| 6 | import { AppBar } from "../../../components/ui/AppBar"; |
| 7 | import { ScreenContent as SettingsScreenContent } from "../../../components/ui/ScreenContent"; |
| 8 | import { useWorkspaceTabs } from "../../layout/workspace/WorkspaceTabsContext"; |
| 9 | import { useDeviceType } from "../../../native/native-layout-metrics"; |
| 10 | import { useCompactWorkspaceTabs } from "../../layout/workspace/useSystemWorkspaceTabBar"; |
| 11 | import { useSettingsPageBack } from "../useSettingsPageBack"; |
| 12 | import { |
| 13 | ScreenScrollViewBottomInset, |
| 14 | ScreenScrollViewSurface, |
| 15 | } from "../../../components/ui/ScreenScrollView"; |
| 16 | |
| 17 | export { SettingsScreenContent }; |
| 18 | |
| 19 | export function SettingsScreen( |
| 20 | props: Pick< |
| 21 | AppBarProps, |
| 22 | "title" | "actions" | "refresh" | "trailing" | "search" | "menus" | "guardBack" |
| 23 | > & { |
| 24 | readonly children: ReactNode; |
| 25 | readonly workspaceRoot?: boolean; |
| 26 | }, |
| 27 | ) { |
| 28 | const route = useRoute(); |
| 29 | const workspace = useWorkspaceTabs(); |
| 30 | const deviceType = useDeviceType(); |
| 31 | const compactTabs = useCompactWorkspaceTabs(); |
| 32 | const back = useSettingsPageBack(); |
| 33 | const cover = deviceType === "duo-folded"; |
| 34 | // Opened as a workspace tab, the Settings list has nothing to go back to. |
| 35 | const workspaceRoot = props.workspaceRoot || (workspace !== null && route.name === "Settings"); |
| 36 | |
| 37 | const surfaceClassName = workspaceRoot || cover ? "bg-screen" : "bg-sheet"; |
| 38 | |
| 39 | return ( |
| 40 | <View collapsable={false} className={`flex-1 ${surfaceClassName}`}> |
| 41 | <AppBar |
| 42 | title={props.title} |
| 43 | actions={props.actions} |
| 44 | refresh={props.refresh} |
| 45 | search={props.search} |
| 46 | trailing={props.trailing} |
| 47 | menus={props.menus} |
| 48 | onBack={workspaceRoot ? undefined : back} |
| 49 | guardBack={props.guardBack} |
| 50 | hideBottomBorder |
| 51 | /> |
| 52 | <ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}> |
| 53 | <ScreenScrollViewSurface value={surfaceClassName}> |
| 54 | <SettingsScreenContent>{props.children}</SettingsScreenContent> |
| 55 | </ScreenScrollViewSurface> |
| 56 | </ScreenScrollViewBottomInset> |
| 57 | </View> |
| 58 | ); |
| 59 | } |