I am able to use the contextMenu guy to navigate to another View. Do I miss something?
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
FirstView()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct FirstView: View {
@State var goToSecond = false
var body: some View {
VStack {
Text("FirstView")
.contextMenu {
Button("Go to Second View") {
goToSecond.toggle()
}
}
}
.navigationDestination(isPresented: $goToSecond) {
SecondView()
}
}
}
struct SecondView: View {
var body: some View {
VStack {
Text("SecondView")
}
}
}