In my case, a successful workaround has been moving my convenience modifier around navigationDestination to be used directly within the NavigationStack.
Broken example:
NavigationStack(path: $navModel.myFarmTabPath) {
MyRootScreen()
.appNavigationDestinations() // <- My wrapper around destination selection
}
Working example:
NavigationStack(path: $navModel.myFarmTabPath) {
MyRootScreen()
.navigationDestination(for: Screen.self) { screen in
return screen.representedDestination
}
}
To keep things tidy and allow for easier re-use in my tab views, I've added an extension to Screen which returns a destination:
extension Screen {
@ViewBuilder
var representedDestination: some View {
switch self {
case .screenOne:
ScreenOne()
case .screenTwo:
ScreenTwo()
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: