From 3b8802ca078f68b8b6505b89b46e2b41ecd26ad9 Mon Sep 17 00:00:00 2001 From: Dominic Go <18517029+dominicstop@users.noreply.github.com> Date: Fri, 7 Apr 2023 01:36:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20`RNIModalView`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related: * `TODO:2023-03-31-18-33-34` - Unify/streamline/consolidate logic for invoking modal focus/blur. * `TODO:2023-04-06-02-13-24` - Update `RNIModalView` to use `RNIViewControllerLifeCycleNotifiable`. Summary: WIP - Update `RNIModalView` to conform to `RNIViewControllerLifeCycleNotifiable`, and add placeholder/"no-op" methods. --- .../RNIModalView/RNIModalView.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ios/src_library/React Native/RNIModalView/RNIModalView.swift b/ios/src_library/React Native/RNIModalView/RNIModalView.swift index dc9caa2c..5e8c7514 100644 --- a/ios/src_library/React Native/RNIModalView/RNIModalView.swift +++ b/ios/src_library/React Native/RNIModalView/RNIModalView.swift @@ -338,7 +338,9 @@ class RNIModalView: UIView, RNIIdentifiable, RNIModalFocusNotifying, self.modalVC = { let vc = RNIModalViewController(); + vc.modalViewRef = self; + vc.lifecycleDelegate = self; vc.isBGBlurred = self.isModalBGBlurred; vc.isBGTransparent = self.isModalBGTransparent; @@ -751,6 +753,25 @@ extension RNIModalView: RNIModalRequestable { }; }; +extension RNIModalView: RNIViewControllerLifeCycleNotifiable { + + func viewWillAppear(sender: UIViewController, animated: Bool) { + guard sender.isBeingPresented else { return }; + }; + + func viewDidAppear(sender: UIViewController, animated: Bool) { + guard sender.isBeingPresented else { return }; + }; + + func viewWillDisappear(sender: UIViewController, animated: Bool) { + guard sender.isBeingDismissed else { return }; + }; + + func viewDidDisappear(sender: UIViewController, animated: Bool) { + guard sender.isBeingDismissed else { return }; + }; +}; + // MARK: Extension: RNIModalFocusNotifiable // ----------------------------------------