pr suggestions and implemented a simpler way to clear the route, that always brings back to the initial coordinator

This commit is contained in:
Mauro Romito
2025-11-05 16:05:09 +01:00
committed by Mauro
parent e597dd8722
commit 6dee4176f2
7 changed files with 136 additions and 50 deletions
@@ -574,6 +574,21 @@ private struct NavigationSplitCoordinatorView: View {
}
}
func pop(to coordinator: CoordinatorProtocol, animated: Bool = true) {
if rootCoordinator === coordinator {
popToRoot(animated: animated)
} else if stackCoordinators.contains(where: { $0 === coordinator }) {
var transaction = Transaction()
transaction.disablesAnimations = !animated
withTransaction(transaction) {
while stackCoordinators.last !== coordinator, !stackCoordinators.isEmpty {
_ = stackModules.popLast()
}
}
}
}
/// Present a sheet on top of the stack. If this NavigationStackCoordinator is embedded within a NavigationSplitCoordinator
/// then the presentation will be proxied to the split
/// - Parameters: