import 'package:eatvio_app/core/app_export.dart'; import 'package:flutter/material.dart'; import 'package:eatvio_app/widgets/app_bar/appbar_title_circleimage.dart'; import 'package:eatvio_app/widgets/custom_navigation_menu.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.imgLogo, activeIcon: ImageConstant.imgLogo, type: BottomBarEnum.tf, image: false), BottomMenuModel( icon: ImageConstant.imgFeed, activeIcon: ImageConstant.imgFeed, title: "Лента", type: BottomBarEnum.tf, image: false), BottomMenuModel( icon: ImageConstant.imgDiary, activeIcon: ImageConstant.imgDiary, title: "diary".tr, type: BottomBarEnum.tf, image: false), BottomMenuModel( icon: ImageConstant.imgChat, activeIcon: ImageConstant.imgChat, title: "chat".tr, type: BottomBarEnum.tf, image: false), BottomMenuModel( icon: ImageConstant.imgBell, activeIcon: ImageConstant.imgBell, type: BottomBarEnum.tf, image: false), BottomMenuModel( icon: ImageConstant.imgEllipse1, activeIcon: ImageConstant.imgEllipse1, type: BottomBarEnum.tf, image: true, ), ]; @override Widget build(BuildContext context) { return Container( height: 83.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) { setState(() { selectedIndex = index; }); switch (index) { case 0: Navigator.pushNamed(context, AppRoutes.myProfile); break; case 1: break; case 2: Navigator.pushNamed(context, AppRoutes.diaryEdit); break; case 3: Navigator.pushNamed(context, AppRoutes.chatSelectScreen); break; } } BottomNavigationBarItem bottomMenu(index) { bool isSelected = selectedIndex == index; double iconHeight; double iconWidth; if (index == 0) { // Для логотипа- iconHeight = 52.v; // Увеличиваем высоту iconWidth = 48.h; // Меняем ширину, чтобы сохранить пропорции } else if (index == bottomMenuList.length - 2) { // Для колокольчика iconHeight = 20.v; // Уменьшаем высоту iconWidth = 20.h; // Меняем ширину, чтобы сохранить пропорции } else if (index == bottomMenuList.length - 1) { // Для колокольчика iconHeight = 40.v; // Уменьшаем высоту iconWidth = 40.h; // Меняем ширину, чтобы сохранить пропорции } else { // Для остальных иконок iconHeight = 24.v; // Стандартная высота iconWidth = 19.h; // Стандартная ширина } return BottomNavigationBarItem( icon: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ if (!bottomMenuList[index].image) CustomImageView( imagePath: bottomMenuList[index].icon, height: iconHeight, width: iconWidth, color: isSelected ? theme.colorScheme.primary : appTheme.blueGray400, ), if (bottomMenuList[index].image) GestureDetector( onTap: () => showMenu( context: context, color: Colors.white, shadowColor: Colors.white, surfaceTintColor: Colors.white, position: RelativeRect.fromLTRB( // Указываем позицию справа по центру MediaQuery.of(context).size.width - 50, // Расположение от правого края kToolbarHeight + 340, // Расположение от верхнего края 0, // Не смещаем по горизонтали 0, // Не смещаем по вертикали ), items: [ PopupMenuItem( child: CustomNavigationMenu(), // Используйте ваше меню здесь ) ], ), child: AppbarTitleCircleimage( imagePath: ImageConstant.imgEllipse1, ), ), if (bottomMenuList[index].title != null) // Проверяем, существует ли title Padding( padding: EdgeInsets.only(top: 8.v), child: Text( bottomMenuList[index].title!, style: CustomTextStyles.bodySmallMulishBluegray80012.copyWith( color: isSelected ? theme.colorScheme.primary : appTheme.blueGray800, ), ), ), ], ), activeIcon: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ CustomImageView( imagePath: bottomMenuList[index].activeIcon, height: iconHeight, // Используем тот же размер для активной иконки width: iconWidth, // Используем тот же размер для активной иконки 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, required this.image, }); String icon; String activeIcon; String? title; BottomBarEnum type; bool image; }