feat: add support for unread message and room highlighting #49
@@ -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,6 +664,15 @@ fun NewRequests(requests: List<Room>) {
|
|||||||
navigator.navigate(Screen.RequestList)
|
navigator.navigate(Screen.RequestList)
|
||||||
},
|
},
|
||||||
leadingContent = {
|
leadingContent = {
|
||||||
|
BadgedBox(
|
||||||
|
badge = {
|
||||||
|
if (totalUnread > 0) {
|
||||||
|
Badge {
|
||||||
|
Text(totalUnread.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(48.dp)
|
.size(48.dp)
|
||||||
@@ -681,6 +692,7 @@ fun NewRequests(requests: List<Room>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
headlineContent = {
|
headlineContent = {
|
||||||
Text(
|
Text(
|
||||||
@@ -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 = {
|
||||||
|
BadgedBox(
|
||||||
|
badge = {
|
||||||
|
if (room.unreadCount > 0) {
|
||||||
|
Badge {
|
||||||
|
Text(room.unreadCount.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
Avatar(picture = roomState.picture, description = roomState.picture)
|
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
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user