From 4035c1ca5b4dd84e8a09fc6627f980c20ba5c693 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 25 Jan 2024 15:06:34 +0100 Subject: [PATCH] Rework: extract sub fun composable. --- .../impl/components/RoomSummaryRow.kt | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) 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 65e5490aa6..7944fc69b2 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 @@ -209,12 +209,7 @@ private fun RowScope.NotificationIcons( null, RoomNotificationMode.ALL_MESSAGES -> { if (numberOfUnreadMentions > 0) { - Icon( - modifier = Modifier.size(16.dp), - contentDescription = null, - imageVector = CompoundIcons.Mention, - tint = ElementTheme.colors.unreadIndicator, - ) + MentionIndicatorAtom() UnreadIndicatorAtom() } else if (numberOfUnreadMessages > 0) { UnreadIndicatorAtom() @@ -222,24 +217,14 @@ private fun RowScope.NotificationIcons( } RoomNotificationMode.MENTIONS_AND_KEYWORDS_ONLY -> { if (numberOfUnreadMentions > 0) { - Icon( - modifier = Modifier.size(16.dp), - contentDescription = null, - imageVector = CompoundIcons.Mention, - tint = ElementTheme.colors.unreadIndicator, - ) + MentionIndicatorAtom() UnreadIndicatorAtom() } else if (numberOfUnreadMessages > 0) { UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary) } } RoomNotificationMode.MUTE -> { - Icon( - modifier = Modifier.size(16.dp), - contentDescription = null, - imageVector = CompoundIcons.NotificationsSolidOff, - tint = ElementTheme.colors.iconQuaternary, - ) + NotificationOffIndicatorAtom() if (numberOfUnreadMessages > 0 || numberOfUnreadMentions > 0) { UnreadIndicatorAtom(color = ElementTheme.colors.iconQuaternary) } @@ -247,6 +232,26 @@ private fun RowScope.NotificationIcons( } } +@Composable +private fun NotificationOffIndicatorAtom() { + Icon( + modifier = Modifier.size(16.dp), + contentDescription = null, + imageVector = CompoundIcons.NotificationsSolidOff, + tint = ElementTheme.colors.iconQuaternary, + ) +} + +@Composable +private fun MentionIndicatorAtom() { + Icon( + modifier = Modifier.size(16.dp), + contentDescription = null, + imageVector = CompoundIcons.Mention, + tint = ElementTheme.colors.unreadIndicator, + ) +} + @PreviewsDayNight @Composable internal fun RoomSummaryRowPreview(@PreviewParameter(RoomListRoomSummaryProvider::class) data: RoomListRoomSummary) = ElementPreview {