import 'package:aman_kassa_flutter/redux/constants/setting_const.dart';
import 'package:aman_kassa_flutter/redux/state/setting_state.dart';
import 'package:aman_kassa_flutter/redux/store.dart';
import 'package:aman_kassa_flutter/shared/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

class BottomBar extends StatelessWidget {
  final PageController pageController;
  final int selectedTabIndex;

  BottomBar({
    required this.pageController,
    required this.selectedTabIndex,
  });

  @override
  Widget build(BuildContext context) {
    return StoreConnector<AppState, SettingState>(
        converter: (store) => store.state.settingState!,
        builder: (context, vm) {
          return BottomNavigationBar(
            currentIndex: selectedTabIndex,
            showUnselectedLabels: true,
            backgroundColor: menuColor,
            type: BottomNavigationBarType.shifting,
            items: [
              vm.mode == SettingModeKassa
                  ? BottomNavigationBarItem(
                      backgroundColor: menuColor,
                      icon: Icon(MdiIcons.cashRegister, color: Colors.white),
                      label: 'Касса',
                      // title: new Text(
                      //   'Касса',
                      //   style: TextStyle(color: Colors.white),
                      // )
                  )
                  : BottomNavigationBarItem(
                      backgroundColor: menuColor,
                      icon: Icon(MdiIcons.calculator, color: Colors.white),
                      label: 'Калькулятор',
                      // title: new Text(
                      //   'Калькулятор',
                      //   style: TextStyle(color: Colors.white),
                      // )
                  ),
              BottomNavigationBarItem(
                  backgroundColor: menuColor,
                  icon: Icon(MdiIcons.tune, color: Colors.white),
                  label: 'Опции'
                  // title: new Text(
                  //   'Опции',
                  //   style: TextStyle(color: Colors.white),
                  // )
              ),
            ],
            onTap: (index) {
              pageController.animateToPage(
                index,
                duration: const Duration(milliseconds: 300),
                curve: Curves.easeIn,
              );
            },
          );
        });
  }
}
