Optimize lazy column

This commit is contained in:
Benoit Marty 2022-11-23 17:00:16 +01:00 committed by Benoit Marty
parent 4ddf216bee
commit 89224744e5
2 changed files with 28 additions and 3 deletions

View file

@ -122,7 +122,11 @@ fun RoomListContent(
.nestedScroll(nestedScrollConnection),
state = lazyListState,
) {
items(roomSummaries) { room ->
items(
items = roomSummaries,
contentType = { room -> room.contentType() },
key = { room -> room.key() },
) { room ->
RoomSummaryRow(room = room, onClick = ::onRoomClicked)
}
}
@ -134,6 +138,9 @@ fun RoomListContent(
}
}
private fun RoomListRoomSummary.key() = id
private fun RoomListRoomSummary.contentType() = isPlaceholder
private fun LazyListState.isScrolled(): Boolean {
return firstVisibleItemIndex > 0 || firstVisibleItemScrollOffset > 0
}