import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:flutter/material.dart';
import 'package:gradient_bottom_navigation_bar/gradient_bottom_navigation_bar.dart';

// ignore: must_be_immutable
class BottomNavigator extends StatefulWidget {
  int bottomNavIndex = 0;
  BottomNavigator({this.bottomNavIndex}) {
    this.bottomNavIndex = bottomNavIndex;
  }

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

class _NawDrawerWidget extends State<BottomNavigator> {


  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final Color bgrColor = Color(0xffb4f500);
    final Color bgrColorEnd = Colors.blue;
    final Color active = Colors.black;
    final Color inactive = Colors.black26;

    /*final Color bgrColor = Colors.black;
    final Color active = Colors.yellowAccent;
    final Color inactive = Colors.white60;*/
//

    return GradientBottomNavigationBar(
        currentIndex: widget.bottomNavIndex, // this will be set when a new tab is tapped
        backgroundColorStart: bgrColorEnd,
        backgroundColorEnd: bgrColor,
        fixedColor: active,
        //selectedItemColor: active,
        //unselectedItemColor: inactive,
        //showSelectedLabels: true,
        //showUnselectedLabels: true,
        items: [
          BottomNavigationBarItem(
            backgroundColor: bgrColor,
            icon: new Icon(Icons.home, color: inactive),
            activeIcon: new Icon(Icons.home, color: active,),
            title: new Text(AppLocalizations.of(context).translate("Home"),
              style: TextStyle(fontSize: 9)),
          ),
          BottomNavigationBarItem(
            backgroundColor: bgrColor,
            icon: new Icon(Icons.trending_up, color: inactive),
            activeIcon: new Icon(Icons.trending_up, color: active,),
            title: new Text(AppLocalizations.of(context).translate("My Development"),
              style: TextStyle(fontSize: 9),),
          ),

          BottomNavigationBarItem(
            backgroundColor: bgrColor,
            icon: new Icon(Icons.featured_play_list, color: inactive),
            activeIcon: new Icon(Icons.featured_play_list, color: active,),
            title: new Text(AppLocalizations.of(context).translate("My Training Plan"),
            style: TextStyle(fontSize: 9),),
          ),

          BottomNavigationBarItem(
              backgroundColor: bgrColor,
              icon: Icon(Icons.person, color: inactive,),
              activeIcon: new Icon(Icons.person, color: active,),
              title: Text(AppLocalizations.of(context).translate("Account"),
                style: TextStyle(fontSize: 9),)
          ),
          BottomNavigationBarItem(
              backgroundColor: bgrColor,
              icon: Icon(Icons.settings, color: inactive),
              activeIcon: new Icon(Icons.settings, color: active,),
              title: Text(AppLocalizations.of(context).translate("Settings"),
                style: TextStyle(fontSize: 9))
          )
        ],
        onTap:(index) {
            setState(() {
              widget.bottomNavIndex = index;
              switch (index) {
                case 0:
                  Navigator.of(context).pop();
                  Navigator.of(context).pushNamed('home');

                  break;
                case 1:
                  Navigator.of(context).pop();
                  Navigator.of(context).pushNamed('myDevelopment');
                  break;
                case 2:

                  Navigator.of(context).pop();
                  Navigator.of(context).pushNamed('myExercisePlan');

                  break;
                case 3:
                  Navigator.of(context).pop();
                  Navigator.of(context).pushNamed('account');

                  break;
                case 4:
                  Navigator.of(context).pop();
                  Navigator.of(context).pushNamed('settings');

                  break;
              }

            });
        }

    );
  }


}