Replies: 1 comment 1 reply
-
Hi @oskarek, right now our tools are focused on building the simplest and most extensible experience for driving navigation from state, while trying to stay true to UIKit's and SwiftUI's APIs. The code you have sketched is something that could be built on top of our tools, and maybe some day we will provide a tool like that, but we want to take is slow for the time being. To achieve a version of this in the tools we have today, you would do this: @Observable
class FeatureModel {
var destination: Destination?
@CasePathable
enum Destination {
case childA(ChildAModel)
case childB(ChildAModel)
case childC(ChildAModel)
}
}
…
present(item: $model.destination.childA) { model in
ChildAViewController(model: model)
}
navigationDestination(item: $model.destination.childB) { model in
ChildBViewController(model: model)
}
present(item: $model.destination.childC) { model in
ChildCViewController(model: model)
} This of course isn't exhaustive, but it gets the job done for the most part. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In the new navigation tools for UIKit, is there a way to exhaustively switch on a enum destination, and provide a navigation destination for each case, where some of the cases should be pushed and some should be presented?
A theoretical syntax that would accomplish this would look something like this:
which would be possible if there was a version of
navigationDestination
which took a closure that, instead of just returning a view controller, it returned a type which also decided how to present it. Something like:But maybe there is already a way to accomplish this with the current tools?
Beta Was this translation helpful? Give feedback.
All reactions