Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

Sheet.android.tsx

42 lines1.6 KB

1import { useState } from "react";
2import { View } from "react-native";
3import { FormSheet } from "react-native-screens";
4import { useResolveClassNames } from "uniwind";
5import { AppBar } from "./AppBar";
6import { RoutedFormSheetContext } from "./RoutedFormSheetContext";
7import { ScreenContent } from "./ScreenContent";
8import type { SheetProps } from "./Sheet.types";
9export type { SheetProps } from "./Sheet.types";
10​
11export function Sheet(props: SheetProps) {
12 const containerStyle = useResolveClassNames("bg-header");
13 const [isOpen, setIsOpen] = useState(true);
14 return (
15 <FormSheet
16 isOpen={isOpen}
17 detents={[0.5, 0.9]}
18 prefersGrabberVisible={false}
19 preventNativeDismiss={props.dismissDisabled}
20 nativeContainerStyle={containerStyle}
21 onDismiss={props.onClose}
22 onNativeDismiss={props.onClose}
23 >
24 <RoutedFormSheetContext value={false}>
25 {/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
26 <View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
27 <ScreenContent>{props.children}</ScreenContent>
28 <AppBar
29 sheet
30 title={props.title}
31 onBack={props.dismissDisabled ? undefined : () => setIsOpen(false)}
32 hideBottomBorder
33 />
34 <View
35 pointerEvents="none"
36 className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
37 />
38 </View>
39 </RoutedFormSheetContext>
40 </FormSheet>
41 );