diff --git a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift index 85bd8945..62a651cd 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift +++ b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift @@ -52,9 +52,7 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { // ------------------------ public var reactProps: NSDictionary = [:]; - - // TBA - + // MARK: Init // ---------- @@ -81,6 +79,7 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView { modalVC.view.backgroundColor = .systemBackground; modalVC.lifecycleEventDelegates.add(self); + modalVC.modalLifecycleEventDelegates.add(self); modalVC.sheetPresentationStateMachine.eventDelegates.add(self); return modalVC; @@ -174,22 +173,7 @@ extension RNIModalSheetViewDelegate: RNIContentViewDelegate { ); let modalVC = try self.createModalController(); - - self.dispatchEvent( - for: .onModalWillPresent, - withPayload: [ - "isAnimated": isAnimated, - ] - ); - - closestVC.present(modalVC, animated: isAnimated) { - self.dispatchEvent( - for: .onModalDidPresent, - withPayload: [ - "isAnimated": isAnimated, - ] - ); - }; + closestVC.present(modalVC, animated: isAnimated); resolveBlock([:]); @@ -295,6 +279,33 @@ extension RNIModalSheetViewDelegate: ViewControllerLifecycleNotifiable { }; }; +extension RNIModalSheetViewDelegate: ModalViewControllerEventsNotifiable { + + public func notifyOnModalWillPresent( + sender: UIViewController, + isAnimated: Bool + ) { + self.dispatchEvent( + for: .onModalWillPresent, + withPayload: [ + "isAnimated": isAnimated, + ] + ); + }; + + public func notifyOnModalDidPresent( + sender: UIViewController, + isAnimated: Bool + ) { + self.dispatchEvent( + for: .onModalDidPresent, + withPayload: [ + "isAnimated": isAnimated, + ] + ); + }; +}; + // MARK: - RNIModalSheetViewDelegate+ViewControllerLifecycleNotifiable // -------------------------------------------------------------------