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

Commit a15e153a authored by Lucas Silva's avatar Lucas Silva
Browse files

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
parent b8dad2fb
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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,
+8 −2
Original line number Diff line number Diff line
@@ -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) }
    }
}