Merge "Add placeholder when dragging items within the grid" into main
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 fff1410..8bd5ddb 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
@@ -205,8 +205,12 @@
list[index].size.dp().value,
)
if (viewModel.isEditMode && dragDropState != null) {
- DraggableItem(dragDropState = dragDropState, enabled = true, index = index) {
- isDragging ->
+ DraggableItem(
+ dragDropState = dragDropState,
+ enabled = true,
+ index = index,
+ size = size
+ ) { isDragging ->
val elevation by animateDpAsState(if (isDragging) 4.dp else 1.dp)
CommunalContent(
modifier = cardModifier,
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
index 0d460aa8..1b40de4 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt
@@ -16,6 +16,7 @@
package com.android.systemui.communal.ui.compose
+import android.util.SizeF
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.detectDragGesturesAfterLongPress
import androidx.compose.foundation.gestures.scrollBy
@@ -233,6 +234,7 @@
dragDropState: GridDragDropState,
index: Int,
enabled: Boolean,
+ size: SizeF,
modifier: Modifier = Modifier,
content: @Composable (isDragging: Boolean) -> Unit
) {
@@ -250,7 +252,11 @@
} else {
Modifier.animateItemPlacement()
}
- Box(modifier = modifier.then(draggingModifier), propagateMinConstraints = true) {
- content(dragging)
+
+ Box(modifier) {
+ if (dragging) {
+ WidgetPlaceholderContent(size)
+ }
+ Box(modifier = draggingModifier, propagateMinConstraints = true) { content(dragging) }
}
}