From d3fe032923f96c6f8be96fc5b9573fb2e0cf8883 Mon Sep 17 00:00:00 2001 From: Sanskar2807 Date: Fri, 29 Sep 2023 19:09:31 +0530 Subject: [PATCH] feat(neon_notifications): disable button when no notifications Signed-off-by: Sanskar2807 --- .../neon/neon_notifications/lib/pages/main.dart | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/neon/neon_notifications/lib/pages/main.dart b/packages/neon/neon_notifications/lib/pages/main.dart index 9fdc10bf..3d00a43e 100644 --- a/packages/neon/neon_notifications/lib/pages/main.dart +++ b/packages/neon/neon_notifications/lib/pages/main.dart @@ -28,12 +28,16 @@ class _NotificationsMainPageState extends State { stream: bloc.notifications, builder: (final context, final notifications) => Scaffold( resizeToAvoidBottomInset: false, - floatingActionButton: FloatingActionButton( - onPressed: () async { - bloc.deleteAllNotifications(); + floatingActionButton: StreamBuilder( + stream: bloc.unreadCounter, + builder: (final context, final snapshot) { + final unreadCount = snapshot.data ?? 0; + return FloatingActionButton( + onPressed: unreadCount > 0 ? bloc.deleteAllNotifications : null, + tooltip: AppLocalizations.of(context).notificationsDismissAll, + child: const Icon(MdiIcons.checkAll), + ); }, - tooltip: AppLocalizations.of(context).notificationsDismissAll, - child: const Icon(MdiIcons.checkAll), ), body: NeonListView( scrollKey: 'notifications-notifications',