Given a List view with an EditButton() in there, if the view is being edited (user tapped the Edit button), how can one disable the edit mode programmatically when the user navigates away from the view? (e.g. similar behavior to the Favorites view in the Phone app on the iPhone)
struct ContentView2: View {
@State var fruits = ["Apple", "Banana"]
var body: some View {
NavigationView {
List {
ForEach(fruits, id: \.self) { fruit in
Text(fruit)
}
.onDelete { _ in
print("Delete")
}
}
.toolbar {
EditButton()
}
}
.onDisappear {
// make List's editMode be .inactive; how?
}
}
}