Skip to content

Commit

Permalink
🛠 Refactor: Update RNIModalView
Browse files Browse the repository at this point in the history
Related:
* `TODO:2023-03-24-09-58-50` - Refactor `RNIModalView` to use `RNIModalManager`

Summary: WIP - Update `RNIModalView` to use `RNIModalManager`.
  • Loading branch information
dominicstop committed Mar 26, 2023
1 parent 7ca0e3f commit 17a207f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ios/src_library/React Native/RNIModalView/RNIModalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ class RNIModalView: UIView, RNIModalFocusNotifying, RNIModalIdentity,

self.bridge = bridge;
self.touchHandler = RCTTouchHandler(bridge: self.bridge);

RNIModalManagerShared.register(modal: self);
};

required init?(coder aDecoder: NSCoder) {
Expand Down Expand Up @@ -551,6 +553,8 @@ class RNIModalView: UIView, RNIModalFocusNotifying, RNIModalIdentity,

self.presentingViewController = topMostPresentedVC;

self.modalFocusDelegate.onModalWillFocusNotification(sender: self);

topMostPresentedVC.present(modalVC, animated: true) {
if self.hideNonVisibleModals {
self.setIsHiddenForViewBelowLevel(self.modalLevel - 1, isHidden: true);
Expand All @@ -562,6 +566,8 @@ class RNIModalView: UIView, RNIModalFocusNotifying, RNIModalIdentity,
/// TODO:2023-03-24-14-25-52 - Remove `RNIModalViewFocusDelegate`-related logic
self.delegate?.onPresentModalView(modalView: self);

self.modalFocusDelegate.onModalDidFocusNotification(sender: self);

self.onModalShow?(
self.createModalNativeEventDict()
);
Expand Down Expand Up @@ -629,6 +635,7 @@ class RNIModalView: UIView, RNIModalFocusNotifying, RNIModalIdentity,
presentedVC.dismiss(animated: true){
/// TODO:2023-03-24-14-25-52 - Remove `RNIModalViewFocusDelegate`-related logic
self.delegate?.onDismissModalView(modalView: self);

self.onModalDismiss?(
self.createModalNativeEventDict()
);
Expand Down Expand Up @@ -680,6 +687,8 @@ class RNIModalView: UIView, RNIModalFocusNotifying, RNIModalIdentity,
extension RNIModalView: UIAdaptivePresentationControllerDelegate {

func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {
self.modalFocusDelegate.onModalWillBlurNotification(sender: self);

if self.hideNonVisibleModals {
self.setIsHiddenForViewBelowLevel(self.modalLevel, isHidden: false);
};
Expand All @@ -696,6 +705,8 @@ extension RNIModalView: UIAdaptivePresentationControllerDelegate {
};

func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
self.modalFocusDelegate.onModalDidBlurNotification(sender: self);

self.modalLevel = -1;

/// TODO:2023-03-24-14-25-52 - Remove `RNIModalViewFocusDelegate`-related logic
Expand Down

0 comments on commit 17a207f

Please sign in to comment.