SwiftUI Row swipeActions, is there a way to detect when the swipe occurs?

Viewed 30

I'm trying to log an interaction marker when a user swipes a list row. I'm able to do this when the user selects the action, but I'm not sure how to detect that just the swipe has occurred.

If I add .onAppear to one of the buttons, I can tell when it's swiped for the first time, but if that same row is swiped again, it won't trigger.

.swipeActions {
    Button {
        // do something
    } label: {
        Label("Flag", systemImage: "flag")
    }
    .onAppear {
        print("onAppear") // this only occurs first swipe
    }
0 Answers
Related