diff --git a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift index 62a651cd..8637b148 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift +++ b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift @@ -21,6 +21,9 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { case onModalWillPresent; case onModalDidPresent; + case onModalWillDismiss; + case onModalDidDismiss; + case onModalWillShow; case onModalDidShow; @@ -304,6 +307,30 @@ extension RNIModalSheetViewDelegate: ModalViewControllerEventsNotifiable { ] ); }; + + public func notifyOnModalWillDismiss( + sender: UIViewController, + isAnimated: Bool + ) { + self.dispatchEvent( + for: .onModalWillDismiss, + withPayload: [ + "isAnimated": isAnimated, + ] + ); + }; + + public func notifyOnModalDidDismiss( + sender: UIViewController, + isAnimated: Bool + ) { + self.dispatchEvent( + for: .onModalDidDismiss, + withPayload: [ + "isAnimated": isAnimated, + ] + ); + }; }; // MARK: - RNIModalSheetViewDelegate+ViewControllerLifecycleNotifiable diff --git a/ios/RNIModalSheetView/RNIModalSheetViewManager.mm b/ios/RNIModalSheetView/RNIModalSheetViewManager.mm index 0154ffa5..c7b5872d 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewManager.mm +++ b/ios/RNIModalSheetView/RNIModalSheetViewManager.mm @@ -31,6 +31,9 @@ - (UIView *)view RNI_EXPORT_VIEW_EVENT(onModalWillPresent, RCTBubblingEventBlock); RNI_EXPORT_VIEW_EVENT(onModalDidPresent, RCTBubblingEventBlock); +RNI_EXPORT_VIEW_EVENT(onModalWillDismiss, RCTBubblingEventBlock); +RNI_EXPORT_VIEW_EVENT(onModalDidDismiss, RCTBubblingEventBlock); + RNI_EXPORT_VIEW_EVENT(onModalWillShow, RCTBubblingEventBlock); RNI_EXPORT_VIEW_EVENT(onModalDidShow, RCTBubblingEventBlock); diff --git a/src/components/ModalSheetView/ModalSheetView.tsx b/src/components/ModalSheetView/ModalSheetView.tsx index 727734ec..b109c231 100644 --- a/src/components/ModalSheetView/ModalSheetView.tsx +++ b/src/components/ModalSheetView/ModalSheetView.tsx @@ -141,7 +141,7 @@ export const ModalSheetView = React.forwardRef< {...props} ref={ref => nativeRef.current = ref} style={styles.nativeModalSheet} - onModalDidHide={(event) => { + onModalDidDismiss={(event) => { setShouldExplicitlyMountModalContents(false); props.onModalDidHide?.(event); diff --git a/src/components/ModalSheetView/ModalSheetViewTypes.tsx b/src/components/ModalSheetView/ModalSheetViewTypes.tsx index 32ee171f..4a621f07 100644 --- a/src/components/ModalSheetView/ModalSheetViewTypes.tsx +++ b/src/components/ModalSheetView/ModalSheetViewTypes.tsx @@ -40,6 +40,8 @@ export type ModalSheetViewInheritedProps = Pick; onModalDidPresent?: BubblingEventHandler<{}>; + onModalWillDismiss: BubblingEventHandler<{}>; + onModalDidDismiss: BubblingEventHandler<{}>; + onModalWillShow?: BubblingEventHandler<{}>; onModalDidShow?: BubblingEventHandler<{}>; onModalWillHide?: BubblingEventHandler<{}>; diff --git a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts index c8ed7718..51477476 100644 --- a/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts +++ b/src/native_components/RNIModalSheetVIew/RNIModalSheetViewTypes.ts @@ -35,6 +35,8 @@ export type RNIModalSheetViewInheritedOptionalProps = Partial; +export type OnModalWillDismissEventPayload = Readonly<{ + isAnimated: boolean; +}>; + +export type OnModalDidDidDismissEventPayload = Readonly<{ + isAnimated: boolean; +}>; + export type OnModalWillShowEventPayload = Readonly<{ isAnimated: boolean; isFirstAppearance: boolean; @@ -39,6 +47,12 @@ export type OnModalWillPresentEvent = export type OnModalDidPresentEvent = BubblingEventHandler; +export type OnModalWillDismissEvent = + BubblingEventHandler; + +export type OnModalDidDismissEvent = + BubblingEventHandler; + export type OnModalWillShowEvent = BubblingEventHandler;