Handle PR review.

This commit is contained in:
Benoit Marty 2023-12-21 16:05:51 +01:00
parent a83cafd6b7
commit 709e68f099
6 changed files with 45 additions and 33 deletions

View file

@ -71,7 +71,7 @@ internal fun aRoomListRoomSummaryList(): ImmutableList<RoomListRoomSummary> {
return persistentListOf( return persistentListOf(
RoomListRoomSummary( RoomListRoomSummary(
name = "Room", name = "Room",
numUnreadMessages = 1, numberOfUnreadMessages = 1,
timestamp = "14:18", timestamp = "14:18",
lastMessage = "A very very very very long message which suites on two lines", lastMessage = "A very very very very long message which suites on two lines",
avatarData = AvatarData("!id", "R", size = AvatarSize.RoomListItem), avatarData = AvatarData("!id", "R", size = AvatarSize.RoomListItem),
@ -80,7 +80,7 @@ internal fun aRoomListRoomSummaryList(): ImmutableList<RoomListRoomSummary> {
), ),
RoomListRoomSummary( RoomListRoomSummary(
name = "Room#2", name = "Room#2",
numUnreadMessages = 0, numberOfUnreadMessages = 0,
timestamp = "14:16", timestamp = "14:16",
lastMessage = "A short message", lastMessage = "A short message",
avatarData = AvatarData("!id", "Z", size = AvatarSize.RoomListItem), avatarData = AvatarData("!id", "Z", size = AvatarSize.RoomListItem),

View file

@ -174,15 +174,23 @@ private fun RowScope.LastMessageAndIndicatorRow(room: RoomListRoomSummary) {
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
// Video call // Video call
OnGoingCallIcon(room) OnGoingCallIcon(
room.hasRoomCall,
)
// Other indicators // Other indicators
NotificationIcons(room) NotificationIcons(
room.userDefinedNotificationMode,
room.numberOfUnreadMessages,
room.numberOfUnreadMentions,
)
} }
} }
@Composable @Composable
private fun OnGoingCallIcon(room: RoomListRoomSummary) { private fun OnGoingCallIcon(
if (room.hasRoomCall) { hasRoomCall: Boolean,
) {
if (hasRoomCall) {
Icon( Icon(
modifier = Modifier.size(16.dp), modifier = Modifier.size(16.dp),
imageVector = CompoundIcons.VideoCallSolid, imageVector = CompoundIcons.VideoCallSolid,
@ -193,11 +201,15 @@ private fun OnGoingCallIcon(room: RoomListRoomSummary) {
} }
@Composable @Composable
private fun RowScope.NotificationIcons(room: RoomListRoomSummary) { private fun RowScope.NotificationIcons(
when (room.userDefinedNotificationMode) { userDefinedNotificationMode: RoomNotificationMode?,
numberOfUnreadMessages: Int,
numberOfUnreadMentions: Int,
) {
when (userDefinedNotificationMode) {
null, null,
RoomNotificationMode.ALL_MESSAGES -> { RoomNotificationMode.ALL_MESSAGES -> {
if (room.numUnreadMentions > 0) { if (numberOfUnreadMentions > 0) {
Icon( Icon(
modifier = Modifier.size(16.dp), modifier = Modifier.size(16.dp),
contentDescription = null, contentDescription = null,
@ -205,12 +217,12 @@ private fun RowScope.NotificationIcons(room: RoomListRoomSummary) {
tint = ElementTheme.colors.unreadIndicator, tint = ElementTheme.colors.unreadIndicator,
) )
UnreadIndicatorAtom() UnreadIndicatorAtom()
} else if (room.numUnreadMessages > 0) { } else if (numberOfUnreadMessages > 0) {
UnreadIndicatorAtom() UnreadIndicatorAtom()
} }
} }
RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> { RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> {
if (room.numUnreadMentions > 0) { if (numberOfUnreadMentions > 0) {
Icon( Icon(
modifier = Modifier.size(16.dp), modifier = Modifier.size(16.dp),
contentDescription = null, contentDescription = null,
@ -218,7 +230,7 @@ private fun RowScope.NotificationIcons(room: RoomListRoomSummary) {
tint = ElementTheme.colors.unreadIndicator, tint = ElementTheme.colors.unreadIndicator,
) )
UnreadIndicatorAtom() UnreadIndicatorAtom()
} else if (room.numUnreadMessages > 0) { } else if (numberOfUnreadMessages > 0) {
UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary) UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary)
} }
} }
@ -229,7 +241,7 @@ private fun RowScope.NotificationIcons(room: RoomListRoomSummary) {
imageVector = CompoundIcons.NotificationsSolidOff, imageVector = CompoundIcons.NotificationsSolidOff,
tint = ElementTheme.colors.iconQuaternary, tint = ElementTheme.colors.iconQuaternary,
) )
if (room.numUnreadMessages > 0 || room.numUnreadMentions > 0) { if (numberOfUnreadMessages > 0 || numberOfUnreadMentions > 0) {
UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary) UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary)
} }
} }

View file

@ -154,8 +154,8 @@ class RoomListDataSource @Inject constructor(
id = roomSummary.identifier(), id = roomSummary.identifier(),
roomId = RoomId(roomIdentifier), roomId = RoomId(roomIdentifier),
name = roomSummary.details.name, name = roomSummary.details.name,
numUnreadMessages = roomSummary.details.numUnreadMessages, numberOfUnreadMessages = roomSummary.details.numUnreadMessages,
numUnreadMentions = roomSummary.details.numUnreadMentions, numberOfUnreadMentions = roomSummary.details.numUnreadMentions,
timestamp = lastMessageTimestampFormatter.format(roomSummary.details.lastMessageTimestamp), timestamp = lastMessageTimestampFormatter.format(roomSummary.details.lastMessageTimestamp),
lastMessage = roomSummary.details.lastMessage?.let { message -> lastMessage = roomSummary.details.lastMessage?.let { message ->
roomLastMessageFormatter.format(message.event, roomSummary.details.isDirect) roomLastMessageFormatter.format(message.event, roomSummary.details.isDirect)

View file

@ -32,8 +32,8 @@ data class RoomListRoomSummary(
val avatarData: AvatarData = AvatarData(id, name, size = AvatarSize.RoomListItem), val avatarData: AvatarData = AvatarData(id, name, size = AvatarSize.RoomListItem),
val isPlaceholder: Boolean = false, val isPlaceholder: Boolean = false,
val userDefinedNotificationMode: RoomNotificationMode? = null, val userDefinedNotificationMode: RoomNotificationMode? = null,
val numUnreadMessages: Int = 0, val numberOfUnreadMessages: Int = 0,
val numUnreadMentions: Int = 0, val numberOfUnreadMentions: Int = 0,
val hasRoomCall: Boolean = false, val hasRoomCall: Boolean = false,
) )
@ -41,8 +41,8 @@ fun RoomListRoomSummary.isTimestampHighlighted(): Boolean {
return hasRoomCall || return hasRoomCall ||
when (userDefinedNotificationMode) { when (userDefinedNotificationMode) {
null, null,
RoomNotificationMode.ALL_MESSAGES -> numUnreadMessages > 0 || numUnreadMentions > 0 RoomNotificationMode.ALL_MESSAGES -> numberOfUnreadMessages > 0 || numberOfUnreadMentions > 0
RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> numUnreadMentions > 0 RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> numberOfUnreadMentions > 0
RoomNotificationMode.MUTE -> false RoomNotificationMode.MUTE -> false
} }
} }

View file

@ -35,7 +35,7 @@ open class RoomListRoomSummaryProvider : PreviewParameterProvider<RoomListRoomSu
" ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea com" + " ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea com" +
"modo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", "modo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
timestamp = "yesterday", timestamp = "yesterday",
numUnreadMessages = 1, numberOfUnreadMessages = 1,
), ),
), ),
listOf(false, true).map { hasCall -> listOf(false, true).map { hasCall ->
@ -49,32 +49,32 @@ open class RoomListRoomSummaryProvider : PreviewParameterProvider<RoomListRoomSu
name = roomNotificationMode.name, name = roomNotificationMode.name,
lastMessage = "No activity" + if (hasCall) ", call" else "", lastMessage = "No activity" + if (hasCall) ", call" else "",
notificationMode = roomNotificationMode, notificationMode = roomNotificationMode,
numUnreadMessages = 0, numberOfUnreadMessages = 0,
numUnreadMentions = 0, numberOfUnreadMentions = 0,
hasOngoingCall = hasCall, hasOngoingCall = hasCall,
), ),
aRoomListRoomSummary( aRoomListRoomSummary(
name = roomNotificationMode.name, name = roomNotificationMode.name,
lastMessage = "New messages" + if (hasCall) ", call" else "", lastMessage = "New messages" + if (hasCall) ", call" else "",
notificationMode = roomNotificationMode, notificationMode = roomNotificationMode,
numUnreadMessages = 1, numberOfUnreadMessages = 1,
numUnreadMentions = 0, numberOfUnreadMentions = 0,
hasOngoingCall = hasCall, hasOngoingCall = hasCall,
), ),
aRoomListRoomSummary( aRoomListRoomSummary(
name = roomNotificationMode.name, name = roomNotificationMode.name,
lastMessage = "New messages, mentions" + if (hasCall) ", call" else "", lastMessage = "New messages, mentions" + if (hasCall) ", call" else "",
notificationMode = roomNotificationMode, notificationMode = roomNotificationMode,
numUnreadMessages = 1, numberOfUnreadMessages = 1,
numUnreadMentions = 1, numberOfUnreadMentions = 1,
hasOngoingCall = hasCall, hasOngoingCall = hasCall,
), ),
aRoomListRoomSummary( aRoomListRoomSummary(
name = roomNotificationMode.name, name = roomNotificationMode.name,
lastMessage = "New mentions" + if (hasCall) ", call" else "", lastMessage = "New mentions" + if (hasCall) ", call" else "",
notificationMode = roomNotificationMode, notificationMode = roomNotificationMode,
numUnreadMessages = 0, numberOfUnreadMessages = 0,
numUnreadMentions = 1, numberOfUnreadMentions = 1,
hasOngoingCall = hasCall, hasOngoingCall = hasCall,
), ),
) )
@ -86,8 +86,8 @@ open class RoomListRoomSummaryProvider : PreviewParameterProvider<RoomListRoomSu
fun aRoomListRoomSummary( fun aRoomListRoomSummary(
lastMessage: String? = null, lastMessage: String? = null,
notificationMode: RoomNotificationMode? = null, notificationMode: RoomNotificationMode? = null,
numUnreadMessages: Int = 0, numberOfUnreadMessages: Int = 0,
numUnreadMentions: Int = 0, numberOfUnreadMentions: Int = 0,
timestamp: String? = "88:88", timestamp: String? = "88:88",
hasOngoingCall: Boolean = false, hasOngoingCall: Boolean = false,
isPlaceholder: Boolean = false, isPlaceholder: Boolean = false,
@ -96,8 +96,8 @@ fun aRoomListRoomSummary(
id = "!roomId", id = "!roomId",
roomId = RoomId("!roomId:domain"), roomId = RoomId("!roomId:domain"),
name = name, name = name,
numUnreadMessages = numUnreadMessages, numberOfUnreadMessages = numberOfUnreadMessages,
numUnreadMentions = numUnreadMentions, numberOfUnreadMentions = numberOfUnreadMentions,
timestamp = timestamp, timestamp = timestamp,
lastMessage = lastMessage, lastMessage = lastMessage,
avatarData = AvatarData("!roomId", "Room name", size = AvatarSize.RoomListItem), avatarData = AvatarData("!roomId", "Room name", size = AvatarSize.RoomListItem),

View file

@ -439,7 +439,7 @@ private val aRoomListRoomSummary = RoomListRoomSummary(
id = A_ROOM_ID.value, id = A_ROOM_ID.value,
roomId = A_ROOM_ID, roomId = A_ROOM_ID,
name = A_ROOM_NAME, name = A_ROOM_NAME,
numUnreadMessages = 1, numberOfUnreadMessages = 1,
timestamp = A_FORMATTED_DATE, timestamp = A_FORMATTED_DATE,
lastMessage = "", lastMessage = "",
avatarData = AvatarData(id = A_ROOM_ID.value, name = A_ROOM_NAME, size = AvatarSize.RoomListItem), avatarData = AvatarData(id = A_ROOM_ID.value, name = A_ROOM_NAME, size = AvatarSize.RoomListItem),