Created
December 13, 2023 14:06
-
-
Save teegarcs/4551676c62b1e0c060ff2cf1ab3e5d13 to your computer and use it in GitHub Desktop.
Extension function genericList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <Intent : Any> LazyListScope.genericList( | |
items: List<GenericLazyItem<Intent>>, | |
processIntent: (Intent) -> Unit | |
) { | |
items.forEachIndexed { index, genericLazyItem -> | |
/* | |
Draw Header if the section is different than the previous one. | |
*/ | |
if (index == 0 || genericLazyItem.sectionMatcher() != items[index - 1].sectionMatcher()) { | |
stickyHeader { | |
genericLazyItem.BuildHeaderItem(processIntent = processIntent) | |
} | |
} | |
/* | |
Calls the BuildItem function and provides the process Intent function. | |
*/ | |
item( | |
key = genericLazyItem.itemKey(), | |
contentType = genericLazyItem::class | |
) { | |
genericLazyItem.BuildItem(processIntent = processIntent) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment