Skip to content

Commit

Permalink
Try waiting for animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Olivares committed Jul 4, 2024
1 parent 5116ec2 commit 65292df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
19 changes: 13 additions & 6 deletions Source/Turbo Navigator/TurboNavigationHierarchyController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,28 @@ class TurboNavigationHierarchyController {
if navigationController.presentedViewController != nil {
if modalNavigationController.viewControllers.count == 1 {
navigationController.dismiss(animated: proposal.animated)
refreshIfTopViewControllerIsVisitable(from: .main)
refreshIfTopViewControllerIsVisitable(from: .main, animated: proposal.animated)
} else {
modalNavigationController.popViewController(animated: proposal.animated)
refreshIfTopViewControllerIsVisitable(from: .modal)
refreshIfTopViewControllerIsVisitable(from: .modal, animated: proposal.animated)
}
} else {
navigationController.popViewController(animated: proposal.animated)
refreshIfTopViewControllerIsVisitable(from: .main)
refreshIfTopViewControllerIsVisitable(from: .main, animated: proposal.animated)
}
}

private func refreshIfTopViewControllerIsVisitable(from stack: NavigationStackType) {
private func refreshIfTopViewControllerIsVisitable(from stack: NavigationStackType, animated: Bool) {
if let navControllerTopmostVisitable = navController(for: stack).topViewController as? Visitable {
delegate.refreshVisitable(navigationStack: stack,
newTopmostVisitable: navControllerTopmostVisitable)
if animated {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.333) {
self.delegate.refreshVisitable(navigationStack: stack,
newTopmostVisitable: navControllerTopmostVisitable)
}
} else {
delegate.refreshVisitable(navigationStack: stack,
newTopmostVisitable: navControllerTopmostVisitable)
}
}
}

Expand Down
8 changes: 2 additions & 6 deletions Source/Turbo Navigator/TurboNavigator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,10 @@ extension TurboNavigator: TurboNavigationHierarchyControllerDelegate {
newTopmostVisitable: any Visitable) {
switch navigationStack {
case .main:
session.visit(newTopmostVisitable,
options: .init(action: .replace))
session.visit(newTopmostVisitable, reload: true)
case .modal:
modalSession.visit(newTopmostVisitable,
options: .init(action: .replace))
modalSession.visit(newTopmostVisitable, reload: true)
}

newTopmostVisitable.visitableViewDidRequestRefresh()
}
}

Expand Down

0 comments on commit 65292df

Please sign in to comment.