Skip to content

Commit 3e0f3a2

Browse files
committed
feat: add primary and secondary action buttons to Sheet component
- Add title, message, primaryButtonTitle, secondaryButtonTitle props - Add onPrimaryAction and onSecondaryAction event handlers - Wire up all three events (dismiss, primaryAction, secondaryAction) to native layer - Expose functionality already supported by native implementation
1 parent 6f9042e commit 3e0f3a2

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/components/SwiftUI/Sheet.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,32 @@ export type NativeSheetDetent = "medium" | "large" | `fraction:${number}` | `hei
1010
export type NativeSheetProps = {
1111
isPresented?: boolean;
1212
detents?: NativeSheetDetent[];
13+
title?: string;
14+
message?: string;
15+
primaryButtonTitle?: string;
16+
secondaryButtonTitle?: string;
17+
};
18+
19+
export type NativeSheetEvents = {
1320
onDismiss?: () => void;
21+
onPrimaryAction?: () => void;
22+
onSecondaryAction?: () => void;
1423
};
1524

16-
export const Sheet: FunctionComponentWithId<PropsWithChildren<NativeSheetProps>> = ({
25+
export type SheetProps = NativeSheetProps & NativeSheetEvents;
26+
27+
export const Sheet: FunctionComponentWithId<PropsWithChildren<SheetProps>> = ({
1728
children,
1829
onDismiss,
30+
onPrimaryAction,
31+
onSecondaryAction,
1932
...otherProps
2033
}) => {
21-
const { id } = useSwiftUINode("Sheet", otherProps, { dismiss: onDismiss });
34+
const { id } = useSwiftUINode("Sheet", otherProps, {
35+
dismiss: onDismiss,
36+
primaryAction: onPrimaryAction,
37+
secondaryAction: onSecondaryAction,
38+
});
2239
return <SwiftUIParentIdProvider id={id}>{children}</SwiftUIParentIdProvider>;
2340
};
2441
Sheet.displayName = "Sheet";

0 commit comments

Comments
 (0)