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

Commit 6307029a authored by Bryce Lee's avatar Bryce Lee Committed by Android (Google) Code Review
Browse files

Merge "Do not show remove button unless item is selected or reordering." into main

parents c47d0540 47b1c542
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -108,7 +108,12 @@ internal constructor(
    private val draggingItemLayoutInfo: LazyGridItemInfo?
        get() = state.layoutInfo.visibleItemsInfo.firstOrNull { it.index == draggingItemIndex }

    internal fun onDragStart(offset: Offset, contentOffset: Offset) {
    /**
     * Called when dragging is initiated.
     *
     * @return {@code True} if dragging a grid item, {@code False} otherwise.
     */
    internal fun onDragStart(offset: Offset, contentOffset: Offset): Boolean {
        state.layoutInfo.visibleItemsInfo
            .filter { item -> contentListState.isItemEditable(item.index) }
            // grid item offset is based off grid content container so we need to deduct
@@ -118,7 +123,10 @@ internal constructor(
                dragStartPointerOffset = offset - this.offset.toOffset()
                draggingItemIndex = index
                draggingItemInitialOffset = this.offset.toOffset()
                return true
            }

        return false
    }

    internal fun onDragInterrupted() {
@@ -216,8 +224,9 @@ fun Modifier.dragContainer(
                    dragDropState.onDrag(offset = offset)
                },
                onDragStart = { offset ->
                    dragDropState.onDragStart(offset, contentOffset)
                    if (dragDropState.onDragStart(offset, contentOffset)) {
                        viewModel.onReorderWidgetStart()
                    }
                },
                onDragEnd = {
                    dragDropState.onDragInterrupted()