In the code below, for the #else
case, when I click Click to dismiss
, the button remains. But for the #if DISMISS_SUCCESSFULLY
case, clicking the button causes pops it of the navigation stack. Would you please help explain why the difference? Thank you.
Button("Click to navigate") {
myNavigate = true
}
.navigationDestination(isPresented: $myNavigate) {
#if DISMISS_SUCCESSFULLY
DismissButton()
#else
Button("Click it dismiss") {
print("Dismissing ...")
presentationMode.dismiss()
print("Done dismissing")
}
#endif
}
struct DismissButton: View {
//=== Local ===
@Environment(\.presentationMode) @Binding private var presentationMode
var body: some View {
Button("Click it dismiss") {
presentationMode.dismiss()
}
}
}