forked from eatvio/eatvio_app
171 lines
4.2 KiB
Dart
171 lines
4.2 KiB
Dart
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<CustomBottomBar> {
|
|
int selectedIndex = 2;
|
|
|
|
List<BottomMenuModel> 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.imgNavBlueGray40024x23,
|
|
title: "Настройки",
|
|
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) {
|
|
setState(() {
|
|
selectedIndex = index;
|
|
});
|
|
|
|
switch (index) {
|
|
case 0:
|
|
Navigator.pushNamed(context, AppRoutes.diaryEdit);
|
|
break;
|
|
/*case 1:
|
|
Navigator.pushNamed(context, '/my_blog');
|
|
break;*/
|
|
case 1:
|
|
Navigator.pushNamed(context, AppRoutes.myProfile);
|
|
break;
|
|
case 2:
|
|
Navigator.pushNamed(context, AppRoutes.mySettings);
|
|
break;
|
|
case 3:
|
|
Navigator.pushNamed(context, '/chat');
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
|
|
BottomNavigationBarItem bottomMenu(index) {
|
|
bool isSelected = selectedIndex == index;
|
|
|
|
return BottomNavigationBarItem(
|
|
icon: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
CustomImageView(
|
|
imagePath: bottomMenuList[index].icon,
|
|
height: 24.v,
|
|
width: 19.h,
|
|
color:
|
|
isSelected ? theme.colorScheme.primary : appTheme.blueGray400,
|
|
),
|
|
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: 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;
|
|
}
|