aheze / SwipeActions

Add customizable swipe actions to any view.

Home Page:https://twitter.com/aheze0/status/1646399867764510721

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detect Swipe Action Context State

anthony1810 opened this issue · comments

I need something like this to adjust SwipeView

SwipeView {
    teamNoteRow(note: note)
        .contentShape(Rectangle())
} trailingActions: { context in
    SwipeAction(action: {
        withAnimation {
            viewModel.deleteNote(id: note.id)
        }
    }, label: { _ in
        Image(systemName: "trash")
            .foregroundColor(Color.white)
    }, background: { _ in
        Color.red
    })
    .onReceive(context) { newValue in
        isTrailingActionVisible = context == .open // globaly detect state of swipe actions
}