Skip to content

Commit

Permalink
Modify navigate
Browse files Browse the repository at this point in the history
  • Loading branch information
olivaresf committed Dec 15, 2023
1 parent 9120f7d commit 484577c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Source/Turbo Navigator/TurboNavigationHierarchyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,28 @@ class TurboNavigationHierarchyController {
delegate.visit(visitable, on: .main, with: proposal.options)
}
case .modal:
if navigationController.presentedViewController != nil, !modalNavigationController.isBeingDismissed {
pushOrReplace(on: modalNavigationController, with: controller, via: proposal)
if proposal.alwaysDismiss {
navigationController.dismiss(animated: true) {
self.modalNavigate(with: controller, via: proposal)
}
} else {
modalNavigationController.setViewControllers([controller], animated: true)
modalNavigationController.setModalPresentationStyle(via: proposal)
navigationController.present(modalNavigationController, animated: true)
}
if let visitable = controller as? Visitable {
delegate.visit(visitable, on: .modal, with: proposal.options)
modalNavigate(with: controller, via: proposal)
}
}
}

private func modalNavigate(with controller: UIViewController, via proposal: VisitProposal) {
if navigationController.presentedViewController != nil, !modalNavigationController.isBeingDismissed {
pushOrReplace(on: modalNavigationController, with: controller, via: proposal)
} else {
modalNavigationController.setViewControllers([controller], animated: true)
modalNavigationController.setModalPresentationStyle(via: proposal)
navigationController.present(modalNavigationController, animated: true)
}
if let visitable = controller as? Visitable {
delegate.visit(visitable, on: .modal, with: proposal.options)
}
}

private func pushOrReplace(on navigationController: UINavigationController, with controller: UIViewController, via proposal: VisitProposal) {
if visitingSamePage(on: navigationController, with: controller, via: proposal.url) {
Expand Down

0 comments on commit 484577c

Please sign in to comment.