StackScope
sealed interface StackScope
Receiver scope used by VerticalStack that defines a DSL for adding items to the stack.
Summary
Public functions |
|
|---|---|
Unit |
item(key: Any?, content: @Composable StackItemScope.() -> Unit)Adds a single item. |
Unit |
items(Adds a |
Extension functions |
|
|---|---|
inline Unit |
<T : Any?> StackScope.items(Adds a list of items. |
Public functions
item
fun item(key: Any? = null, content: @Composable StackItemScope.() -> Unit): Unit
Adds a single item.
| Parameters | |
|---|---|
key: Any? = null |
a stable and unique key representing the item. If a key is specified, the scroll position will be maintained based on the key. If items are added/removed before the current visible item, the item with the given key will be kept as the first visible one. If null is passed, the position in the stack will represent the key. |
content: @Composable StackItemScope.() -> Unit |
the content of the item |
items
fun items(
count: Int,
key: ((index: Int) -> Any)? = null,
itemContent: @Composable StackItemScope.(Int) -> Unit
): Unit
Adds a count of items.
| Parameters | |
|---|---|
count: Int |
the item count |
key: ((index: Int) -> Any)? = null |
a factory of stable and unique keys representing the items. If a key is specified, the scroll position will be maintained based on the key. If items are added/removed before the current visible item, the item with the given key will be kept as the first visible one. If null is passed, the position in the stack will represent the key. |
itemContent: @Composable StackItemScope.(Int) -> Unit |
the content displayed by a single item |
Extension functions
items
inline fun <T : Any?> StackScope.items(
items: List<T>,
noinline key: ((item) -> Any)? = null,
crossinline itemContent: @Composable StackItemScope.(item) -> Unit
): Unit
Adds a list of items.
| Parameters | |
|---|---|
items: List<T> |
the list of item data |
noinline key: ((item) -> Any)? = null |
a factory of stable and unique keys representing the items. If a key is specified, the scroll position will be maintained based on the key. If items are added/removed before the current visible item, the item with the given key will be kept as the first visible one. If null is passed, the position in the stack will represent the key. |
crossinline itemContent: @Composable StackItemScope.(item) -> Unit |
the content displayed by a single item |