Skip to content

Instantly share code, notes, and snippets.

@brindy
Created October 13, 2022 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brindy/75eba7b69e5bf49baa768aa8477cbf31 to your computer and use it in GitHub Desktop.
Save brindy/75eba7b69e5bf49baa768aa8477cbf31 to your computer and use it in GitHub Desktop.
struct ContentView: View {
let items = [
"Hello",
"World"
]
var body: some View {
NavigationView {
List {
ForEach(items, id: \.self) { item in
// In when "editMode" is active (ie delete and move of rows is possible)
// tapping the item does not go to the detail view.
NavigationLink(destination: Text("Detail \(item)")) {
Text(item)
}
}
.onMove { indexes, destination in
print("*** onMove", indexes, destination)
}
.onDelete { indexes in
print("*** onDelete", indexes)
}
}
}
.toolbar {
ToolbarItem(placement: .bottomBar) {
EditButton()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment