import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';

class CustomBottomNavbar extends StatelessWidget {
  final int selectedNavbarBarIndex;
  final Function(int) onSelected;

  const CustomBottomNavbar({Key? key, required this.onSelected, required this.selectedNavbarBarIndex}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BottomNavigationBar(
      items: <BottomNavigationBarItem>[
        BottomNavigationBarItem(
          icon: SvgPicture.asset(MyAssets.providersIcon).paddingAll(5),
          activeIcon: SvgPicture.asset(MyAssets.providersIcon, color: MyColors.darkIconColor).paddingAll(5),
          label: LocaleKeys.providers.tr(),
        ),
        BottomNavigationBarItem(
          icon: SvgPicture.asset(MyAssets.appointmentsIcon).paddingAll(5),
          activeIcon: SvgPicture.asset(MyAssets.appointmentsIcon, color: MyColors.darkIconColor).paddingAll(5),
          label: LocaleKeys.appointments.tr(),
        ),
        BottomNavigationBarItem(
          icon: SvgPicture.asset(
            MyAssets.homeIcon,
            color: MyColors.lightIconColor,
          ).paddingAll(5),
          activeIcon: SvgPicture.asset(MyAssets.homeIcon, color: MyColors.darkIconColor).paddingAll(5),
          label: LocaleKeys.home.tr(),
        ),
        BottomNavigationBarItem(
          icon: SvgPicture.asset(MyAssets.announcementIcon).paddingAll(5),
          activeIcon: SvgPicture.asset(MyAssets.announcementIcon, color: MyColors.darkIconColor).paddingAll(5),
          label: LocaleKeys.ads.tr(),
        ),
        BottomNavigationBarItem(
          icon: SvgPicture.asset(MyAssets.settingsIcon).paddingAll(5),
          activeIcon: SvgPicture.asset(MyAssets.settingsIcon, color: MyColors.darkIconColor).paddingAll(5),
          label: LocaleKeys.settings.tr(),
        ),
      ],
      currentIndex: selectedNavbarBarIndex,
      type: BottomNavigationBarType.fixed,
      selectedItemColor: MyColors.darkIconColor,
      showSelectedLabels: true,
      showUnselectedLabels: true,
      unselectedItemColor: MyColors.lightTextColor,
      unselectedFontSize: 11,
      selectedFontSize: 11,
      selectedLabelStyle: const TextStyle(fontFamily: "Poppins"),
      unselectedLabelStyle: const TextStyle(fontFamily: "Poppins"),
      onTap: (index) => onSelected(index),
    );
  }
}
