Fix unreliable allow multiple votes toggle.

This commit is contained in:
Michelle Tang
2025-12-15 11:30:37 -05:00
committed by jeffrey-signal
parent 3e54cc5c77
commit e4ec538f13

View File

@@ -21,6 +21,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.PointerInputChange
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.zIndex
@@ -127,11 +128,13 @@ internal constructor(
draggingItemInitialOffset = 0
}
internal fun onDrag(offset: Offset) {
internal fun onDrag(offset: Offset, change: PointerInputChange) {
if ((includeHeader && draggingItemIndex == 0) ||
(includeFooter && draggingItemIndex == (state.layoutInfo.totalItemsCount - 1))
) return
change.consume()
draggingItemDraggedDelta += offset.y
val draggingItem = draggingItemLayoutInfo ?: return
@@ -203,8 +206,7 @@ fun Modifier.dragContainer(
return pointerInput(dragDropState) {
detectDragGestures(
onDrag = { change, offset ->
change.consume()
dragDropState.onDrag(offset = offset)
dragDropState.onDrag(offset = offset, change = change)
},
onDragStart = { offset -> dragDropState.onDragStart(offset) },
onDragEnd = { dragDropState.onDragEnd() },