From e2071254f7f9a9a4a01d8482c50f60bc318f78f4 Mon Sep 17 00:00:00 2001 From: Fernando Olivares Date: Thu, 25 Apr 2024 21:17:00 -0600 Subject: [PATCH] Allow a nav controller to be pushed into a modal stack There are times where this is expected (e.g. EKEventEditViewController inherits from a nav controller and it must be presented). --- .../TurboNavigationHierarchyController.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Turbo Navigator/TurboNavigationHierarchyController.swift b/Source/Turbo Navigator/TurboNavigationHierarchyController.swift index cbc5afb..d70ff43 100644 --- a/Source/Turbo Navigator/TurboNavigationHierarchyController.swift +++ b/Source/Turbo Navigator/TurboNavigationHierarchyController.swift @@ -86,7 +86,10 @@ class TurboNavigationHierarchyController { delegate.visit(visitable, on: .main, with: proposal.options) } case .modal: - if navigationController.presentedViewController != nil, !modalNavigationController.isBeingDismissed { + if let proposedModalNavController = controller as? UINavigationController { + proposedModalNavController.setModalPresentationStyle(via: proposal) + navigationController.present(proposedModalNavController, animated: true) + } else if navigationController.presentedViewController != nil, !modalNavigationController.isBeingDismissed { pushOrReplace(on: modalNavigationController, with: controller, via: proposal) } else { modalNavigationController.setViewControllers([controller], animated: true) @@ -151,7 +154,10 @@ class TurboNavigationHierarchyController { delegate.visit(visitable, on: .main, with: proposal.options) } case .modal: - if navigationController.presentedViewController != nil { + if let proposedModalNavController = controller as? UINavigationController { + proposedModalNavController.setModalPresentationStyle(via: proposal) + navigationController.present(proposedModalNavController, animated: true) + } else if navigationController.presentedViewController != nil { modalNavigationController.replaceLastViewController(with: controller) } else { modalNavigationController.setViewControllers([controller], animated: false)