2024-04-24 15:19:26 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:solian/providers/notify.dart';
|
|
|
|
import 'package:solian/router.dart';
|
|
|
|
import 'package:badges/badges.dart' as badge;
|
|
|
|
|
2024-05-12 12:59:33 +00:00
|
|
|
class NotificationButton extends StatelessWidget {
|
2024-05-12 12:15:12 +00:00
|
|
|
const NotificationButton({super.key});
|
2024-04-24 15:19:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final nty = context.watch<NotifyProvider>();
|
|
|
|
|
|
|
|
return badge.Badge(
|
2024-04-28 13:49:03 +00:00
|
|
|
showBadge: nty.unreadAmount > 0,
|
2024-04-24 15:19:26 +00:00
|
|
|
position: badge.BadgePosition.custom(top: -2, end: 8),
|
|
|
|
badgeContent: Text(
|
2024-04-28 13:49:03 +00:00
|
|
|
nty.unreadAmount.toString(),
|
2024-04-24 15:19:26 +00:00
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
child: IconButton(
|
|
|
|
icon: const Icon(Icons.notifications),
|
|
|
|
onPressed: () {
|
2024-05-03 05:39:52 +00:00
|
|
|
SolianRouter.router.pushNamed('notification');
|
2024-04-24 15:19:26 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|