fix show count in home page

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

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

@ -72,7 +72,6 @@ class _HomeScreenState extends State<HomeScreen> {
await model.getDoctorProfile(isGetProfile: true);
await model.checkDoctorHasLiveCare();
await model.getSpecialClinicalCareList();
await model.getNotRepliedCount();
},
builder: (_, model, w) => AppScaffold(
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/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
@ -9,6 +10,9 @@ import 'bottom_navigation_item.dart';
class BottomNavBar extends StatefulWidget {
final ValueChanged<int> changeIndex;
final int index;
DashboardViewModel dashboardViewModel = DashboardViewModel();
BottomNavBar({Key key, this.changeIndex, this.index}) : super(key: key);
@override
@ -25,6 +29,12 @@ class _BottomNavBarState extends State<BottomNavBar> {
});
}
@override
void initState() {
widget.dashboardViewModel.getNotRepliedCount();
super.initState();
}
@override
Widget build(BuildContext context) {
return BottomAppBar(
@ -44,6 +54,7 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index,
currentIndex: 0,
name: TranslationBase.of(context).home,
dashboardViewModel: widget.dashboardViewModel,
),
BottomNavigationItem(
icon: DoctorApp.schedule_1,
@ -52,6 +63,8 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index,
currentIndex: 1,
name: TranslationBase.of(context).mySchedule,
dashboardViewModel: widget.dashboardViewModel,
),
BottomNavigationItem(
icon: DoctorApp.qr_reader,
@ -60,6 +73,8 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index,
currentIndex: 2,
name: TranslationBase.of(context).qr,
dashboardViewModel: widget.dashboardViewModel,
),
BottomNavigationItem(
icon: DoctorApp.dr_reply_1,
@ -68,6 +83,8 @@ class _BottomNavBarState extends State<BottomNavBar> {
index: widget.index,
currentIndex: 3,
name: TranslationBase.of(context).replay2,
dashboardViewModel: widget.dashboardViewModel,
),
],
),

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

Loading…
Cancel
Save