|
|
|
@@ -1,6 +1,9 @@ |
|
|
|
import 'package:badges/badges.dart'; |
|
|
|
import 'package:farm_tpf/custom_model/NotificationObjectDTO.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/account/sc_account.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/control_device/sc_control_device.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/plot/sc_plot.dart'; |
|
|
|
import 'package:farm_tpf/utils/const_color.dart'; |
|
|
|
import 'package:farm_tpf/utils/const_icons.dart'; |
|
|
|
@@ -39,6 +42,31 @@ class _TabbarScreenState extends State<TabbarScreen> { |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
changeTabbar.initValue(); |
|
|
|
updateCountNotiBloc.getNotifications((data) {}, (err) {}); |
|
|
|
} |
|
|
|
|
|
|
|
Widget textCountNoti() { |
|
|
|
return StreamBuilder( |
|
|
|
stream: updateCountNotiBloc.actions, |
|
|
|
builder: (context, AsyncSnapshot<dynamic> snapshot) { |
|
|
|
if (snapshot.hasData) { |
|
|
|
var noti = snapshot.data as NotificationObjectDTO; |
|
|
|
var unreadNoti = |
|
|
|
noti.numberUnreadTotal > 99 ? '99+' : '${noti.numberUnreadTotal}'; |
|
|
|
return Text( |
|
|
|
'$unreadNoti', |
|
|
|
softWrap: true, |
|
|
|
style: TextStyle(color: Colors.white, fontSize: 10), |
|
|
|
); |
|
|
|
} else { |
|
|
|
return Text( |
|
|
|
'O', |
|
|
|
softWrap: true, |
|
|
|
style: TextStyle(color: Colors.white, fontSize: 10), |
|
|
|
); |
|
|
|
} |
|
|
|
}, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
@@ -92,15 +120,33 @@ class _TabbarScreenState extends State<TabbarScreen> { |
|
|
|
child: Column( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
SvgPicture.asset( |
|
|
|
itemsTabbar[index].icon, |
|
|
|
width: 24, |
|
|
|
height: 24, |
|
|
|
color: (tabbarSelected.index == |
|
|
|
itemsTabbar[index].index) |
|
|
|
? AppColors.YELLOW |
|
|
|
: AppColors.GRAY1, |
|
|
|
), |
|
|
|
index == 3 |
|
|
|
? Badge( |
|
|
|
badgeContent: textCountNoti(), |
|
|
|
shape: BadgeShape.circle, |
|
|
|
badgeColor: Colors.red, |
|
|
|
position: BadgePosition( |
|
|
|
top: -15, start: 10), |
|
|
|
child: SvgPicture.asset( |
|
|
|
itemsTabbar[index].icon, |
|
|
|
width: 24, |
|
|
|
height: 24, |
|
|
|
color: (tabbarSelected.index == |
|
|
|
itemsTabbar[index] |
|
|
|
.index) |
|
|
|
? AppColors.YELLOW |
|
|
|
: AppColors.GRAY1, |
|
|
|
), |
|
|
|
) |
|
|
|
: SvgPicture.asset( |
|
|
|
itemsTabbar[index].icon, |
|
|
|
width: 24, |
|
|
|
height: 24, |
|
|
|
color: (tabbarSelected.index == |
|
|
|
itemsTabbar[index].index) |
|
|
|
? AppColors.YELLOW |
|
|
|
: AppColors.GRAY1, |
|
|
|
), |
|
|
|
Flexible( |
|
|
|
child: Text( |
|
|
|
itemsTabbar[index].title, |