yogaboy
02/09/2024, 10:57 AMval dismissState = rememberDismissState(
confirmValueChange = {
if (it == DismissValue.DismissedToStart) {
onEventSent(ListContract.Event.DeleteAction(item))
contentItems.remove(item)
}
true
}
)
to
val dismissState = rememberSwipeToDismissBoxState(
confirmValueChange = {})
SwipeToDismissBox(
state = dismissState,
but this generates me 2x event for swipe action. And I have to check
aka
val dismissState = rememberSwipeToDismissBoxState(
confirmValueChange = {
if (it == SwipeToDismissBoxValue.EndToStart && contentItems.contains(item)) {
onEventSent(ListContract.Event.DeleteAction(item))
contentItems.remove(item)
}
true
}
)
I didn’t find much documentation on how to use it correctly except that for wearables there is onDismissed
SwipeToDismissBox(
state = state,
onDismissed = {}
Could someone please help me how to do it correctly?jossiwolf
02/09/2024, 12:56 PMconfirmValueChange
is just a callback to indicate whether the component is allowed to move to a certain state, it should not be used to perform actions. Use a snapshotFlow
instead to listen for the state changes.yogaboy
02/13/2024, 8:35 AMjossiwolf
02/13/2024, 10:57 AMyogaboy
02/13/2024, 11:04 AM