Skip to content

Commit

Permalink
Allow a nav controller to be pushed into a modal stack
Browse files Browse the repository at this point in the history
There are times where this is expected (e.g. EKEventEditViewController inherits from a nav controller and it must be presented).
  • Loading branch information
olivaresf committed Apr 26, 2024
1 parent 15a9958 commit e207125
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Source/Turbo Navigator/TurboNavigationHierarchyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e207125

Please sign in to comment.