Open History to see the last commit
1import { View } from "react-native";
2
3import { AppBar } from "./AppBar";
4import { Button } from "./Button";
5import { IconButton } from "./IconButton";
6import type { SheetCloseButtonProps, SheetHeaderProps } from "./SheetHeader.types";
7
8export function SheetCloseButton(props: SheetCloseButtonProps) {
9 return (
10 <IconButton
11 icon="xmark"
12 accessibilityLabel={props.accessibilityLabel ?? (props.onCancel ? "Cancel" : "Close")}
13 disabled={props.disabled}
14 tintColorClassName="accent-header-foreground"
15 onPress={props.onCancel ?? props.onClose}
16 />
17 );
18}
19
20export function SheetHeader(props: SheetHeaderProps) {
21 const confirmation = props.confirm;
22 const trailing =
23 props.trailing || confirmation ? (
24 <View className="flex-row items-center gap-2">
25 {props.trailing}
26 {confirmation ? (
27 <Button
28 label={confirmation.label}
29 tone="text"
30 loading={confirmation.loading}
31 disabled={confirmation.disabled}
32 onPress={confirmation.onPress}
33 />
34 ) : null}
35 </View>
36 ) : undefined;
37
38 return (
39 <AppBar
40 embedded
41 sheet={props.presentation === "inline"}
42 title={props.title}
43 subtitle={props.subtitle}
44 leading={
45 <SheetCloseButton
46 {...(props.onCancel ? { onCancel: props.onCancel } : { onClose: props.onClose })}
47 accessibilityLabel={props.accessibilityLabel}
48 disabled={props.dismissDisabled}
49 />
50 }
51 trailing={trailing}
52 hideBottomBorder
53 />
54 );
55}