forked from eatvio/eatvio_app
go router
This commit is contained in:
@@ -67,6 +67,7 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
},
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
selectedItemColor: appTheme.blueA400,
|
||||
currentIndex: currentBottomNavBarIndex,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
@@ -76,18 +77,46 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
BottomNavigationBarItem(
|
||||
label: 'Лента',
|
||||
icon: SvgPicture.asset(ImageConstant.imgFeed),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgFeed,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "diary".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgDiary),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgDiary,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "chat".tr,
|
||||
icon: SvgPicture.asset(ImageConstant.imgChat),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(ImageConstant.imgBell),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
@@ -102,223 +131,3 @@ class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CustomBottomBar extends StatefulWidget {
|
||||
CustomBottomBar({this.onChanged});
|
||||
|
||||
Function(BottomBarEnum)? onChanged;
|
||||
|
||||
@override
|
||||
CustomBottomBarState createState() => CustomBottomBarState();
|
||||
}
|
||||
|
||||
class CustomBottomBarState extends State<CustomBottomBar> {
|
||||
int selectedIndex = 2;
|
||||
|
||||
List<BottomMenuModel> 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.pushReplacementNamed(context, AppRoutes.myProfile);
|
||||
break;
|
||||
case 1:
|
||||
Navigator.pushReplacementNamed(context, AppRoutes.feedScreen);
|
||||
break;
|
||||
case 2:
|
||||
Navigator.pushReplacementNamed(context, AppRoutes.diaryEdit);
|
||||
break;
|
||||
case 3:
|
||||
Navigator.pushReplacementNamed(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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user