struct ContentView: View {
@State private var itemSelection = Set<String>()
let names = [ "Orange", "Apple", "Grape", "Watermelon"]
var body: some View {
NavigationView {
VStack{
List(names, id: \.self, selection: $itemSelection) { name in
Text(name)
}
.navigationTitle("Item List")
.toolbar {
EditButton()
}
if !itemSelection.isEmpty {
Button("Deselect All"){
print("Items: \(itemSelection)")
itemSelection.removeAll()
}
.transition(AnyTransition.move(edge: .bottom))
}
}
.animation(.default, value: itemSelection.isEmpty)
}
}
}