import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:tanami_app/core/styles/app_color.dart';

import 'bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
import 'bloc/bottom_nav_bar/bottom_navigation_event.dart';

Widget bottomnavigationbar(
    BuildContext context, selectedIndex, PageController pageController) {
  return BottomNavigationBar(
    backgroundColor: AppColor.plainWhite,
    type: BottomNavigationBarType.fixed,
    showUnselectedLabels: true,
    selectedItemColor: AppColor.selectedItemColor,
    unselectedItemColor: AppColor.unselectedItemColor,
    unselectedLabelStyle: GoogleFonts.dmSans(
      fontSize: 10.sp,
      color: AppColor.unselectedItemColor,
      fontWeight: FontWeight.w400,
    ),
    selectedLabelStyle: GoogleFonts.dmSans(
      fontSize: 10.sp,
      color: AppColor.selectedItemColor,
      fontWeight: FontWeight.w400,
    ),
    currentIndex: selectedIndex,
    onTap: (index) {
      pageController.jumpToPage(index);

      context.read<BottomNavigationBloc>().add(TabChanged(index));
    },
    items: [
      BottomNavigationBarItem(
        icon: Image.asset(
          'assets/images/bottom_bar/inactive/wallet.png',
          height: 26.h,
          width: 26.w,
        ),
        activeIcon: Image.asset(
          'assets/images/bottom_bar/active/wallet.png',
          height: 30.h,
          width: 30.w,
        ),
        label: 'Wallet',
      ),
      BottomNavigationBarItem(
        icon: Image.asset(
          'assets/images/bottom_bar/inactive/portfolio.png',
          height: 26.h,
          width: 26.w,
        ),
        activeIcon: Image.asset(
          'assets/images/bottom_bar/active/portfolio.png',
          height: 30.h,
          width: 30.w,
        ),
        label: 'Portfolio',
      ),
      BottomNavigationBarItem(
        icon: Image.asset(
          'assets/images/bottom_bar/inactive/invest.png',
          height: 24.h,
          width: 24.w,
        ),
        activeIcon: Image.asset(
          'assets/images/bottom_bar/active/invest.png',
          height: 28.h,
          width: 28.w,
        ),
        label: 'Invest',
      ),
      BottomNavigationBarItem(
        icon: Image.asset(
          'assets/images/bottom_bar/inactive/academy.png',
          height: 26.h,
          width: 26.w,
        ),
        activeIcon: Image.asset(
          'assets/images/bottom_bar/active/academy.png',
          height: 30.h,
          width: 30.w,
        ),
        label: 'Academy',
      ),
      BottomNavigationBarItem(
        icon: Image.asset(
          'assets/images/bottom_bar/inactive/settings.png',
          height: 26.h,
          width: 26.w,
        ),
        activeIcon: Image.asset(
          'assets/images/bottom_bar/active/settings.png',
          height: 30.h,
          width: 30.w,
        ),
        label: 'Settings',
      ),
    ],
  );
}
