Post

Replies

Boosts

Views

Activity

NavigationStack not working correctly in sheet
I am currently trying to build a NavigationManager with programmatic navigation. For that I'm using the NavigationPath combined with NavigationDestination. Sadly facing the following issue: navigationDestionation is not being recognised when located in sheet. Im receiving the following message when trying to update the path of the NavigationStack within the sheet. A NavigationLink is presenting a value of type “PathType” but there is no matching navigationDestination declaration visible from the location of the link. The link cannot be activated. Note: Links search for destinations in any surrounding NavigationStack, then within the same column of a NavigationSplitView. Here is some simplified code snipped of the implementation. struct RootView: View { @State private var isPresented: Bool = true var body: some View { Button("Open Modal", action: { self.isPresented.toggle() }) .sheet(isPresented: self.$isPresented, content: { ModalContent() }) } } private struct ModalContent: View { @State private var path = NavigationPath([PathType.configuration]) var body: some View { NavigationStack(path: self.$path) { VStack { Text("Placeholder") } .navigationDestination(for: PathType.self) { pathType in switch pathType { case .configuration: Text("Configuration") default: Color.red } } } } }
1
1
2.3k
May ’23
NavigationStack not working correctly in sheet
I am currently trying to build a NavigationManager with programmatic navigation. For that I'm using the NavigationPath combined with NavigationDestination. Sadly facing the following issue: navigationDestionation is not being recognised when located in sheet. Im receiving the following message when trying to update the path of the NavigationStack within the sheet. A NavigationLink is presenting a value of type “PathType” but there is no matching navigationDestination declaration visible from the location of the link. The link cannot be activated. Note: Links search for destinations in any surrounding NavigationStack, then within the same column of a NavigationSplitView. Here is some simplified code snipped of the implementation. struct RootView: View { @State private var isPresented: Bool = true var body: some View { Button("Open Modal", action: { self.isPresented.toggle() }) .sheet(isPresented: self.$isPresented, content: { ModalContent() }) } } private struct ModalContent: View { @State private var path = NavigationPath([PathType.configuration]) var body: some View { NavigationStack(path: self.$path) { VStack { Text("Placeholder") } .navigationDestination(for: PathType.self) { pathType in switch pathType { case .configuration: Text("Configuration") default: Color.red } } } } }
Replies
1
Boosts
1
Views
2.3k
Activity
May ’23