StackScope


public sealed interface StackScope


Receiver scope used by VerticalStack that defines a DSL for adding items to the stack.

Summary

Public methods

abstract void
item(
    Object key,
    @Composable @NonNull Function1<@NonNull StackItemScopeUnit> content
)

Adds a single item.

abstract void
items(
    int count,
    Function1<@NonNull Integer, @NonNull Object> key,
    @Composable @NonNull Function2<@NonNull StackItemScope, @NonNull IntegerUnit> itemContent
)

Adds a count of items.

Extension functions

default final void
<T extends Object> StackScopeKt.items(
    @NonNull StackScope receiver,
    @NonNull List<@NonNull T> items,
    Function1<@NonNull item, @NonNull Object> key,
    @Composable @NonNull Function2<@NonNull StackItemScope, @NonNull item, Unit> itemContent
)

Adds a list of items.

Public methods

item

Added in 1.0.0-alpha01
abstract void item(
    Object key,
    @Composable @NonNull Function1<@NonNull StackItemScopeUnit> content
)

Adds a single item.

Parameters
Object key

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.

@Composable @NonNull Function1<@NonNull StackItemScopeUnit> content

the content of the item

items

Added in 1.0.0-alpha01
abstract void items(
    int count,
    Function1<@NonNull Integer, @NonNull Object> key,
    @Composable @NonNull Function2<@NonNull StackItemScope, @NonNull IntegerUnit> itemContent
)

Adds a count of items.

Parameters
int count

the item count

Function1<@NonNull Integer, @NonNull Object> key

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.

@Composable @NonNull Function2<@NonNull StackItemScope, @NonNull IntegerUnit> itemContent

the content displayed by a single item

Extension functions

StackScopeKt.items

default final void <T extends Object> StackScopeKt.items(
    @NonNull StackScope receiver,
    @NonNull List<@NonNull T> items,
    Function1<@NonNull item, @NonNull Object> key,
    @Composable @NonNull Function2<@NonNull StackItemScope, @NonNull item, Unit> itemContent
)

Adds a list of items.

Parameters
@NonNull List<@NonNull T> items

the list of item data

Function1<@NonNull item, @NonNull Object> key

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.

@Composable @NonNull Function2<@NonNull StackItemScope, @NonNull item, Unit> itemContent

the content displayed by a single item