From 00b066139ed0bf2f68549a7d87434ed36dfa6dea Mon Sep 17 00:00:00 2001 From: Paul Kraft Date: Thu, 2 Feb 2023 15:52:19 +0100 Subject: [PATCH] Set trigger async extensions to be run on MainActor and mark non-objc functions in extensions to be public instead of open because they could not be overriden anyways according to Xcode --- Sources/XCoordinator/BaseCoordinator.swift | 6 +++--- Sources/XCoordinator/NavigationAnimationDelegate.swift | 2 +- Sources/XCoordinator/Router.swift | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/XCoordinator/BaseCoordinator.swift b/Sources/XCoordinator/BaseCoordinator.swift index be02e914..1ecacdc3 100755 --- a/Sources/XCoordinator/BaseCoordinator.swift +++ b/Sources/XCoordinator/BaseCoordinator.swift @@ -193,7 +193,7 @@ extension BaseCoordinator { /// The closure to be called whenever the transition completes. /// Hint: Might be called multiple times but only once per performing the transition. /// - open func registerInteractiveTransition( + public func registerInteractiveTransition( for route: RouteType, triggeredBy recognizer: GestureRecognizer, handler: @escaping (_ handlerRecognizer: GestureRecognizer, _ transition: () -> TransitionAnimation?) -> Void, @@ -238,7 +238,7 @@ extension BaseCoordinator { /// The closure to be called whenever the transition completes. /// Hint: Might be called multiple times but only once per performing the transition. /// - open func registerInteractiveTransition( + public func registerInteractiveTransition( for route: RouteType, triggeredBy recognizer: GestureRecognizer, progress: @escaping (GestureRecognizer) -> CGFloat, @@ -287,7 +287,7 @@ extension BaseCoordinator { /// The recognizer to unregister interactive transitions for. /// This method will unregister all interactive transitions with that gesture recognizer. /// - open func unregisterInteractiveTransitions(triggeredBy recognizer: UIGestureRecognizer) { + public func unregisterInteractiveTransitions(triggeredBy recognizer: UIGestureRecognizer) { gestureRecognizerTargets.removeAll { target in guard target.gestureRecognizer === recognizer else { return false } recognizer.removeTarget(target, action: nil) diff --git a/Sources/XCoordinator/NavigationAnimationDelegate.swift b/Sources/XCoordinator/NavigationAnimationDelegate.swift index ffbe834e..29bf4c1e 100755 --- a/Sources/XCoordinator/NavigationAnimationDelegate.swift +++ b/Sources/XCoordinator/NavigationAnimationDelegate.swift @@ -263,7 +263,7 @@ extension NavigationAnimationDelegate: UIGestureRecognizerDelegate { /// /// - Parameter navigationController: The navigation controller to be set up. /// - open func setupPopGestureRecognizer(for navigationController: UINavigationController) { + public func setupPopGestureRecognizer(for navigationController: UINavigationController) { self.navigationController = navigationController guard let popRecognizer = navigationController.interactivePopGestureRecognizer, popRecognizer.delegate !== self else { diff --git a/Sources/XCoordinator/Router.swift b/Sources/XCoordinator/Router.swift index 2e414b6c..c29929d2 100755 --- a/Sources/XCoordinator/Router.swift +++ b/Sources/XCoordinator/Router.swift @@ -127,7 +127,7 @@ extension Router { /// - Parameters: /// - route: The route to be triggered. /// - public func trigger(_ route: RouteType) async { + @MainActor public func trigger(_ route: RouteType) async { await trigger(route, with: .default) } @@ -138,7 +138,7 @@ extension Router { /// - route: The route to be triggered. /// - options: Transition options for performing the transition, e.g. whether it should be animated. /// - public func trigger(_ route: RouteType, with options: TransitionOptions) async { + @MainActor public func trigger(_ route: RouteType, with options: TransitionOptions) async { _ = await contextTrigger(route, with: options) } @@ -159,7 +159,7 @@ extension Router { /// The transition context of the performed transition(s). /// If the context is not needed, use `trigger` instead. /// - public func contextTrigger(_ route: RouteType, with options: TransitionOptions) async -> TransitionContext { + @MainActor public func contextTrigger(_ route: RouteType, with options: TransitionOptions) async -> TransitionContext { await withCheckedContinuation { continuation in contextTrigger(route, with: options) { context in continuation.resume(returning: context)