import 'package:doctor_app_flutter/core/viewModel/dashboard_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'bottom_navigation_item.dart';

class BottomNavBar extends StatefulWidget {
  final ValueChanged<int> changeIndex;
  final int index;

  DashboardViewModel dashboardViewModel = DashboardViewModel();

  BottomNavBar({Key? key, required this.changeIndex, required this.index})
      : super(key: key);

  @override
  _BottomNavBarState createState() => _BottomNavBarState();
}

class _BottomNavBarState extends State<BottomNavBar> {
  int _index = 0;

  _changeIndex(int index) {
    widget.changeIndex(index);
    setState(() {
      _index = index;
    });
  }

  @override
  void initState() {
    widget.dashboardViewModel.getNotRepliedCount();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return BottomAppBar(
      elevation: 4,
      shape: CircularNotchedRectangle(),
      color: Colors.white,
      child: Container(
        decoration: BoxDecoration(
            border: Border.all(color: Color(0XFFEFEFEF), width: 1)),
        child: Padding(
          padding: EdgeInsets.symmetric(horizontal: 18),
          child: Row(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              BottomNavigationItem(
                icon: DoctorApp.home_1,
                activeIcon: DoctorApp.home_active_1,
                svgPath: "assets/images/svgs/bottom_nav/home-active.svg",
                changeIndex: _changeIndex,
                index: widget.index,
                currentIndex: 0,
                name: TranslationBase.of(context).home,
                dashboardViewModel: widget.dashboardViewModel,
              ),
              BottomNavigationItem(
                icon: DoctorApp.schedule_1,
                activeIcon: DoctorApp.schedule_active_1,
                svgPath: "assets/images/svgs/bottom_nav/schedule-active.svg",
                changeIndex: _changeIndex,
                index: widget.index,
                currentIndex: 1,
                name: TranslationBase.of(context).mySchedule,
                dashboardViewModel: widget.dashboardViewModel,
              ),
              BottomNavigationItem(
                icon: DoctorApp.qr_reader,
                activeIcon: DoctorApp.qr_reader_active_1,
                svgPath: "assets/images/svgs/bottom_nav/reader-active.svg",
                changeIndex: _changeIndex,
                index: widget.index,
                currentIndex: 2,
                name: TranslationBase.of(context).qr,
                dashboardViewModel: widget.dashboardViewModel,
              ),
              BottomNavigationItem(
                icon: DoctorApp.dr_reply_1,
                activeIcon: DoctorApp.dr_reply_active_1,
                svgPath: "assets/images/svgs/bottom_nav/reply-active.svg",
                changeIndex: _changeIndex,
                index: widget.index,
                currentIndex: 3,
                name: TranslationBase.of(context).replay2,
                dashboardViewModel: widget.dashboardViewModel,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
