LazyDragSelectHorizontalGrid
A wrapper for LazyHorizontalGrid that provides drag selection functionality.
You can use LazyDragSelectGridItemScope.SelectableItem to wrap your item composable to make it selectable via a long press, or when selected via the drag-select.
Example usage:
@Composable
fun MyGrid() {
val items: List<Int> = List(100) { it }
val dragSelectState = rememberDragSelectState<Int>()
LazyDragSelectHorizontalGrid(
rows = GridCells.Adaptive(minSize = 128.dp),
items = items,
state = dragSelectState,
horizontalArrangement = Arrangement.spacedBy(3.dp),
verticalArrangement = Arrangement.spacedBy(3.dp),
) {
items { item ->
// SelectableItem is available on the grid scope
SelectableItem(item = item) { selected ->
// your item composable
}
}
}
}
Parameters
The type of item in the grid.
a class describing how cells form rows, see GridCells doc for more information.
the modifier to apply to this layout.
the state object to be used to control or observe the list's state.
specify a padding around the whole content.
reverse the direction of scrolling and layout. When true
, items will be laid out in the reverse order and LazyGridState.firstVisibleItemIndex == 0
means that grid is scrolled to the bottom. Note that reverseLayout does not change the behavior of verticalArrangement.
The vertical arrangement of the layout's children.
The horizontal arrangement of the layout's children.
logic describing fling behavior.
whether the scrolling via the user gestures or accessibility actions is allowed. You can still scroll programmatically using the state even when it is disabled.
whether to enable auto scroll when dragging outside of the grid.
the threshold in dp from the edge of the grid to start auto scroll.
whether to enable haptic feedback when dragging outside of the grid.
the haptic feedback to be played when dragging outside of the grid.
the LazyGridScope which describes the content.