fix show count in home page

merge-requests/791/head
Elham Rababh 5 years ago
parent 2c0cdff0dc
commit e8c0281913

@ -126,7 +126,9 @@ class DashboardViewModel extends BaseViewModel {
if (_doctorReplyService.hasError) { if (_doctorReplyService.hasError) {
error = _doctorReplyService.error; error = _doctorReplyService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else } else {
notifyListeners();
setState(ViewState.Idle); setState(ViewState.Idle);
}
} }
} }

@ -72,7 +72,6 @@ class _HomeScreenState extends State<HomeScreen> {
await model.getDoctorProfile(isGetProfile: true); await model.getDoctorProfile(isGetProfile: true);
await model.checkDoctorHasLiveCare(); await model.checkDoctorHasLiveCare();
await model.getSpecialClinicalCareList(); await model.getSpecialClinicalCareList();
await model.getNotRepliedCount();
}, },
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,

@ -1,3 +1,4 @@
import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
@ -9,6 +10,9 @@ import 'bottom_navigation_item.dart';
class BottomNavBar extends StatefulWidget { class BottomNavBar extends StatefulWidget {
final ValueChanged<int> changeIndex; final ValueChanged<int> changeIndex;
final int index; final int index;
DashboardViewModel dashboardViewModel = DashboardViewModel();
BottomNavBar({Key key, this.changeIndex, this.index}) : super(key: key); BottomNavBar({Key key, this.changeIndex, this.index}) : super(key: key);
@override @override
@ -25,6 +29,12 @@ class _BottomNavBarState extends State<BottomNavBar> {
}); });
} }
@override
void initState() {
widget.dashboardViewModel.getNotRepliedCount();
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BottomAppBar( return BottomAppBar(
@ -44,6 +54,7 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index, index: widget.index,
currentIndex: 0, currentIndex: 0,
name: TranslationBase.of(context).home, name: TranslationBase.of(context).home,
dashboardViewModel: widget.dashboardViewModel,
), ),
BottomNavigationItem( BottomNavigationItem(
icon: DoctorApp.schedule_1, icon: DoctorApp.schedule_1,
@ -52,6 +63,8 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index, index: widget.index,
currentIndex: 1, currentIndex: 1,
name: TranslationBase.of(context).mySchedule, name: TranslationBase.of(context).mySchedule,
dashboardViewModel: widget.dashboardViewModel,
), ),
BottomNavigationItem( BottomNavigationItem(
icon: DoctorApp.qr_reader, icon: DoctorApp.qr_reader,
@ -60,6 +73,8 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index, index: widget.index,
currentIndex: 2, currentIndex: 2,
name: TranslationBase.of(context).qr, name: TranslationBase.of(context).qr,
dashboardViewModel: widget.dashboardViewModel,
), ),
BottomNavigationItem( BottomNavigationItem(
icon: DoctorApp.dr_reply_1, icon: DoctorApp.dr_reply_1,
@ -68,6 +83,8 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index, index: widget.index,
currentIndex: 3, currentIndex: 3,
name: TranslationBase.of(context).replay2, name: TranslationBase.of(context).replay2,
dashboardViewModel: widget.dashboardViewModel,
), ),
], ],
), ),

@ -14,6 +14,9 @@ class BottomNavigationItem extends StatelessWidget {
final int index; final int index;
final int currentIndex; final int currentIndex;
final String name; final String name;
final DashboardViewModel dashboardViewModel;
BottomNavigationItem( BottomNavigationItem(
{this.icon, {this.icon,
@ -21,12 +24,11 @@ class BottomNavigationItem extends StatelessWidget {
this.changeIndex, this.changeIndex,
this.index, this.index,
this.currentIndex, this.currentIndex,
this.name}); this.name, this.dashboardViewModel});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
DashboardViewModel model = DashboardViewModel();
return Expanded( return Expanded(
child: SizedBox( child: SizedBox(
height: 70.0, height: 70.0,
@ -66,7 +68,7 @@ class BottomNavigationItem extends StatelessWidget {
), ),
], ],
), ),
if(currentIndex == 3 && model.notRepliedCount != 0) if(currentIndex == 3 && dashboardViewModel.notRepliedCount != 0)
Positioned( Positioned(
right: 18.0, right: 18.0,
bottom: 40.0, bottom: 40.0,
@ -78,7 +80,7 @@ class BottomNavigationItem extends StatelessWidget {
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
badgeContent: Container( badgeContent: Container(
// padding: EdgeInsets.all(2.0), // padding: EdgeInsets.all(2.0),
child: Text(model.notRepliedCount.toString(), child: Text(dashboardViewModel.notRepliedCount.toString(),
style: TextStyle( style: TextStyle(
color: Colors.white, fontSize: 12.0)), color: Colors.white, fontSize: 12.0)),
), ),

Loading…
Cancel
Save