From 8b1cf6a8d913ccf45434c5e55c4009ea0cbfa961 Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Thu, 14 Nov 2024 17:53:53 +0700 Subject: [PATCH] TW-1849: Fix bug weird grey counter sometimes appears --- .../chat_list/chat_list_item_subtitle.dart | 19 ++++--------------- .../mixins/chat_list_item_mixin.dart | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/pages/chat_list/chat_list_item_subtitle.dart b/lib/pages/chat_list/chat_list_item_subtitle.dart index 9feca2bc05..6e6a4ef126 100644 --- a/lib/pages/chat_list/chat_list_item_subtitle.dart +++ b/lib/pages/chat_list/chat_list_item_subtitle.dart @@ -1,6 +1,5 @@ import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/config/themes.dart'; -import 'package:fluffychat/domain/model/room/room_extension.dart'; import 'package:fluffychat/presentation/mixins/chat_list_item_mixin.dart'; import 'package:fluffychat/pages/chat_list/chat_list_item_style.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart'; @@ -30,12 +29,6 @@ class ChatListItemSubtitle extends StatelessWidget with ChatListItemMixin { final isMediaEvent = room.lastEvent?.messageType == MessageTypes.Image || room.lastEvent?.messageType == MessageTypes.Video; - final haveNotificationsAndMuted = - room.notificationCount > 0 && room.isMuted; - - final haveNotificationsOrUnread = - room.notificationCount > 0 || room.markedUnread; - return Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, @@ -133,14 +126,10 @@ class ChatListItemSubtitle extends StatelessWidget with ChatListItemMixin { room.notificationCount, ), decoration: BoxDecoration( - color: - room.highlightCount > 0 || room.membership == Membership.invite - ? Theme.of(context).colorScheme.primary - : haveNotificationsAndMuted - ? LinagoraRefColors.material().tertiary[30] - : haveNotificationsOrUnread - ? Theme.of(context).colorScheme.primary - : LinagoraRefColors.material().tertiary[30], + color: notificationColor( + context: context, + room: room, + ), borderRadius: BorderRadius.circular(AppConfig.borderRadius), ), child: Center( diff --git a/lib/presentation/mixins/chat_list_item_mixin.dart b/lib/presentation/mixins/chat_list_item_mixin.dart index 359cd25214..9360dfe67d 100644 --- a/lib/presentation/mixins/chat_list_item_mixin.dart +++ b/lib/presentation/mixins/chat_list_item_mixin.dart @@ -1,3 +1,4 @@ +import 'package:fluffychat/domain/model/room/room_extension.dart'; import 'package:fluffychat/pages/chat/events/images_builder/image_placeholder.dart'; import 'package:fluffychat/presentation/decorators/chat_list/subtitle_image_preview_style.dart'; import 'package:fluffychat/presentation/decorators/chat_list/subtitle_text_style_decorator/subtitle_text_style_view.dart'; @@ -208,4 +209,20 @@ mixin ChatListItemMixin { ], ); } + + Color? notificationColor({ + required BuildContext context, + required Room room, + }) { + if (room.notificationCount > 0 && room.isMuted) { + return LinagoraRefColors.material().tertiary[30]; + } + if (room.notificationCount > 0) { + return Theme.of(context).colorScheme.primary; + } + if (room.membership == Membership.invite) { + return Theme.of(context).colorScheme.primary; + } + return Colors.transparent; + } }