I am trying to mimic the same behaviour that notes app does when deletes a note in swiftUI. I have this code, but I am still missing the delete button to expand to cover the width of the cell.
import SwiftUI
struct ItemStore {
var items: [String]
}
struct ContentView: View {
let itemStore = ItemStore(items: [
"Hi",
"Hello"
])
@State var showingAlert = false
var body: some View {
List {
ForEach(itemStore.items, id: \.self) { item in
Text("Item: \(item)")
.swipeActions() {
Button {
withAnimation { showingAlert.toggle() }
} label: {
Label("Delete", systemImage: "trash")
}
}
.tint(.red)
}
} /// alert goes here!
.alert("Important message", isPresented: $showingAlert) {
Button("First") { }
Button("Second") { }
}
}
}

this should work fine, also with the animations