|
|
|
@@ -1,6 +1,9 @@ |
|
|
|
import 'package:badges/badges.dart'; |
|
|
|
import 'package:farm_tpf/authentication/authentication.dart'; |
|
|
|
import 'package:farm_tpf/custom_model/NotificationObjectDTO.dart'; |
|
|
|
import 'package:farm_tpf/data/repository/user_repository.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/notification/sc_notification.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/notification/update_count_noti_bloc.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; |
|
|
|
import 'package:farm_tpf/utils/const_color.dart'; |
|
|
|
import 'package:farm_tpf/utils/pref.dart'; |
|
|
|
@@ -154,10 +157,7 @@ class _HomeDrawerState extends State<HomeDrawer> { |
|
|
|
), |
|
|
|
textAlign: TextAlign.left, |
|
|
|
), |
|
|
|
leading: Icon( |
|
|
|
Icons.notifications, |
|
|
|
color: Colors.black, |
|
|
|
), |
|
|
|
leading: _iconWithBadgeNotiCount(), |
|
|
|
onTap: () { |
|
|
|
navigationtoScreen(currentDrawerIndex); |
|
|
|
Navigator.of(context).push( |
|
|
|
@@ -333,6 +333,49 @@ class _HomeDrawerState extends State<HomeDrawer> { |
|
|
|
pref.saveString(DATA_CONST.PUSH_KEY, ""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Widget _iconWithBadgeNotiCount() { |
|
|
|
return StreamBuilder( |
|
|
|
stream: updateCountNotiBloc.actions, |
|
|
|
builder: (context, AsyncSnapshot<dynamic> snapshot) { |
|
|
|
if (snapshot.hasData) { |
|
|
|
var noti = snapshot.data as NotificationObjectDTO; |
|
|
|
var unreadNoti = noti.numberUnreadTotal.toString(); |
|
|
|
return Badge( |
|
|
|
badgeContent: Text( |
|
|
|
'' + unreadNoti, |
|
|
|
softWrap: true, |
|
|
|
style: TextStyle(color: Colors.white), |
|
|
|
), |
|
|
|
shape: BadgeShape.square, |
|
|
|
badgeColor: Colors.red, |
|
|
|
borderRadius: 20, |
|
|
|
position: BadgePosition(top: -15, start: 10), |
|
|
|
child: Icon( |
|
|
|
Icons.notifications, |
|
|
|
color: Colors.black, |
|
|
|
), |
|
|
|
); |
|
|
|
} else { |
|
|
|
return Badge( |
|
|
|
badgeContent: Text( |
|
|
|
'0', |
|
|
|
softWrap: true, |
|
|
|
style: TextStyle(color: Colors.white), |
|
|
|
), |
|
|
|
shape: BadgeShape.square, |
|
|
|
badgeColor: Colors.red, |
|
|
|
borderRadius: 20, |
|
|
|
position: BadgePosition(top: -15, start: 10), |
|
|
|
child: Icon( |
|
|
|
Icons.notifications, |
|
|
|
color: Colors.black, |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
}, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
enum DrawerIndex { ScanBarcode, Home, ControlDevice } |