How Can I add multiple custom buttons in a list on swipe?
You can use swipeActions, but are only supported for target iOS >=15
https://developer.apple.com/documentation/swiftui/view/swipeactions(edge:allowsfullswipe:content:)
You can achieve that by using swipeActions modifier (iOS 15.0+), here is the example:
List {
ForEach(items, id: \.self) { item in
Text("Item N\(item)")
}
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
print("Delete")
} label: {
Text("Delete")
.foregroundColor(.white)
}
.tint(.red)
Button(role: .cancel) {
print("Edit")
} label: {
Text("Edit")
.foregroundColor(.white)
}
.tint(.gray)
}
}