TabView + Destinations for navigation #1894
Unanswered
AndrewMalyhin
asked this question in
Q&A
Replies: 1 comment
-
I don't think you would want to use this Instead, I think it's better for a tab reducer to hold onto the state of all of its tabs: struct TabFeature: ReducerProtocol {
struct State {
var tab1 = Tab1Feature.State()
var tab2 = Tab2Feature.State()
var tab3 = Tab3Feature.State()
}
enum Action {
case tab1(Tab1Feature.Action)
case tab2(Tab2Feature.Action)
case tab3(Tab3Feature.Action)
}
var body: some ReducerProtocolOf<Self> {
// ...
Scope(state: \.tab1, action: Action.tab1) {
Tab1Feature()
}
Scope(state: \.tab2, action: Action.tab2) {
Tab2Feature()
}
Scope(state: \.tab3, action: Action.tab3) {
Tab3Feature()
}
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey!
Trying to learn from isowords codebase.
There is a nested struct called Destinations
public struct Destinations: ReducerProtocol
, and I see how it works with child states viapublic var destination: Destinations.State?
stored in a Parent state. Then you may send an action using tagcase setNavigation(tag: Destinations.State.Tag?)
from the View, and it all works.My question: is it possible to use this Destinations approach with TabView?
I doubt it since I have to provide all child Stores to child views in this method.
TabView(selection: <#T##Binding<Hashable>?#>, content: <#T##() -> View#>)
So it means that navigation will be split between Destinations and then some var in the parent state with tabbar Tag.
Should I treat Destinations as something that sends the user to a completely different view and TabView as a union view of its subviews and substates.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions