Post not yet marked as solved
Post marked as unsolved with 1 replies, 1,510 views
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
}
}
}
}
}