ListScopesKt

Added in 1.0.0-alpha02

public final class ListScopesKt


Summary

Public methods

static final void
<T extends Object> items(
    @NonNull ListScope receiver,
    @NonNull List<@NonNull T> items,
    Function1<@NonNull item, @NonNull Object> key,
    @NonNull Function1<@NonNull item, Object> contentType,
    @Composable @NonNull Function2<@NonNull ListItemScope, @NonNull item, Unit> itemContent
)

Adds a list of items.

static final void
<T extends Object> itemsIndexed(
    @NonNull ListScope receiver,
    @NonNull List<@NonNull T> items,
    Function2<@NonNull Integer, @NonNull item, @NonNull Object> key,
    @NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType,
    @Composable @NonNull Function3<@NonNull ListItemScope, @NonNull Integer, @NonNull item, Unit> itemContent
)

Adds a list of items where the content of an item is aware of its index.

Public methods

public static final void <T extends Object> items(
    @NonNull ListScope receiver,
    @NonNull List<@NonNull T> items,
    Function1<@NonNull item, @NonNull Object> key,
    @NonNull Function1<@NonNull item, Object> contentType,
    @Composable @NonNull Function2<@NonNull ListItemScope, @NonNull item, Unit> itemContent
)

Adds a list of items.

Parameters
@NonNull List<@NonNull T> items

the data list

Function1<@NonNull item, @NonNull Object> key

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. This can be overridden by calling 'requestScrollToItem' on the 'ListState'.

@NonNull Function1<@NonNull item, Object> contentType

a factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.

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

the content displayed by a single item

itemsIndexed

public static final void <T extends Object> itemsIndexed(
    @NonNull ListScope receiver,
    @NonNull List<@NonNull T> items,
    Function2<@NonNull Integer, @NonNull item, @NonNull Object> key,
    @NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType,
    @Composable @NonNull Function3<@NonNull ListItemScope, @NonNull Integer, @NonNull item, Unit> itemContent
)

Adds a list of items where the content of an item is aware of its index.

Parameters
@NonNull List<@NonNull T> items

the data list

Function2<@NonNull Integer, @NonNull item, @NonNull Object> key

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. This can be overridden by calling 'requestScrollToItem' on the 'ListState'.

@NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType

a factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.

@Composable @NonNull Function3<@NonNull ListItemScope, @NonNull Integer, @NonNull item, Unit> itemContent

the content displayed by a single item