summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Lucas Silva <lusilva@google.com> 2024-01-05 15:06:18 -0500
committer Lucas Silva <lusilva@google.com> 2024-01-05 15:11:39 -0500
commita15e153a8302d01cc0dbabdd9d65c5882e5226a0 (patch)
tree84b5d2c080b44d38f1c9c6bb83491c8f79a8a7fa
parentb8dad2fb07343854d86210b7399d384a2b9742b2 (diff)
Add placeholder when dragging items within the grid
Fixes: 318858580 Test: flashed and dragged widgets around the grid, verified outline shows up in target destination Flag: ACONFIG com.android.systemui.communal_hub DEVELOPMENT Change-Id: I3229470e93cbfe6dc8162c9a7b278e5fa59a8093
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt8
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/GridDragDropState.kt10
2 files changed, 14 insertions, 4 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 5a4e0a9cd5ce..54d702e79a19 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 @@ private fun BoxScope.CommunalHubLazyGrid(
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 0d460aa8d464..1b40de4ef5df 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 @@ fun LazyGridItemScope.DraggableItem(
dragDropState: GridDragDropState,
index: Int,
enabled: Boolean,
+ size: SizeF,
modifier: Modifier = Modifier,
content: @Composable (isDragging: Boolean) -> Unit
) {
@@ -250,7 +252,11 @@ fun LazyGridItemScope.DraggableItem(
} 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) }
}
}