Skip to content

Commit

Permalink
💫 Update: RNIModalSheetView - Modal Present Event Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicstop committed Sep 30, 2024
1 parent 8e76eef commit 1f2ac6d
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public final class RNIModalSheetViewDelegate: UIView, RNIContentView {
// ------------------------

public var reactProps: NSDictionary = [:];

// TBA


// MARK: Init
// ----------

Expand All @@ -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;
Expand Down Expand Up @@ -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([:]);

Expand Down Expand Up @@ -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
// -------------------------------------------------------------------

Expand Down

0 comments on commit 1f2ac6d

Please sign in to comment.