From 5ae23f46204584e76f9b3ee31bd89a28ff598116 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Wed, 19 Nov 2025 13:45:42 -0500 Subject: [PATCH] displaying unreads --- lib/widgets/chat_page/sidebar.dart | 13 +++++-------- lib/widgets/chat_page/unread.dart | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 lib/widgets/chat_page/unread.dart diff --git a/lib/widgets/chat_page/sidebar.dart b/lib/widgets/chat_page/sidebar.dart index e6e98e6..34479f3 100644 --- a/lib/widgets/chat_page/sidebar.dart +++ b/lib/widgets/chat_page/sidebar.dart @@ -7,6 +7,7 @@ import "package:nexus/controllers/spaces_controller.dart"; import "package:nexus/helpers/extension_helper.dart"; import "package:nexus/pages/settings_page.dart"; import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/chat_page/unread.dart"; class Sidebar extends HookConsumerWidget { const Sidebar({super.key}); @@ -40,12 +41,8 @@ class Sidebar extends HookConsumerWidget { destinations: spaces .map( (space) => NavigationRailDestination( - icon: Badge( - smallSize: 8, - backgroundColor: Theme.of( - context, - ).colorScheme.primary, - isLabelVisible: + icon: Unread( + isUnread: space.children.firstWhereOrNull( (room) => room.roomData.hasNewMessages, ) != @@ -107,8 +104,8 @@ class Sidebar extends HookConsumerWidget { .map( (room) => NavigationRailDestination( label: Text(room.title), - icon: Badge( - isLabelVisible: room.roomData.hasNewMessages, + icon: Unread( + isUnread: room.roomData.hasNewMessages, child: AvatarOrHash( room.avatar, room.title, diff --git a/lib/widgets/chat_page/unread.dart b/lib/widgets/chat_page/unread.dart new file mode 100644 index 0000000..4c478ed --- /dev/null +++ b/lib/widgets/chat_page/unread.dart @@ -0,0 +1,15 @@ +import "package:flutter/material.dart"; + +class Unread extends StatelessWidget { + final bool isUnread; + final Widget child; + const Unread({required this.isUnread, required this.child, super.key}); + + @override + Widget build(BuildContext context) => Badge( + smallSize: 8, + backgroundColor: Theme.of(context).colorScheme.primary, + isLabelVisible: isUnread, + child: child, + ); +}