Skip to content

Commit

Permalink
TW-1849: Fix bug weird grey counter sometimes appears
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Nov 14, 2024
1 parent c7b84a3 commit 8b1cf6a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
19 changes: 4 additions & 15 deletions lib/pages/chat_list/chat_list_item_subtitle.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 17 additions & 0 deletions lib/presentation/mixins/chat_list_item_mixin.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 8b1cf6a

Please sign in to comment.