Open History to see the last commit
1import { useNavigation } from "@react-navigation/native";
2import type { ComponentProps, ReactNode } from "react";
3import { Platform, View } from "react-native";
4
5import { AndroidScreenHeader } from "../../../components/AndroidScreenHeader";
6import { MaterialScreenContent as SettingsScreenContent } from "../../../components/MaterialScreenContent";
7import { NativeStackScreenOptions } from "../../../native/StackHeader";
8import { AndroidWorkspaceSidebarButton } from "../../layout/workspace-sidebar-toolbar";
9
10export { SettingsScreenContent };
11
12export function SettingsScreen(
13 props: Pick<ComponentProps<typeof AndroidScreenHeader>, "title" | "actions" | "trailing"> & {
14 readonly children: ReactNode;
15 /** A native form sheet already owns its rounded outer frame. */
16 readonly formSheet?: boolean;
17 },
18) {
19 const navigation = useNavigation();
20
21 return (
22 <View collapsable={false} className="flex-1 bg-sheet">
23 {Platform.OS === "android" ? (
24 <>
25 <NativeStackScreenOptions options={{ headerShown: false }} />
26 <AndroidScreenHeader
27 title={props.title}
28 leading={props.formSheet ? undefined : <AndroidWorkspaceSidebarButton />}
29 actions={props.actions}
30 trailing={props.trailing}
31 onBack={() => navigation.goBack()}
32 hideBottomBorder={!props.formSheet}
33 />
34 </>
35 ) : null}
36 {props.formSheet ? (
37 props.children
38 ) : (
39 <SettingsScreenContent>{props.children}</SettingsScreenContent>
40 )}
41 </View>
42 );
43}