From fbb776a14a3ec159109f607bd2be577ed37da525 Mon Sep 17 00:00:00 2001 From: Diogo Date: Thu, 5 Sep 2024 14:04:36 +0100 Subject: [PATCH] unread badge --- .../common/views/chatlist/ChatListView.kt | 2 +- .../common/views/chatlist/UserPicker.kt | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt index c502dd713d..6abbf09262 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt @@ -446,7 +446,7 @@ fun UserProfileButton(image: String?, allRead: Boolean, onButtonClicked: () -> U @Composable -fun BoxScope.unreadBadge(text: String? = "") { +private fun BoxScope.unreadBadge(text: String? = "") { Text( text ?: "", color = MaterialTheme.colors.onPrimary, diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt index 47940889cb..2986062e40 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt @@ -186,6 +186,21 @@ private fun ActiveUserSection( } } +@Composable +private fun BoxScope.unreadBadge(text: String? = "") { + Text( + text ?: "", + color = MaterialTheme.colors.onPrimary, + fontSize = 12.sp, + modifier = Modifier + .background(MaterialTheme.colors.primary, shape = CircleShape) + .badgeLayout() + .padding(horizontal = 3.dp) + .padding(vertical = 2.dp) + .align(Alignment.TopEnd) + ) +} + @Composable fun UserPickerInactiveUserBadge(userInfo: UserInfo, stopped: Boolean, size: Int = 60, onClick: (user: User) -> Unit) { Box { @@ -195,8 +210,9 @@ fun UserPickerInactiveUserBadge(userInfo: UserInfo, stopped: Boolean, size: Int ) { Box { ProfileImage(size = size.dp, image = userInfo.user.profile.image, color = MaterialTheme.colors.secondaryVariant) + if (userInfo.unreadCount > 0) { - unreadBadge() + unreadBadge("${userInfo.unreadCount}") } } }