New issue
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
No way to know when a sheet is dismissed #14
Comments
Probably not as elegant as what you're proposing in #15, but if your For example: struct Coordinator: View {
@State var routes: Routes<Screen> = [.root(.home)]
var body: some View {
Router($routes) { screen, _ in
switch screen {
case .home:
HomeView(onComplete: { routes.presentSheet(.second) })
case .second:
SecondView(onComplete: { routes.presentSheet(.third) })
case .third:
ThirdView(onComplete: { ... })
}
}
.onChange(of: routes) { [routes] newValue in
print(routes) // old value
print(newValue) // new value
// compare the two values above to check whether a sheet got dismissed")
}
}
} |
Thanks Federico, that's a good workaround, we know everything from the routes |
#15 is now merged, so I'll close this issue. Thanks @lionel-alves for raising it. And thanks @zntfdr for your suggestion - I think I prefer that approach as each Route can remain a simple 'bag of values', and it's not much work to be notified when a route is dismissed, e.g.:
|
Hi, first of all thanks for making SwiftUI navigation easier with you library, it is the best approach I came across by far. As a big fan of coordinators, I think your approach is even better that with UIKit since it easy to have one coordinator for a small flow that can both push and present, very convenient!
My issue: Presenting sheets, there is no way to know when it is dismissed (the
onDismiss
on the native call is passed tonil
in you library). Exposing that would be very convenient as theonAppear
is not called for sheets (well known problem).Best regards
The text was updated successfully, but these errors were encountered: