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

Commit 3844e718 authored by Coco Duan's avatar Coco Duan Committed by Android (Google) Code Review
Browse files

Merge "Fix bug with adding widgets via drag&drop when GH is empty" into main

parents df2fd69e 9248717a
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -250,7 +250,6 @@ fun CommunalHub(
                            )
                        isDraggingToRemove
                    },
                    onOpenWidgetPicker = onOpenWidgetPicker,
                    gridState = gridState,
                    contentListState = contentListState,
                    selectedKey = selectedKey,
@@ -393,7 +392,6 @@ private fun BoxScope.CommunalHubLazyGrid(
    contentListState: ContentListState,
    setGridCoordinates: (coordinates: LayoutCoordinates) -> Unit,
    updateDragPositionForRemove: (offset: Offset) -> Boolean,
    onOpenWidgetPicker: (() -> Unit)? = null,
    widgetConfigurator: WidgetConfigurator?,
) {
    var gridModifier =
@@ -461,7 +459,6 @@ private fun BoxScope.CommunalHubLazyGrid(
                        model = list[index],
                        viewModel = viewModel,
                        size = size,
                        onOpenWidgetPicker = onOpenWidgetPicker,
                        selected = selected && !isDragging,
                        widgetConfigurator = widgetConfigurator,
                    )
@@ -739,7 +736,6 @@ private fun CommunalContent(
    size: SizeF,
    selected: Boolean,
    modifier: Modifier = Modifier,
    onOpenWidgetPicker: (() -> Unit)? = null,
    widgetConfigurator: WidgetConfigurator? = null,
) {
    when (model) {
+2 −2
Original line number Diff line number Diff line
@@ -161,9 +161,9 @@ internal class DragAndDropTargetState(
    private var isOnRemoveButton = false

    fun onStarted() {
        // assume item will be added to the second to last position before CTA tile.
        // assume item will be added to the end.
        contentListState.list.add(placeHolder)
        placeHolderIndex = contentListState.list.size - 1
        placeHolderIndex?.let { contentListState.list.add(it, placeHolder) }
    }

    fun onMoved(event: DragAndDropEvent) {
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ constructor(

    override val isEditMode = true

    // Only widgets are editable. The CTA tile comes last in the list and remains visible.
    // Only widgets are editable.
    override val communalContent: Flow<List<CommunalContentModel>> =
        communalInteractor.widgetContent.onEach { models ->
            logger.d({ "Content updated: $str1" }) { str1 = models.joinToString { it.key } }