Real-time local notify

This commit is contained in:
2024-04-28 21:49:03 +08:00
parent db45764d42
commit ad10084850
12 changed files with 128 additions and 8 deletions

View File

@ -37,6 +37,7 @@ class _NotificationNotifierState extends State<NotificationNotifier> {
(event) {
final result = model.Notification.fromJson(jsonDecode(event));
nty.onRemoteMessage(result);
nty.notifyMessage(result.subject, result.content);
},
onError: (_, __) => connect(),
onDone: () => connect(),
@ -75,10 +76,10 @@ class _NotificationButtonState extends State<NotificationButton> {
final nty = context.watch<NotifyProvider>();
return badge.Badge(
showBadge: nty.notifications.isNotEmpty,
showBadge: nty.unreadAmount > 0,
position: badge.BadgePosition.custom(top: -2, end: 8),
badgeContent: Text(
nty.notifications.length.toString(),
nty.unreadAmount.toString(),
style: const TextStyle(color: Colors.white),
),
child: IconButton(