import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/BookingOptions.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../d_q_icons_icons.dart'; import 'bottom_navigation_item.dart'; class BottomNavBar extends StatefulWidget { final ValueChanged changeIndex; final int index ; BottomNavBar({Key key, this.changeIndex,this.index}) : super(key: key); @override _BottomNavBarState createState() => _BottomNavBarState(); } class _BottomNavBarState extends State { int _index = 0; ToDoCountProviderModel model; AuthenticatedUserObject authenticatedUserObject = locator(); _changeIndex(int index) { if (index != 4) widget.changeIndex(index); else { if (authenticatedUserObject.isLogin) { if (model.count != 0) { widget.changeIndex(index); } else { AppToast.showErrorToast( message: TranslationBase.of(context).upcomingEmpty); } } else { widget.changeIndex(index); } } } @override Widget build(BuildContext context) { model = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context); return BottomAppBar( elevation: 4, shape: CircularNotchedRectangle(), color: Colors.white, child: Padding( padding: EdgeInsets.symmetric(horizontal: 18), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ BottomNavigationItem( icon: EvaIcons.home, activeIcon: EvaIcons.home, changeIndex: _changeIndex, index: widget.index, currentIndex: 0, name: TranslationBase.of(context).home, ), BottomNavigationItem( icon: DQIcons.my_medical_file, activeIcon: DQIcons.my_medical_file, changeIndex: _changeIndex, index: widget.index, currentIndex: 1, name: TranslationBase.of(context).medicalProfile, ), if(widget.index == 0 && projectViewModel.havePrivilege(34)) Expanded( child: SizedBox( height: 50, child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox(height: 22), ], ), ), ), if(widget.index != 0 && projectViewModel.havePrivilege(34)) BottomNavigationItem( icon: EvaIcons.calendar, activeIcon: EvaIcons.calendar, changeIndex: _changeIndex, index: _index, currentIndex: 2, name: TranslationBase.of(context).bookAppo, ), BottomNavigationItem( icon: DQIcons.family, activeIcon: DQIcons.family, changeIndex: _changeIndex, index: widget.index, currentIndex: 3, name: TranslationBase.of(context).myFamily, ), if(projectViewModel.havePrivilege(51)) BottomNavigationItem( icon: EvaIcons.calendar, activeIcon: EvaIcons.calendar, changeIndex: _changeIndex, index: widget.index, currentIndex: 4, name: TranslationBase.of(context).todoList, ) ], ), ), ); } Future navigateToBookingOptions(context) async { Navigator.push( context, MaterialPageRoute(builder: (context) => BookingOptions())); } Future navigateToToDoList(context) async { Navigator.push(context, MaterialPageRoute(builder: (context) => ToDo(isShowAppBar: false))); } }