Goal:
When in EditMode, the user can tap on the Row (ForEach NavigationLink) and push a different view to the navigation view stack.
How do I accomplish this?
UPDATED: Full code example
import SwiftUI
import PlaygroundSupport
struct DetailView: View {
var body: some View {
Text("Hello World")
}
}
struct EditView: View {
var body: some View {
Text("Hello World")
}
}
struct ContentView: View {
@State var editMode: EditMode = .inactive
var body: some View {
NavigationView {
List {
Text("Testing EditMode")
if self.editMode == .active {
NavigationLink(
destination: EditView()) {
Text("Go To Edit View")
}
.padding()
} else {
NavigationLink(
destination: DetailView()) {
Text("Go To Detail View")
}
.padding()
}
}
.navigationBarTitle("EditMode Problem")
.navigationBarItems(trailing: EditButton())
.environment(\.editMode, $editMode)
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
1. This code is able to enable an EditButton, there is this weird animation between the two NavigationLink when the editMode state changes.
2. When editMode == .active, the row is not tapable. The goal is to enable the row to be tapable and enter a different view.