Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5362e4e2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use the updated drag state in tiles that are not recomposed." into main

parents b844f252 789162db
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -158,18 +158,20 @@ private fun insertAfter(item: LazyGridItemInfo, offset: Offset): Boolean {
    return item.span != 1 && offset.x > itemCenter.x
}

@Composable
fun Modifier.dragAndDropTileSource(
    sizedTile: SizedTile<EditTileViewModel>,
    onTap: (TileSpec) -> Unit,
    onDoubleTap: (TileSpec) -> Unit,
    dragAndDropState: DragAndDropState
): Modifier {
    val state by rememberUpdatedState(dragAndDropState)
    return dragAndDropSource {
        detectTapGestures(
            onTap = { onTap(sizedTile.tile.tileSpec) },
            onDoubleTap = { onDoubleTap(sizedTile.tile.tileSpec) },
            onLongPress = {
                dragAndDropState.onStarted(sizedTile)
                state.onStarted(sizedTile)

                // The tilespec from the ClipData transferred isn't actually needed as we're moving
                // a tile within the same application. We're using a custom MIME type to limit the