Open History to see the last commit
1import { useState } from "react";
2import { View } from "react-native";
3import { FormSheet } from "react-native-screens";
4import { useResolveClassNames } from "uniwind";
5import { AndroidSheetHeader } from "./AndroidScreenHeader";
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 nativeContainerStyle={containerStyle}
20 onDismiss={props.onClose}
21 onNativeDismiss={props.onClose}
22 >
23 <RoutedFormSheetContext value={false}>
24 {/* Android FormSheet does not bound flex children. Material drags target the first scroll view, so place content before the header. */}
25 <View collapsable={false} className="absolute inset-0 flex-col-reverse bg-header">
26 <ScreenContent>{props.children}</ScreenContent>
27 <AndroidSheetHeader
28 title={props.title}
29 onBack={() => setIsOpen(false)}
30 hideBottomBorder
31 />
32 <View
33 pointerEvents="none"
34 className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
35 />
36 </View>
37 </RoutedFormSheetContext>
38 </FormSheet>
39 );
40}