diff options
| author | 2024-10-18 14:56:40 -0400 | |
|---|---|---|
| committer | 2024-10-18 15:07:49 -0400 | |
| commit | 7fd21a2d419ed53d62f98a5978cd83350e35332c (patch) | |
| tree | 79153d664cdf76913b2a6045578866e7a12a3102 | |
| parent | ff72c93091bb7cc9e861253cab845f506d531db5 (diff) | |
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
| -rw-r--r-- | packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt index 4ab526188ffe..ab8e8e696b26 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt @@ -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.animateItem( - placementSpec = spring(stiffness = Spring.StiffnessMediumLow) - ) - }, + 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( |