Tweak room list behaviour:

- Instead of an extra item, use `contentPadding`.
- Make sure each item has an unique id.
This commit is contained in:
Jorge Martín 2024-02-02 13:05:37 +01:00
parent ee5f30d0d9
commit 9783dee537

View file

@ -20,6 +20,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.consumeWindowInsets import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
@ -220,7 +221,6 @@ private fun RoomListContent(
) )
}, },
content = { padding -> content = { padding ->
println(state.roomList)
if (state.roomList is AsyncData.Success && state.roomList.data.isEmpty()) { if (state.roomList is AsyncData.Success && state.roomList.data.isEmpty()) {
EmptyRoomListView(onCreateRoomClicked) EmptyRoomListView(onCreateRoomClicked)
} else { } else {
@ -230,6 +230,8 @@ private fun RoomListContent(
.consumeWindowInsets(padding) .consumeWindowInsets(padding)
.nestedScroll(nestedScrollConnection), .nestedScroll(nestedScrollConnection),
state = lazyListState, state = lazyListState,
// FAB height is 56dp, bottom padding is 16dp, we add 8dp as extra margin -> 56+16+8 = 80
contentPadding = PaddingValues(bottom = 80.dp)
) { ) {
when { when {
state.displayVerificationPrompt -> { state.displayVerificationPrompt -> {
@ -260,6 +262,7 @@ private fun RoomListContent(
itemsIndexed( itemsIndexed(
items = roomList, items = roomList,
contentType = { _, room -> room.contentType() }, contentType = { _, room -> room.contentType() },
key = { _, room -> room.roomId.value }
) { index, room -> ) { index, room ->
RoomSummaryRow( RoomSummaryRow(
room = room, room = room,
@ -270,11 +273,6 @@ private fun RoomListContent(
HorizontalDivider() HorizontalDivider()
} }
} }
// Add a last Spacer item to ensure that the FAB does not hide the last room item
// FAB height is 56dp, bottom padding is 16dp, we add 8dp as extra margin -> 56+16+8 = 80
item {
Spacer(modifier = Modifier.height(80.dp))
}
} }
} }
}, },