why can't you use @Environment(.presentationMode) var presentationMode this it's easy to navigate using Environment variables
not much complex and just need to add one variable rather than passing it to all along
this is the very simple example to use @Environment variable to navigate
struct HomeView: View {
var body: some View {
NavigationStack {
NavigationLink("Go to Detail", destination: DetailView())
}
}
}
struct DetailView: View {
@Environment(\.presentationMode) var presentationMode
var body: some View {
Button("Go Back") {
presentationMode.wrappedValue.dismiss()
}
}
}