1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-16 18:28:51 +01:00

feat: notification style

This commit is contained in:
Rongjian Zhang 2019-09-15 01:43:41 +08:00
parent c24fd4600c
commit 1eafcff124

View File

@ -37,21 +37,22 @@ class _HomeState extends State<Home> {
}); });
} }
Widget _buildNotificationIcon(BuildContext context) { Widget _buildNotificationIcon(BuildContext context, bool isActive) {
final iconData = isActive ? Icons.notifications : Icons.notifications_none;
int count = Provider.of<NotificationModel>(context).count; int count = Provider.of<NotificationModel>(context).count;
if (count == 0) { if (count == 0) {
return Icon(Icons.notifications_none); return Icon(iconData);
} }
// String text = count > 99 ? '99+' : count.toString(); // String text = count > 99 ? '99+' : count.toString();
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
Icon(Icons.notifications_none), Icon(iconData),
Positioned( Positioned(
right: 0, right: -2,
top: 0, top: -2,
child: Icon(Octicons.primitive_dot, child: Icon(Octicons.primitive_dot,
color: PrimerColors.red500, size: 12)) color: PrimerColors.red500, size: 14))
], ],
); );
} }
@ -63,8 +64,8 @@ class _HomeState extends State<Home> {
title: Text('News'), title: Text('News'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: _buildNotificationIcon(context), icon: _buildNotificationIcon(context, false),
activeIcon: Icon(Icons.notifications), activeIcon: _buildNotificationIcon(context, true),
title: Text('Notification'), title: Text('Notification'),
), ),
BottomNavigationBarItem( BottomNavigationBarItem(