View bindings with programmatic navigation links in SwiftUI #996
-
Hello all! I have an interesting challenge around programatic navigation links, similar to the picture above. Sometimes, you want navigation to happen as a result of a state change, rather than from pressing on the link itself. In SwiftUI this is easy; you can just create a nav link with no title that's hidden. The problem is, because there's no link that the user can tap, the I think the solution is easy but I wanted to get the core teams take on it. In this situation, I would just move those actions in the Do you have any suggestions on a better way to handle programmatic navigation links? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@thebarndog This seems like the general way to go about it, though it doesn't need to be driven by effects necessarily. As long as an action can mutate the state that determines if the link's binding is active or not, you will programmatically drive navigation. In vanilla SwiftUI, this is an observable object mutating published state associated with that binding. And in TCA, this is a reducer mutating state associated with the binding 😄 |
Beta Was this translation helpful? Give feedback.
@thebarndog This seems like the general way to go about it, though it doesn't need to be driven by effects necessarily. As long as an action can mutate the state that determines if the link's binding is active or not, you will programmatically drive navigation.
In vanilla SwiftUI, this is an observable object mutating published state associated with that binding.
And in TCA, this is a reducer mutating state associated with the binding 😄