You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/widgets/bottom_navigation/bottom_nav_bar.dart

129 lines
5.2 KiB
Dart

import 'package:diplomaticquarterapp/core/viewModels/project_view_model.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/services/robo_search/event_provider.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.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<int>? changeIndex;
final int? index;
final bool showHomeIcon;
BottomNavBar({Key? key, this.changeIndex, this.index, this.showHomeIcon = false}) : super(key: key);
@override
_BottomNavBarState createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
int _index = 0;
ToDoCountProviderModel? model;
var event = RobotProvider();
_changeIndex(int index) async {
widget.changeIndex!(index);
if (index == 5) {
event.setValue({'isRobotVisible': 'true'});
}
}
@override
Widget build(BuildContext context) {
model = Provider.of<ToDoCountProviderModel>(context);
ProjectViewModel projectViewModel = Provider.of(context);
return BottomAppBar(
elevation: 4,
shape: CircularNotchedRectangle(),
color: Colors.white,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 18),
child: Directionality(
textDirection: TextDirection.ltr,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
BottomNavigationItem(
icon: "assets/images/new/bottom_nav/my_file.svg",
activeIcon: "assets/images/new/bottom_nav/my_file.svg",
changeIndex: _changeIndex,
index: widget.index,
currentIndex: 1,
name: TranslationBase.of(context).medicalFile,
),
BottomNavigationItem(
icon: "assets/images/new/bottom_nav/family_files.svg",
activeIcon: "assets/images/new/bottom_nav/family_files.svg",
changeIndex: _changeIndex,
index: widget.index,
currentIndex: 3,
name: TranslationBase.of(context).myFamily,
isDisabled: projectViewModel.isLoginChild,
),
if (widget.index == 0)
(widget.showHomeIcon)
? BottomNavigationItem(
icon: "assets/images/new/bottom_nav/home.svg",
activeIcon: "assets/images/new/bottom_nav/home.svg",
changeIndex: _changeIndex,
index: widget.index,
currentIndex: 2,
name: TranslationBase.of(context).home,
)
: Expanded(child: SizedBox()),
if (widget.index != 0 && projectViewModel.havePrivilege(34))
BottomNavigationItem(
icon: "assets/images/new/bottom_nav/home.svg",
activeIcon: "assets/images/new/bottom_nav/home.svg",
changeIndex: _changeIndex,
index: widget.index,
currentIndex: 0,
name: TranslationBase.of(context).home,
),
// BottomNavigationItem(
// icon: EvaIcons.calendar,
// activeIcon: EvaIcons.calendar,
// changeIndex: _changeIndex,
// index: _index,
// currentIndex: 2,
// name: TranslationBase.of(context).bookAppo,
// ),
if (/*widget.index == 0 && */ projectViewModel.havePrivilege(34))
BottomNavigationItem(
icon: "assets/images/new/bottom_nav/todo.svg",
activeIcon: "assets/images/new/bottom_nav/todo.svg",
changeIndex: _changeIndex,
index: widget.index,
currentIndex: 4,
name: TranslationBase.of(context).todoList,
),
if (projectViewModel.havePrivilege(77))
BottomNavigationItem(
icon: "assets/images/new/bottom_nav/help.svg",
activeIcon: "assets/images/new/bottom_nav/help.svg",
changeIndex: _changeIndex,
index: widget.index,
currentIndex: 5,
name: TranslationBase.of(context).help,
)
],
)),
),
);
}
Future navigateToBookingOptions(context) async {
Navigator.push(context, FadePage(page: BookingOptions()));
}
Future navigateToToDoList(context) async {
Navigator.push(context, FadePage(page: ToDo(isShowAppBar: false)));
}
}