TvLazyGridScope

@TvLazyGridScopeMarker
sealed interface TvLazyGridScope


Receiver scope which is used by TvLazyVerticalGrid.

Summary

Public functions

Unit
item(
    key: Any?,
    span: (TvLazyGridItemSpanScope.() -> TvGridItemSpan)?,
    contentType: Any?,
    content: @Composable TvLazyGridItemScope.() -> Unit
)

This function is deprecated. Use `LazyGridScope.item` instead

Unit
items(
    count: Int,
    key: ((index: Int) -> Any)?,
    span: (TvLazyGridItemSpanScope.(index: Int) -> TvGridItemSpan)?,
    contentType: (index: Int) -> Any?,
    itemContent: @Composable TvLazyGridItemScope.(index: Int) -> Unit
)

This function is deprecated. Use `LazyGridScope.items` instead

Extension functions

inline Unit
<T : Any?> TvLazyGridScope.items(
    items: Array<T>,
    noinline key: ((item) -> Any)?,
    noinline span: (TvLazyGridItemSpanScope.(item) -> TvGridItemSpan)?,
    noinline contentType: (item) -> Any?,
    crossinline itemContent: @Composable TvLazyGridItemScope.(item) -> Unit
)

This function is deprecated. Use `LazyGridScope.items` instead.

inline Unit
<T : Any?> TvLazyGridScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)?,
    noinline span: (TvLazyGridItemSpanScope.(item) -> TvGridItemSpan)?,
    noinline contentType: (item) -> Any?,
    crossinline itemContent: @Composable TvLazyGridItemScope.(item) -> Unit
)

This function is deprecated. Use `LazyGridScope.items` instead

inline Unit
<T : Any?> TvLazyGridScope.itemsIndexed(
    items: Array<T>,
    noinline key: ((index: Int, item) -> Any)?,
    noinline span: (TvLazyGridItemSpanScope.(index: Int, item) -> TvGridItemSpan)?,
    crossinline contentType: (index: Int, item) -> Any?,
    crossinline itemContent: @Composable TvLazyGridItemScope.(index: Int, item) -> Unit
)

This function is deprecated. Use `LazyGridScope.itemsIndexed` instead.

inline Unit
<T : Any?> TvLazyGridScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)?,
    noinline span: (TvLazyGridItemSpanScope.(index: Int, item) -> TvGridItemSpan)?,
    crossinline contentType: (index: Int, item) -> Any?,
    crossinline itemContent: @Composable TvLazyGridItemScope.(index: Int, item) -> Unit
)

This function is deprecated. Use `LazyGridScope.itemsIndexed` instead.

Public functions

item

Added in 1.0.0-alpha11
Deprecated in 1.0.0-alpha11
fun item(
    key: Any? = null,
    span: (TvLazyGridItemSpanScope.() -> TvGridItemSpan)? = null,
    contentType: Any? = null,
    content: @Composable TvLazyGridItemScope.() -> Unit
): Unit

Adds a single item to the scope.

Parameters
key: Any? = null

a stable and unique key representing the item. Using the same key for multiple items in the grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid 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.

span: (TvLazyGridItemSpanScope.() -> TvGridItemSpan)? = null

the span of the item. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance

contentType: Any? = null

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

content: @Composable TvLazyGridItemScope.() -> Unit

the content of the item

items

Added in 1.0.0-alpha11
Deprecated in 1.0.0-alpha11
fun items(
    count: Int,
    key: ((index: Int) -> Any)? = null,
    span: (TvLazyGridItemSpanScope.(index: Int) -> TvGridItemSpan)? = null,
    contentType: (index: Int) -> Any? = { null },
    itemContent: @Composable TvLazyGridItemScope.(index: Int) -> Unit
): Unit

Adds a count of items.

Parameters
count: Int

the items count

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

a factory of stable and unique keys representing the item. Using the same key for multiple items in the grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid 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.

span: (TvLazyGridItemSpanScope.(index: Int) -> TvGridItemSpan)? = null

define custom spans for the items. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance

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.

itemContent: @Composable TvLazyGridItemScope.(index: Int) -> Unit

the content displayed by a single item

Extension functions

inline fun <T : Any?> TvLazyGridScope.items(
    items: Array<T>,
    noinline key: ((item) -> Any)? = null,
    noinline span: (TvLazyGridItemSpanScope.(item) -> TvGridItemSpan)? = null,
    noinline contentType: (item) -> Any? = { null },
    crossinline itemContent: @Composable TvLazyGridItemScope.(item) -> Unit
): Unit

Adds an array of items.

Parameters
items: Array<T>

the data array

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

a factory of stable and unique keys representing the item. Using the same key for multiple items in the grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid 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.

noinline span: (TvLazyGridItemSpanScope.(item) -> TvGridItemSpan)? = null

define custom spans for the items. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance

noinline contentType: (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 itemContent: @Composable TvLazyGridItemScope.(item) -> Unit

the content displayed by a single item

inline fun <T : Any?> TvLazyGridScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)? = null,
    noinline span: (TvLazyGridItemSpanScope.(item) -> TvGridItemSpan)? = null,
    noinline contentType: (item) -> Any? = { null },
    crossinline itemContent: @Composable TvLazyGridItemScope.(item) -> Unit
): Unit

Adds a list of items.

Parameters
items: List<T>

the data list

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

a factory of stable and unique keys representing the item. Using the same key for multiple items in the grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid 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.

noinline span: (TvLazyGridItemSpanScope.(item) -> TvGridItemSpan)? = null

define custom spans for the items. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance

noinline contentType: (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 itemContent: @Composable TvLazyGridItemScope.(item) -> Unit

the content displayed by a single item

itemsIndexed

inline fun <T : Any?> TvLazyGridScope.itemsIndexed(
    items: Array<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    noinline span: (TvLazyGridItemSpanScope.(index: Int, item) -> TvGridItemSpan)? = null,
    crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null },
    crossinline itemContent: @Composable TvLazyGridItemScope.(index: Int, item) -> Unit
): Unit

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

Parameters
items: Array<T>

the data array

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 grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid 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.

noinline span: (TvLazyGridItemSpanScope.(index: Int, item) -> TvGridItemSpan)? = null

define custom spans for the items. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance

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 itemContent: @Composable TvLazyGridItemScope.(index: Int, item) -> Unit

the content displayed by a single item

itemsIndexed

inline fun <T : Any?> TvLazyGridScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    noinline span: (TvLazyGridItemSpanScope.(index: Int, item) -> TvGridItemSpan)? = null,
    crossinline contentType: (index: Int, item) -> Any? = { _, _ -> null },
    crossinline itemContent: @Composable TvLazyGridItemScope.(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 grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid 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.

noinline span: (TvLazyGridItemSpanScope.(index: Int, item) -> TvGridItemSpan)? = null

define custom spans for the items. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance

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 itemContent: @Composable TvLazyGridItemScope.(index: Int, item) -> Unit

the content displayed by a single item