diff --git a/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt b/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt index 9abce65..3003cd8 100644 --- a/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt +++ b/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt @@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.absoluteOffset import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment @@ -15,9 +16,11 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawWithContent import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.drawscope.DrawScope +import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.layout.layout import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntOffset @@ -72,6 +75,7 @@ fun SwipeableActionsBox( } val scope = rememberCoroutineScope() + val hapticFeedback = LocalHapticFeedback.current Box( modifier = Modifier .onSizeChanged { state.layoutWidth = it.width } @@ -81,6 +85,7 @@ fun SwipeableActionsBox( enabled = !state.isResettingOnRelease, onDragStopped = { scope.launch { + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) state.handleOnDragStopped() } }, @@ -98,6 +103,12 @@ fun SwipeableActionsBox( content = { action.value.icon() } ) } + + if (state.hasCrossedSwipeThreshold()) { + LaunchedEffect(state.visibleAction) { + hapticFeedback.performHapticFeedback(HapticFeedbackType.TextHandleMove) + } + } } @Composable