diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt index acc0ab0dba..7002d451ef 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/components/RoomSummaryRow.kt @@ -35,6 +35,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.PreviewParameter @@ -141,7 +142,7 @@ private fun RowScope.NameAndTimestampRow(room: RoomListRoomSummary) { Text( text = room.timestamp ?: "", style = ElementTheme.typography.fontBodySmMedium, - color = if (room.isTimestampHighlighted) { + color = if (room.isHighlighted) { ElementTheme.colors.unreadIndicator } else { MaterialTheme.roomListRoomMessageDate() @@ -165,69 +166,43 @@ private fun RowScope.LastMessageAndIndicatorRow(room: RoomListRoomSummary) { maxLines = 2, overflow = TextOverflow.Ellipsis ) - - // Unread + // Call and unread Row( modifier = Modifier.height(16.dp), horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically, ) { - // Video call + val tint = if (room.isHighlighted) ElementTheme.colors.unreadIndicator else ElementTheme.colors.iconQuaternary if (room.hasRoomCall) { - OnGoingCallIcon() + OnGoingCallIcon( + color = tint, + ) + } + if (room.userDefinedNotificationMode == RoomNotificationMode.MUTE) { + NotificationOffIndicatorAtom() + } else if (room.numberOfUnreadMentions > 0) { + MentionIndicatorAtom() + } + if (room.hasNewContent) { + UnreadIndicatorAtom( + color = tint + ) } - // Other indicators - NotificationIcons( - room.userDefinedNotificationMode, - room.numberOfUnreadMessages, - room.numberOfUnreadMentions, - ) } } @Composable -private fun OnGoingCallIcon() { +private fun OnGoingCallIcon( + color: Color, +) { Icon( modifier = Modifier.size(16.dp), imageVector = CompoundIcons.VideoCallSolid, contentDescription = null, - tint = ElementTheme.colors.unreadIndicator, + tint = color, ) } -@Composable -private fun RowScope.NotificationIcons( - userDefinedNotificationMode: RoomNotificationMode?, - numberOfUnreadMessages: Int, - numberOfUnreadMentions: Int, -) { - when (userDefinedNotificationMode) { - null, - RoomNotificationMode.ALL_MESSAGES -> { - if (numberOfUnreadMentions > 0) { - MentionIndicatorAtom() - UnreadIndicatorAtom() - } else if (numberOfUnreadMessages > 0) { - UnreadIndicatorAtom() - } - } - RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> { - if (numberOfUnreadMentions > 0) { - MentionIndicatorAtom() - UnreadIndicatorAtom() - } else if (numberOfUnreadMessages > 0) { - UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary) - } - } - RoomNotificationMode.MUTE -> { - NotificationOffIndicatorAtom() - if (numberOfUnreadMessages > 0 || numberOfUnreadMentions > 0) { - UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary) - } - } - } -} - @Composable private fun NotificationOffIndicatorAtom() { Icon( diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt index f2f0e3932d..26cd9e2d32 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/model/RoomListRoomSummary.kt @@ -37,11 +37,10 @@ data class RoomListRoomSummary( val hasRoomCall: Boolean, val isDm: Boolean, ) { - val isTimestampHighlighted = hasRoomCall || - when (userDefinedNotificationMode) { - null, - RoomNotificationMode.ALL_MESSAGES -> numberOfUnreadMessages > 0 || numberOfUnreadMentions > 0 - RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> numberOfUnreadMentions > 0 - RoomNotificationMode.MUTE -> false - } + val isHighlighted = userDefinedNotificationMode != RoomNotificationMode.MUTE && + (numberOfUnreadNotifications > 0 || numberOfUnreadMentions > 0) + + val hasNewContent = numberOfUnreadMessages > 0 || + numberOfUnreadMentions > 0 || + numberOfUnreadNotifications > 0 }