Problem: I Have no NavigationBar on my RootViewController. But when I navigate two steps into the navigationstack or further from my RootViewController and I pop back from there to my RootViewController. I get a navigationBar that should not exist or be there.
This is the code that I'm trying to fix it on right now
import SwiftUI
struct DemoPop: View {
@State private var path = NavigationPath()
var body: some View {
VStack {
NavigationStack(path: $path) {
List {
Section("List One") {
NavigationLink("Navigate to View 1", value: "View 1")
NavigationLink("Navigate to View 2", value: "View 2")
}
}
.navigationDestination(for: String.self) { textDesc in
VStack {
Text(textDesc).padding()
Button("Navigate to View 3") {
path.append("View 3")
}.padding()
Button("Pop to Root View") {
path.removeLast(path.count)
}.padding()
}
}
.navigationTitle("Test Pop To Root")
}
}
}
}
struct DemoPop_Previews: PreviewProvider {
static var previews: some View {
DemoPop()
}
}
I have tried a few different ways like building a router class and navigating through that to get rid of this but I have not succeeded yet, last thing I tried I just took some easy, readable code from stacked to figure out the problem. But no luck so far.