diff --git a/packages/neon/neon/lib/src/widgets/app_bar.dart b/packages/neon/neon/lib/src/widgets/app_bar.dart index ecb20c85..8bd82d2b 100644 --- a/packages/neon/neon/lib/src/widgets/app_bar.dart +++ b/packages/neon/neon/lib/src/widgets/app_bar.dart @@ -251,25 +251,19 @@ class _NotificationIconButtonState extends State { final notificationsImplementationData = notificationsAppImplementation.data!; final notificationBloc = notificationsImplementationData.getBloc(_account); - return StreamBuilder( - stream: notificationsImplementationData.getUnreadCounter(notificationBloc), - builder: (final context, final unreadCounterSnapshot) { - final unreadCount = unreadCounterSnapshot.data ?? 0; - return IconButton( - key: Key('app-${notificationsImplementationData.id}'), - onPressed: () async { - await _openNotifications(notificationsImplementationData); - }, - tooltip: AppLocalizations.of(context).appImplementationName(notificationsImplementationData.id), - icon: NeonAppImplementationIcon( - appImplementation: notificationsImplementationData, - unreadCount: unreadCount, - color: unreadCount > 0 - ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.onBackground, - ), - ); + return IconButton( + key: Key('app-${notificationsImplementationData.id}'), + onPressed: () async { + await _openNotifications(notificationsImplementationData); }, + tooltip: AppLocalizations.of(context).appImplementationName(notificationsImplementationData.id), + icon: StreamBuilder( + stream: notificationsImplementationData.getUnreadCounter(notificationBloc), + builder: (final context, final unreadCounterSnapshot) => NeonAppImplementationIcon( + appImplementation: notificationsImplementationData, + unreadCount: unreadCounterSnapshot.data, + ), + ), ); }, ); diff --git a/packages/neon/neon/lib/src/widgets/app_implementation_icon.dart b/packages/neon/neon/lib/src/widgets/app_implementation_icon.dart index 6a3ba25c..f8c83072 100644 --- a/packages/neon/neon/lib/src/widgets/app_implementation_icon.dart +++ b/packages/neon/neon/lib/src/widgets/app_implementation_icon.dart @@ -1,4 +1,4 @@ -import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; import 'package:neon/src/models/app_implementation.dart'; @@ -6,7 +6,7 @@ import 'package:neon/src/models/app_implementation.dart'; class NeonAppImplementationIcon extends StatelessWidget { const NeonAppImplementationIcon({ required this.appImplementation, - this.unreadCount = 0, + this.unreadCount, this.color, this.size, super.key, @@ -14,7 +14,7 @@ class NeonAppImplementationIcon extends StatelessWidget { final AppImplementation appImplementation; - final int unreadCount; + final int? unreadCount; final Color? color; @@ -22,6 +22,11 @@ class NeonAppImplementationIcon extends StatelessWidget { @override Widget build(final BuildContext context) { + final unreadCount = this.unreadCount ?? 0; + + final color = this.color ?? + (unreadCount > 0 ? Theme.of(context).colorScheme.primary : Theme.of(context).colorScheme.onBackground); + final icon = Container( margin: const EdgeInsets.all(5), child: appImplementation.buildIcon(