DragSelectState

class DragSelectState<Item>(initialSelection: List<Item>, val gridState: LazyGridState, compareSelector: (Item) -> Any, dragState: DragState)

A state object that can be hoisted to control and observe selected items.

In most cases, this will be created via rememberDragSelectState.

Parameters

Item

The type of the items in the list.

initialSelection

The initial selection of items.

gridState

The LazyGridState that will be used to control the items in the grid.

dragState

The current drag state.

compareSelector

A factory for selecting a property of Item to compare.

Constructors

Link copied to clipboard
constructor(gridState: LazyGridState, initialIndex: Int, initialSelection: List<Item>)

A state object that can be hoisted to control and observe selected items.

constructor(initialSelection: List<Item>, gridState: LazyGridState, compareSelector: (Item) -> Any, dragState: DragState)

Properties

Link copied to clipboard
Link copied to clipboard

Whether or not the grid is in selection mode.

Link copied to clipboard

The currently selected items.

Functions

Link copied to clipboard
fun addSelected(item: Item)

Adds the provided item to the selected items.

Link copied to clipboard
fun clear()

Clears the selected items.

Link copied to clipboard

Disables selection mode and clear selected items.

Link copied to clipboard

Enables selection mode with no items selected.

Link copied to clipboard
fun isSelected(item: Item): Boolean

Whether or not the provided item is selected.

Link copied to clipboard
fun removeSelected(item: Item)

Removes the provided item from the selected items.

Link copied to clipboard

Toggle the selection mode.

Link copied to clipboard
fun updateSelected(selected: List<Item>)

Updates the selected items.