Вот моя попытка:
Код: Выделить всё
LazyColumn(
reverseLayout = true
) {
val itemCount = list.itemCount
var lastHeader: String? = null
for (index in 0 until itemCount) {
val item = list.peek(index)
val headerString = item?.date
if (item !== null && headerString != lastCharacter) {
stickyHeader(key = headerString) {
Text(
text = "Header: $headerString",
modifier = Modifier
.fillMaxWidth()
.background(Color.Red)
.padding(16.dp)
)
}
}
item(key = item?.communicationId) {
// Gets item, triggering page loads if needed
when (val item = list[index]) {
is Type1 -> {
[email protected] {
Type1Cell()
}
}
is Type2 -> {
[email protected] {
Type2Cell()
}
}
null -> {
[email protected] {
LoadingCell()
}
}
}
}
lastHeader = headerString
}
}
Код: Выделить всё
val items = viewModel.items.collectAsLazyPagingItems()
Подробнее здесь: https://stackoverflow.com/questions/792 ... ck-compose