I have these 3 different views they all connect to each other through a NavigationView
. I am trying to find a way to navigate to a page earlier in the NavigationView
but I want the transition to seem like it is going backwards.
struct Testing: View {
var body: some View {
NavigationView {
VStack {
NavigationLink(destination:testing2()) { Text("Go to two") }
}
.navigationBarTitle("Navigation")
}
}
}
struct testing2 : View {
var body: some View{
VStack {
NavigationLink(destination: testing3()) { Text("Go to third") }
}
.navigationBarTitle("Second Page")
}
}
struct testing3 : View {
var body: some View{
VStack {
Text("Go back to first")
}
.navigationBarTitle("Third Page")
}
}
I have found a solution for this using a combination of an Observable Object, an Environment variable and tags and selections on the NavigationLink
.
Is their a simpler solution to making the navigation transition go to a specific page and if it is a view that is before the current view preform the backwards transition?
Much simpler solution is to modify your third view as following: