I have an existing app that uses NavigationSplitView with a detail view that is never changed and just updates to show changes in data. All navigation changes the sidebar only using NavigationLinks with .isDetailLink(false).
Now I'm wanting to use NavigationPath with a simple router and enums.
import SwiftUI
@main
struct NavRouterApp: App {
@State private var router = Router()
var body: some Scene {
WindowGroup {
NavigationStack(path: $router.navPath) {
ContentView()
.navigationDestination(for: AppRoute.self) { route in
switch route {
case .citizens:
ContentView()
.environment(router)
case .citizen:
EmptyView()
.environment(router)
case .tasform2:
TASForm2View()
.environment(router)
case .start:
StartView()
.environment(router)
case .editcharacteristics:
EmptyView()
.environment(router)
case .basicdata(let citizen):
BasicDataView(citizen: citizen)
.environment(router)
.navigationBarBackButtonHidden(true)
case .characteristics:
EmptyView()
.environment(router)
}
}
}
.environment(router)
}
}
}
The problem is that pushing a subview now replaces the entire content instead of just the sidebar.
Pushing a subview with NavigationSplitView would update the sidebar as desired but I would have to replace the detail view, which is not a good idea.
I haven't been able to find any way to accomplish what I want. Suggestions?