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 type { SheetProps } from "./Sheet.types";
7export type { SheetProps } from "./Sheet.types";
8
9export function Sheet(props: SheetProps) {
10 const containerStyle = useResolveClassNames("bg-sheet");
11 const [isOpen, setIsOpen] = useState(true);
12 return (
13 <FormSheet
14 isOpen={isOpen}
15 detents={[0.5, 0.9]}
16 prefersGrabberVisible
17 nativeContainerStyle={containerStyle}
18 onDismiss={props.onClose}
19 onNativeDismiss={props.onClose}
20 >
21 {/* Flex children are not bounded by the FormSheet host on Android, so pin to its edges.
22 Material coordinates drags with the first nested-scrolling view in native order. The Compose
23 header has one, so the content comes first and column-reverse draws it below. */}
24 <View collapsable={false} className="absolute inset-0 flex-col-reverse bg-sheet">
25 <View className="flex-1">{props.children}</View>
26 <AndroidSheetHeader title={props.title} onBack={() => setIsOpen(false)} />
27 </View>
28 </FormSheet>
29 );
30}