We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[//]: # Using goBack to navigate back to a previous screen doesn't dismiss all of the views when each view is presented modally.
goBack
[//]: # Open a series of at least 3 modal views and then try to navigate back to the original view. One modal view will remain.
struct RootView: View { var body: some View { let dataSource = Navigator.Datasource(root: MainScreen()) let navigator = Navigator(dataSource: dataSource) return Root(dataSource: dataSource, navigator: navigator, pathBuilder: MainScreen.Builder()) } } struct MainScreen: Screen { var presentationStyle: ScreenPresentationStyle = .push struct Builder: NavigationTree { var builder: some PathBuilder { Screen( content: { (_: MainScreen) in MainView() }, nesting: { ModalScreen.Builder().eraseCircularNavigationPath() } ) } } } struct MainView: View { @Environment(\.navigator) private var navigator @Environment(\.currentScreenID) private var currentScreenID var body: some View { VStack { Button { navigator.go(to: ModalScreen(viewCount: 1, onDismiss: { print(currentScreenID) navigator.goBack(to: currentScreenID) }), on: currentScreenID) } label: { Text("Show new view") } } } } struct ModalScreen: Screen { var presentationStyle: ScreenPresentationStyle = .sheet(allowsPush: true) var viewCount: Int var onDismiss: () -> Void struct Builder: NavigationTree { var builder: some PathBuilder { Screen( content: { (screen: ModalScreen) in ModalView(viewCount: screen.viewCount, onDismiss: screen.onDismiss) }, nesting: { ModalScreen.Builder().eraseCircularNavigationPath() } ) } } } extension ModalScreen: Equatable { static func == (lhs: ModalScreen, rhs: ModalScreen) -> Bool { return lhs.viewCount == rhs.viewCount } } extension ModalScreen: Hashable { func hash(into hasher: inout Hasher) { hasher.combine(viewCount) } } struct ModalView: View { @Environment(\.navigator) private var navigator @Environment(\.currentScreenID) private var currentScreenID var viewCount: Int var onDismiss: () -> Void var body: some View { VStack { Text("View \(viewCount)") Button { navigator.go(to: ModalScreen(viewCount: viewCount + 1, onDismiss: onDismiss), on: currentScreenID) } label: { Text("Show new view") } Button { onDismiss() } label: { Text("dismiss all views") } } } }
[//]: I would expect the original screen to be fully visible and all of the modal views to be dismissed.
[//]:
The text was updated successfully, but these errors were encountered:
Hm, interesting. I will look into this. 🧐
Sorry, something went wrong.
No branches or pull requests
Bug description
[//]: # Using
goBack
to navigate back to a previous screen doesn't dismiss all of the views when each view is presented modally.Steps to reproduce
[//]: # Open a series of at least 3 modal views and then try to navigate back to the original view. One modal view will remain.
Expected behavior
[//]: I would expect the original screen to be fully visible and all of the modal views to be dismissed.
Screenshots
[//]:
Environment
The text was updated successfully, but these errors were encountered: