From 84cf3e4fd2a27a308591be59f1be930be663ebf3 Mon Sep 17 00:00:00 2001 From: Dominic Go Date: Wed, 2 Oct 2024 14:16:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20Update:=20`ModalFocusEventNotifi?= =?UTF-8?q?able.notifyForModalFocusStateChange`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift | 1 + ios/Temp/ModalEventManager/ModalFocusEventNotifiable.swift | 2 ++ ios/Temp/ModalEventManager/ModalRegistryEntry.swift | 5 +++++ ios/Temp/ModalViewControllerLifecycleNotifier.swift | 2 ++ 4 files changed, 10 insertions(+) diff --git a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift index 5fa10f6..c7e3cfa 100644 --- a/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift +++ b/ios/RNIModalSheetView/RNIModalSheetViewDelegate.swift @@ -459,6 +459,7 @@ extension RNIModalSheetViewDelegate: ModalSheetViewControllerEventsNotifiable { extension RNIModalSheetViewDelegate: ModalFocusEventNotifiable { public func notifyForModalFocusStateChange( + forViewController viewController: UIViewController, prevState: ModalFocusState?, currentState: ModalFocusState, nextState: ModalFocusState diff --git a/ios/Temp/ModalEventManager/ModalFocusEventNotifiable.swift b/ios/Temp/ModalEventManager/ModalFocusEventNotifiable.swift index 1cdbe78..1a5e1ef 100644 --- a/ios/Temp/ModalEventManager/ModalFocusEventNotifiable.swift +++ b/ios/Temp/ModalEventManager/ModalFocusEventNotifiable.swift @@ -10,6 +10,7 @@ import Foundation public protocol ModalFocusEventNotifiable: AnyObject { func notifyForModalFocusStateChange( + forViewController viewController: UIViewController, prevState: ModalFocusState?, currentState: ModalFocusState, nextState: ModalFocusState @@ -22,6 +23,7 @@ public protocol ModalFocusEventNotifiable: AnyObject { public extension ModalFocusEventNotifiable { func notifyForModalFocusStateChange( + forViewController viewController: UIViewController, prevState: ModalFocusState?, currentState: ModalFocusState, nextState: ModalFocusState diff --git a/ios/Temp/ModalEventManager/ModalRegistryEntry.swift b/ios/Temp/ModalEventManager/ModalRegistryEntry.swift index 80e30ab..0f0b87c 100644 --- a/ios/Temp/ModalEventManager/ModalRegistryEntry.swift +++ b/ios/Temp/ModalEventManager/ModalRegistryEntry.swift @@ -35,6 +35,10 @@ public class ModalRegistryEntry { }; public func setModalFocusState(_ modalStateNext: ModalFocusState){ + guard let viewController = self.viewController else { + return; + }; + let modalStatePrev = self.modalFocusStatePrev; let modalStateCurrent = self.modalFocusState; @@ -47,6 +51,7 @@ public class ModalRegistryEntry { if let eventDelegate = self.viewController as? ModalFocusEventNotifiable { eventDelegate.notifyForModalFocusStateChange( + forViewController: viewController, prevState: modalStatePrev, currentState: modalStateCurrent, nextState: modalStateNext diff --git a/ios/Temp/ModalViewControllerLifecycleNotifier.swift b/ios/Temp/ModalViewControllerLifecycleNotifier.swift index 40d51e8..8d9a2db 100644 --- a/ios/Temp/ModalViewControllerLifecycleNotifier.swift +++ b/ios/Temp/ModalViewControllerLifecycleNotifier.swift @@ -164,12 +164,14 @@ open class ModalViewControllerLifecycleNotifier: ViewControllerLifecycleNotifier extension ModalViewControllerLifecycleNotifier: ModalFocusEventNotifiable { public func notifyForModalFocusStateChange( + forViewController viewController: UIViewController, prevState: ModalFocusState?, currentState: ModalFocusState, nextState: ModalFocusState ) { self.modalFocusEventDelegates.invoke { $0.notifyForModalFocusStateChange( + forViewController: viewController, prevState: prevState, currentState: currentState, nextState: nextState