
import 'package:hmg_patient_app/pages/BookAppointment/BookingOptions.dart';
import 'package:hmg_patient_app/pages/DrawerPages/family/my-family.dart';
import 'package:hmg_patient_app/pages/ToDoList/ToDo.dart';
import 'package:hmg_patient_app/pages/landing/home_page_2.dart';
import 'package:hmg_patient_app/pages/medical/medical_profile_page_new.dart';
import 'package:hmg_patient_app/widgets/bottom_navigation/bottom_nav_bar.dart';
import 'package:hmg_patient_app/widgets/buttons/floatingActionButton.dart';
import 'package:flutter/material.dart';

class H20BottomNavigationBar extends StatelessWidget {
  H20BottomNavigationBar({Key? key}) : super(key: key);

  PageController pageController = PageController(keepPage: true);
  int currentTab = 0;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: PageView(
        physics: NeverScrollableScrollPhysics(),
        controller: pageController,
        children: [
          HomePage2(
            goToMyProfile: () {
              _changeCurrentTab(1);
            },
          ),
          MedicalProfilePageNew(),
          BookingOptions(),
          MyFamily(isAppbarVisible: false),
          ToDo(isShowAppBar: false),
        ], // Please do not remove the BookingOptions from this array
      ),
      bottomNavigationBar: BottomNavBar(
        changeIndex: _changeCurrentTab,
        index: currentTab,
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
      floatingActionButton: FloatingButton(
          elevation: true,
          onTap: () {
            _changeCurrentTab(2);
          }),
    );
  }

  _changeCurrentTab(int tab) {
    // setState(() {
    currentTab = tab;
    if (tab != 0)
      pageController.jumpToPage(tab);
    else {
      pageController.jumpToPage(tab);
    }
    // });
  }
}
