feat: add support for unread message and room highlighting #49

Merged
reya merged 2 commits from feat/new-message-ui into master 2026-07-21 03:44:54 +00:00
Showing only changes of commit 13a7ee942d - Show all commits

View File

@@ -25,6 +25,8 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Badge
import androidx.compose.material3.BadgedBox
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
@@ -662,22 +664,32 @@ fun NewRequests(requests: List<Room>) {
navigator.navigate(Screen.RequestList) navigator.navigate(Screen.RequestList)
}, },
leadingContent = { leadingContent = {
Box( BadgedBox(
modifier = Modifier badge = {
.size(48.dp) if (totalUnread > 0) {
.clip(MaterialShapes.Clover4Leaf.toShape()), Badge {
contentAlignment = Alignment.Center Text(totalUnread.toString())
}
}
}
) { ) {
Surface( Box(
modifier = Modifier.size(48.dp), modifier = Modifier
color = MaterialTheme.colorScheme.tertiaryContainer, .size(48.dp)
.clip(MaterialShapes.Clover4Leaf.toShape()),
contentAlignment = Alignment.Center
) { ) {
Box(contentAlignment = Alignment.Center) { Surface(
Icon( modifier = Modifier.size(48.dp),
painter = painterResource(Res.drawable.ic_request), color = MaterialTheme.colorScheme.tertiaryContainer,
contentDescription = "Requests", ) {
tint = MaterialTheme.colorScheme.onTertiaryFixed Box(contentAlignment = Alignment.Center) {
) Icon(
painter = painterResource(Res.drawable.ic_request),
contentDescription = "Requests",
tint = MaterialTheme.colorScheme.onTertiaryFixed
)
}
} }
} }
} }
@@ -703,13 +715,6 @@ fun NewRequests(requests: List<Room>) {
) )
} }
}, },
trailingContent = {
if (totalUnread > 0) {
androidx.compose.material3.Badge {
Text(totalUnread.toString())
}
}
},
colors = ListItemDefaults.colors( colors = ListItemDefaults.colors(
containerColor = MaterialTheme.colorScheme.surface containerColor = MaterialTheme.colorScheme.surface
) )
@@ -726,12 +731,22 @@ fun ChatRoom(room: Room, onClick: () -> Unit) {
ListItem( ListItem(
modifier = Modifier.clickable(onClick = onClick), modifier = Modifier.clickable(onClick = onClick),
leadingContent = { leadingContent = {
Avatar(picture = roomState.picture, description = roomState.picture) BadgedBox(
badge = {
if (room.unreadCount > 0) {
Badge {
Text(room.unreadCount.toString())
}
}
}
) {
Avatar(picture = roomState.picture, description = roomState.picture)
}
}, },
headlineContent = { headlineContent = {
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically,
) { ) {
Text( Text(
text = roomState.name, text = roomState.name,
@@ -743,7 +758,8 @@ fun ChatRoom(room: Room, onClick: () -> Unit) {
Text( Text(
text = room.createdAt.ago(), text = room.createdAt.ago(),
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
color = if (room.unreadCount > 0) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.outline color = MaterialTheme.colorScheme.outline,
textAlign = TextAlign.End,
) )
} }
}, },
@@ -760,13 +776,6 @@ fun ChatRoom(room: Room, onClick: () -> Unit) {
) )
} }
}, },
trailingContent = {
if (room.unreadCount > 0) {
androidx.compose.material3.Badge {
Text(room.unreadCount.toString())
}
}
},
colors = ListItemDefaults.colors( colors = ListItemDefaults.colors(
containerColor = MaterialTheme.colorScheme.surface containerColor = MaterialTheme.colorScheme.surface
) )