I am using the swipe action library to add swipeable actions to a card. I need to detect when the user swipes the card, so I am using the swipeState property. However, whenever I access or modify swipeState, the swipe action collapses or hides unexpectedly.
Steps to Reproduce:
Add a swipe action to a card using .addSwipeAction(menu: .swiped, edge: .leading, state: $swipeState).
Use swipeState to track the swipe state or perform an action (e.g., in an onChange modifier).
Observe that the swipe action hides or collapses when swipeState is accessed or modified.
Expected Behavior:
The swipe action should remain visible and functional when swipeState is accessed or modified. I should be able to track the swipe state without the swipe action collapsing.
Actual Behavior:
The swipe action hides or collapses when swipeState is accessed or modified.
Code Example:
.addSwipeAction(menu: .swiped, edge: .leading, state: $swipeState) {
if !isSwipeActionHidden {
swipeActionView(id: transaction.id, result: transaction.allowedActions)
}
}
.onChange(of: swipeState) { newState in
print("Swipe state changed to: \(newState)")
// This causes the swipe action to hide
}
Additional Context:
I need to know when the user swipes the card to perform specific actions.
The issue occurs regardless of whether swipeState is accessed directly or through a binding.
I am using the swipe action library to add swipeable actions to a card. I need to detect when the user swipes the card, so I am using the swipeState property. However, whenever I access or modify swipeState, the swipe action collapses or hides unexpectedly.
Steps to Reproduce:
Add a swipe action to a card using .addSwipeAction(menu: .swiped, edge: .leading, state: $swipeState).
Use swipeState to track the swipe state or perform an action (e.g., in an onChange modifier).
Observe that the swipe action hides or collapses when swipeState is accessed or modified.
Expected Behavior:
The swipe action should remain visible and functional when swipeState is accessed or modified. I should be able to track the swipe state without the swipe action collapsing.
Actual Behavior:
The swipe action hides or collapses when swipeState is accessed or modified.
Code Example:
Additional Context:
I need to know when the user swipes the card to perform specific actions.
The issue occurs regardless of whether swipeState is accessed directly or through a binding.