ResponsiveTransformingLazyColumnScope

sealed interface ResponsiveTransformingLazyColumnScope


Receiver scope for ResponsiveTransformingLazyColumn.

This scope extends TransformingLazyColumnScope by allowing you to specify the ResponsiveItemType for each item. This item type information is used by the parent component to automatically calculate and apply the correct responsive padding to the top and bottom of the list, adhering to Wear OS Material Design guidelines.

If contentPadding is provided to the ResponsiveTransformingLazyColumn, the maximum of the responsive padding and the provided contentPadding will be used.

Summary

Public functions

Unit
item(
    key: Any?,
    contentType: Any?,
    itemType: ResponsiveItemType,
    content: @Composable TransformingLazyColumnItemScope.() -> Unit
)

Adds a single item to the column, applying the padding according to the itemType.

Unit
items(
    count: Int,
    key: ((index: Int) -> Any)?,
    contentType: (index: Int) -> Any?,
    itemType: (index: Int) -> ResponsiveItemType,
    content: @Composable TransformingLazyColumnItemScope.(index: Int) -> Unit
)

Adds count items to the column, applying the padding according to the itemType.

Extension functions

inline Unit
<T : Any?> ResponsiveTransformingLazyColumnScope.items(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)?,
    crossinline contentType: (index: Int, item) -> Any?,
    crossinline itemType: (index: Int, item) -> ResponsiveItemType,
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(item) -> Unit
)

Adds a list of items.

inline Unit
<T : Any?> ResponsiveTransformingLazyColumnScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)?,
    crossinline contentType: (index: Int, item) -> Any?,
    crossinline itemType: (index: Int, item) -> ResponsiveItemType,
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(index: Int, item) -> Unit
)

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

Public functions

item

fun item(
    key: Any? = null,
    contentType: Any? = null,
    itemType: ResponsiveItemType = ResponsiveItemType.Default,
    content: @Composable TransformingLazyColumnItemScope.() -> Unit
): Unit

Adds a single item to the column, applying the padding according to the itemType.

Parameters
key: Any? = null

a stable and unique key representing the item. Using the same key for multiple items 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.

contentType: Any? = null

the type of the content of 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.

itemType: ResponsiveItemType = ResponsiveItemType.Default

the ResponsiveItemType of the content, e.g. ResponsiveItemType.Card. This type determines the responsive padding that will be added if this is the first or last item in the list. Defaults to ResponsiveItemType.Default.

content: @Composable TransformingLazyColumnItemScope.() -> Unit

the content of the item.

items

Added in 1.6.0-alpha07
fun items(
    count: Int,
    key: ((index: Int) -> Any)? = null,
    contentType: (index: Int) -> Any? = { null },
    itemType: (index: Int) -> ResponsiveItemType = { ResponsiveItemType.Default },
    content: @Composable TransformingLazyColumnItemScope.(index: Int) -> Unit
): Unit

Adds count items to the column, applying the padding according to the itemType.

Parameters
count: Int

the number of items.

key: ((index: Int) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items 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.

contentType: (index: Int) -> Any? = { null }

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.

itemType: (index: Int) -> ResponsiveItemType = { ResponsiveItemType.Default }

a factory to determine the ResponsiveItemType of the content based on the index. The types of the first and last items in the list determine the amount of responsive padding applied to the top and bottom of the list respectively. Defaults to ResponsiveItemType.Default.

content: @Composable TransformingLazyColumnItemScope.(index: Int) -> Unit

the content of the item. The item is aware of its position in the list.

Extension functions

inline fun <T : Any?> ResponsiveTransformingLazyColumnScope.items(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null },
    crossinline itemType: (index: Int, item) -> ResponsiveItemType = { _, _ -> ResponsiveItemType.Default },
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(item) -> Unit
): Unit

Adds a list of items.

Parameters
items: List<T>

the data list

noinline key: ((index: Int, item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the ResponsiveTransformingLazyColumn 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.

crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null }

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.

crossinline itemType: (index: Int, item) -> ResponsiveItemType = { _, _ -> ResponsiveItemType.Default }

a factory of the ResponsiveItemTypes for the item. The types of the first and last items in the list determine the amount of responsive padding applied to the top and bottom of the list respectively. Defaults to ResponsiveItemType.Default.

crossinline itemContent: @Composable TransformingLazyColumnItemScope.(item) -> Unit

the content displayed by a single item

inline fun <T : Any?> ResponsiveTransformingLazyColumnScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null },
    crossinline itemType: (index: Int, item) -> ResponsiveItemType = { _, _ -> ResponsiveItemType.Default },
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(index: Int, item) -> Unit
): Unit

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

Parameters
items: List<T>

the data list

noinline key: ((index: Int, item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the ResponsiveTransformingLazyColumn 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.

crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null }

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.

crossinline itemType: (index: Int, item) -> ResponsiveItemType = { _, _ -> ResponsiveItemType.Default }

a factory of the ResponsiveItemTypes for the item. The types of the first and last items in the list determine the amount of responsive padding applied to the top and bottom of the list respectively. Defaults to ResponsiveItemType.Default.

crossinline itemContent: @Composable TransformingLazyColumnItemScope.(index: Int, item) -> Unit

the content displayed by a single item