import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; // ignore: must_be_immutable class CustomBottomBar extends StatefulWidget { CustomBottomBar({this.onChanged}); Function(BottomBarEnum)? onChanged; @override CustomBottomBarState createState() => CustomBottomBarState(); } class CustomBottomBarState extends State { int selectedIndex = 2; List bottomMenuList = [ BottomMenuModel( icon: ImageConstant.imgNav, activeIcon: ImageConstant.imgNav, title: "diary".tr, type: BottomBarEnum.tf, ), BottomMenuModel( icon: ImageConstant.imgNavBlueGray400, activeIcon: ImageConstant.imgNavBlueGray400, title: "my_blog".tr, type: BottomBarEnum.tf, ), BottomMenuModel( icon: ImageConstant.imgNavBlueGray40024x23, activeIcon: ImageConstant.imgNavBlueGray40024x23, title: "profile".tr, type: BottomBarEnum.tf, ), BottomMenuModel( icon: ImageConstant.imgNavPrimary, activeIcon: ImageConstant.imgNavPrimary, title: "admin".tr, type: BottomBarEnum.tf, ), BottomMenuModel( icon: ImageConstant.imgNavBlueGray40024x25, activeIcon: ImageConstant.imgNavBlueGray40024x25, title: "chat".tr, type: BottomBarEnum.tf, ) ]; @override Widget build(BuildContext context) { return Container( height: 80.v, decoration: BoxDecoration( border: Border.all( color: appTheme.whiteA700, width: 1.h, ), ), child: BottomNavigationBar( backgroundColor: Colors.transparent, showSelectedLabels: false, showUnselectedLabels: false, selectedFontSize: 0, elevation: 0, currentIndex: selectedIndex, type: BottomNavigationBarType.fixed, items: List.generate(bottomMenuList.length, bottomMenu), onTap: changeMeny, ), ); } void changeMeny(index) { selectedIndex = index; widget.onChanged?.call(bottomMenuList[index].type); setState(() {}); } BottomNavigationBarItem bottomMenu(index) { return BottomNavigationBarItem( icon: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ CustomImageView( imagePath: bottomMenuList[index].icon, height: 24.v, width: 19.h, color: appTheme.blueGray400, ), Padding( padding: EdgeInsets.only(top: 8.v), child: Text( bottomMenuList[index].title ?? "", style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith( color: appTheme.blueGray800, ), ), ), ], ), activeIcon: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ CustomImageView( imagePath: bottomMenuList[index].activeIcon, height: 24.adaptSize, width: 24.adaptSize, color: theme.colorScheme.primary, ), Padding( padding: EdgeInsets.only(top: 9.v), child: Text( bottomMenuList[index].title ?? "", style: CustomTextStyles.bodySmallMulishPrimary.copyWith( color: theme.colorScheme.primary, ), ), ), ], ), label: '', ); } } enum BottomBarEnum { tf, } class BottomMenuModel { BottomMenuModel({ required this.icon, required this.activeIcon, this.title, required this.type, }); String icon; String activeIcon; String? title; BottomBarEnum type; }