From b4de46604a9ab5005b4c0a3ee2c0fde48b74b80f Mon Sep 17 00:00:00 2001 From: Veyndan Stuart Date: Mon, 17 Apr 2023 17:25:18 +0200 Subject: [PATCH] Add LazyListScope#itemsIndexed --- .../cash/redwood/treehouse/lazylayout/compose/LazyDsl.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/redwood-treehouse-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/treehouse/lazylayout/compose/LazyDsl.kt b/redwood-treehouse-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/treehouse/lazylayout/compose/LazyDsl.kt index 8a6abe7ab7..7189c71bc8 100644 --- a/redwood-treehouse-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/treehouse/lazylayout/compose/LazyDsl.kt +++ b/redwood-treehouse-lazylayout-compose/src/commonMain/kotlin/app/cash/redwood/treehouse/lazylayout/compose/LazyDsl.kt @@ -39,6 +39,15 @@ public inline fun LazyListScope.items( itemContent(items[it]) } +public inline fun LazyListScope.itemsIndexed( + items: List, + crossinline itemContent: @Composable (index: Int, item: T) -> Unit, +): Unit = items( + count = items.size, +) { + itemContent(it, items[it]) +} + public inline fun LazyListScope.items( items: Array, crossinline itemContent: @Composable (item: T) -> Unit,