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

SheetHeader.android.tsx

54 lines1.6 KB

1import { View } from "react-native";
2​
3import { AndroidScreenHeader } from "./AndroidScreenHeader";
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 );
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 <AndroidScreenHeader
40 embedded={props.presentation === "inline"}
41 title={props.title}
42 subtitle={props.subtitle}
43 leading={
44 <SheetCloseButton
45 {...(props.onCancel ? { onCancel: props.onCancel } : { onClose: props.onClose })}
46 accessibilityLabel={props.accessibilityLabel}
47 disabled={props.dismissDisabled}
48 />
49 }
50 trailing={trailing}
51 hideBottomBorder
52 />
53 );