| 1 | import { useNavigation } from "@react-navigation/native"; |
| 2 | import type { ReactNode } from "react"; |
| 3 | import { Platform, View } from "react-native"; |
| 4 | |
| 5 | import type { ScreenHeaderProps } from "../../../components/ScreenHeader.types"; |
| 6 | import { ScreenHeader } from "../../../components/ScreenHeader"; |
| 7 | import { MaterialScreenContent as SettingsScreenContent } from "../../../components/MaterialScreenContent"; |
| 8 | |
| 9 | export { SettingsScreenContent }; |
| 10 | |
| 11 | export function SettingsScreen( |
| 12 | props: Pick<ScreenHeaderProps, "title" | "actions" | "trailing"> & { |
| 13 | readonly children: ReactNode; |
| 14 | /** A native form sheet already owns its rounded outer frame. */ |
| 15 | readonly formSheet?: boolean; |
| 16 | }, |
| 17 | ) { |
| 18 | const navigation = useNavigation(); |
| 19 | |
| 20 | return ( |
| 21 | <View collapsable={false} className="flex-1 bg-sheet"> |
| 22 | <ScreenHeader |
| 23 | title={props.title} |
| 24 | actions={props.actions} |
| 25 | trailing={Platform.OS === "android" ? props.trailing : undefined} |
| 26 | sidebar={false} |
| 27 | onBack={() => navigation.goBack()} |
| 28 | hideBottomBorder={!props.formSheet} |
| 29 | /> |
| 30 | {props.formSheet ? ( |
| 31 | props.children |
| 32 | ) : ( |
| 33 | <SettingsScreenContent>{props.children}</SettingsScreenContent> |
| 34 | )} |
| 35 | </View> |
| 36 | ); |
| 37 | } |