Skip to content

Use with NavigationStack #12

@Xioshock

Description

@Xioshock

Can Help be used with NavigationStack within TabView? I'm struggling to understand, how to wire up the state of the stack to the helm.

Here is modified sample project that showcases what I want to do:

The Clips view has NavigationStack with "path" state that I would like to control with Help somehow.

`
struct TabExampleView: View {
@EnvironmentObject private var _helm: Helm

var body: some View {
    VStack {
        if let error = _helm.errors.last {
            Text("Error: \(error.localizedDescription)")
                .foregroundColor(.red)
                .padding()
        }
        TabView(selection: _helm.pickPresented([.users, .clips, .more])) {
            Text("Users view")
                .tabItem {
                    Image(systemName: "person.circle.fill")
                    Text("Users")
                }
                .tag(Optional.some(Screen.users))
            ClipsView()
                .tabItem {
                    Image(systemName: "paperclip.circle.fill")
                    Text("Clips")
                }
                .tag(Optional.some(Screen.clips))
            Text("More view")
                .tabItem {
                    Image(systemName: "ellipsis")
                    Text("More")
                }
                .tag(Optional.some(Screen.more))
        }
    }
}

}

struct ClipsView: View {
@EnvironmentObject private var _helm: Helm

@State private var path: [String] = []

var body: some View {
    NavigationStack(path: $path) {
        List {
            NavigationLink(value: "detail") {
                Text("Detail")
            }
        }
        .navigationDestination(for: String.self) { str in
            Text(str)
        }
    }
}

}
`

Thank you for any help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions