Hi. I have a swiftui project with a list. I would now like to add 2 trailing swipe actions to this list, the .onDelete swipe action and a edit swipe action to the left of it. Like this:
To achieve this in swiftui I added the following code to my list:
List {
ForEach(timers, id: \.id) { timer in
TimerRow(timer: timer)
}
.onDelete(perform: { IndexSet in deleteTimer(IndexSet) })
.swipeActions(edge: .trailing, allowsFullSwipe: false) {
Button {
// Open edit sheet
isShowEditTimer.toggle()
} label: {
Image(systemName: "pencil.circle")
}
}
}
But unfortunately only the edit function is displayed now:
Do you know how I can solve my problem? But now to my real problem: I now want to open a modal sheet when the edit swipe action of a line is pressed. But how do I find out which line was swiped on? With the .onDelete function we get an IndexSet, but nothing here I would also like to give the struct that is called in my sheet this certain swiped element (CoreData object):
.sheet(isPresented: $isShowEditTimer) {
EditTimerView(timerObject: ???)
}
By the way, this sheet is applied to my navigation view. I would be really happy if someone could help me and if you didn't report my post. Maybe this question has been asked somewhere deep in StackOverflow, but I'm also relatively new to swiftui (always UIKit before) and don't understand every stackoverflow post yet. Thanks!!! 😀