diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ImageListViewModel.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ImageListViewModel.kt index 8845b9d..33de70c 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ImageListViewModel.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ImageListViewModel.kt @@ -33,5 +33,5 @@ class ImageListViewModel : ViewModel() { } } - fun canDragOver(pos: ItemPosition) = images.any { it == pos.key } + fun canDragOver(draggedOver: ItemPosition, dragging: ItemPosition) = images.any { it == draggedOver.key } } \ No newline at end of file diff --git a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderListViewModel.kt b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderListViewModel.kt index e7da5f1..68f97f8 100644 --- a/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderListViewModel.kt +++ b/android/src/main/kotlin/org/burnoutcrew/android/ui/reorderlist/ReorderListViewModel.kt @@ -39,5 +39,5 @@ class ReorderListViewModel : ViewModel() { } } - fun isDogDragEnabled(pos: ItemPosition) = dogs.getOrNull(pos.index)?.isLocked != true + fun isDogDragEnabled(draggedOver: ItemPosition, dragging: ItemPosition) = dogs.getOrNull(draggedOver.index)?.isLocked != true } \ No newline at end of file diff --git a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyGridState.kt b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyGridState.kt index b51498d..b803861 100644 --- a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyGridState.kt +++ b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyGridState.kt @@ -33,7 +33,7 @@ import kotlinx.coroutines.CoroutineScope fun rememberReorderableLazyGridState( onMove: (ItemPosition, ItemPosition) -> Unit, gridState: LazyGridState = rememberLazyGridState(), - canDragOver: ((index: ItemPosition) -> Boolean)? = null, + canDragOver: ((draggedOver: ItemPosition, dragging: ItemPosition) -> Boolean)? = null, onDragEnd: ((startIndex: Int, endIndex: Int) -> (Unit))? = null, maxScrollPerFrame: Dp = 20.dp, dragCancelledAnimation: DragCancelledAnimation = SpringDragCancelledAnimation() @@ -62,7 +62,7 @@ class ReorderableLazyGridState( scope: CoroutineScope, maxScrollPerFrame: Float, onMove: (fromIndex: ItemPosition, toIndex: ItemPosition) -> (Unit), - canDragOver: ((index: ItemPosition) -> Boolean)? = null, + canDragOver: ((draggedOver: ItemPosition, dragging: ItemPosition) -> Boolean)? = null, onDragEnd: ((startIndex: Int, endIndex: Int) -> (Unit))? = null, dragCancelledAnimation: DragCancelledAnimation = SpringDragCancelledAnimation() ) : ReorderableState(scope, maxScrollPerFrame, onMove, canDragOver, onDragEnd, dragCancelledAnimation) { diff --git a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyListState.kt b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyListState.kt index cde660e..a9dae61 100644 --- a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyListState.kt +++ b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableLazyListState.kt @@ -37,7 +37,7 @@ import kotlinx.coroutines.CoroutineScope fun rememberReorderableLazyListState( onMove: (ItemPosition, ItemPosition) -> Unit, listState: LazyListState = rememberLazyListState(), - canDragOver: ((index: ItemPosition) -> Boolean)? = null, + canDragOver: ((draggedOver: ItemPosition, dragging: ItemPosition) -> Boolean)? = null, onDragEnd: ((startIndex: Int, endIndex: Int) -> (Unit))? = null, maxScrollPerFrame: Dp = 20.dp, dragCancelledAnimation: DragCancelledAnimation = SpringDragCancelledAnimation() @@ -72,7 +72,7 @@ class ReorderableLazyListState( scope: CoroutineScope, maxScrollPerFrame: Float, onMove: (fromIndex: ItemPosition, toIndex: ItemPosition) -> (Unit), - canDragOver: ((index: ItemPosition) -> Boolean)? = null, + canDragOver: ((draggedOver: ItemPosition, dragging: ItemPosition) -> Boolean)? = null, onDragEnd: ((startIndex: Int, endIndex: Int) -> (Unit))? = null, dragCancelledAnimation: DragCancelledAnimation = SpringDragCancelledAnimation() ) : ReorderableState( diff --git a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt index abc015b..1dc98b5 100644 --- a/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt +++ b/reorderable/src/commonMain/kotlin/org/burnoutcrew/reorderable/ReorderableState.kt @@ -40,7 +40,7 @@ abstract class ReorderableState( private val scope: CoroutineScope, private val maxScrollPerFrame: Float, private val onMove: (fromIndex: ItemPosition, toIndex: ItemPosition) -> (Unit), - private val canDragOver: ((index: ItemPosition) -> Boolean)?, + private val canDragOver: ((draggedOver: ItemPosition, dragging: ItemPosition) -> Boolean)?, private val onDragEnd: ((startIndex: Int, endIndex: Int) -> (Unit))?, val dragCancelledAnimation: DragCancelledAnimation ) { @@ -205,7 +205,7 @@ abstract class ReorderableState( ) { return@fastForEach } - if (canDragOver?.invoke(ItemPosition(item.itemIndex, item.itemKey)) != false) { + if (canDragOver?.invoke(ItemPosition(item.itemIndex, item.itemKey), ItemPosition(selected.itemIndex, selected.itemKey)) != false) { val dx = (centerX - (item.left + item.right) / 2).absoluteValue val dy = (centerY - (item.top + item.bottom) / 2).absoluteValue val dist = dx * dx + dy * dy