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

Commit 7fd21a2d authored by Lucas Silva's avatar Lucas Silva
Browse files

Ensure item being dragged shows on top of other items

The item being dragged should draw on top of other items in the grid.

Bug: 368056271
Test: manually by reordering items in the grid using the drag gesture
Flag: EXEMPT bugfix
Change-Id: Ia39444d84a01f014d46b64fb675011f80af27f30
parent ff72c930
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ import androidx.compose.ui.unit.times
import androidx.compose.ui.util.fastAll
import androidx.compose.ui.viewinterop.AndroidView
import androidx.compose.ui.viewinterop.NoOpUpdate
import androidx.compose.ui.zIndex
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.window.layout.WindowMetricsCalculator
import com.android.compose.animation.Easings.Emphasized
@@ -749,6 +750,7 @@ private fun BoxScope.CommunalHubLazyGrid(
            val dpSize = DpSize(size.width.dp, size.height.dp)

            if (viewModel.isEditMode && dragDropState != null) {
                val isItemDragging = dragDropState.draggingItemKey == item.key
                val outlineAlpha by
                    animateFloatAsState(
                        targetValue = if (selected) 1f else 0f,
@@ -764,13 +766,13 @@ private fun BoxScope.CommunalHubLazyGrid(
                    enabled = selected,
                    alpha = { outlineAlpha },
                    modifier =
                        Modifier.requiredSize(dpSize).thenIf(
                            dragDropState.draggingItemKey != item.key
                        ) {
                        Modifier.requiredSize(dpSize)
                            .thenIf(!isItemDragging) {
                                Modifier.animateItem(
                                    placementSpec = spring(stiffness = Spring.StiffnessMediumLow)
                                )
                        },
                            }
                            .thenIf(isItemDragging) { Modifier.zIndex(1f) },
                    onResize = { resizeInfo -> contentListState.resize(index, resizeInfo) },
                ) { modifier ->
                    DraggableItem(