forked from eatvio/eatvio_app
merge fromdiary to main
This commit is contained in:
@@ -30,7 +30,6 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppBar(
|
||||
elevation: 0,
|
||||
toolbarHeight: height ?? 56.v,
|
||||
automaticallyImplyLeading: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
|
||||
160
lib/widgets/bottom_navigation_bar_widget.dart
Normal file
160
lib/widgets/bottom_navigation_bar_widget.dart
Normal file
@@ -0,0 +1,160 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_navigation_menu.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
int currentBottomNavBarIndex = 0;
|
||||
|
||||
class BottomNavigationBarWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const BottomNavigationBarWidget({
|
||||
super.key,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BottomNavigationBarWidget> createState() => _BottomNavigationBarWidgetState();
|
||||
}
|
||||
|
||||
class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
|
||||
void _onItemTapped(int index) {
|
||||
if (currentBottomNavBarIndex != index) {
|
||||
setState(() {
|
||||
currentBottomNavBarIndex = index;
|
||||
});
|
||||
}
|
||||
switch (currentBottomNavBarIndex) {
|
||||
case 0:
|
||||
GoRouter.of(context).replace('/my-profile-screen');
|
||||
break;
|
||||
case 1:
|
||||
GoRouter.of(context).replace('/feed-screen');
|
||||
break;
|
||||
case 2:
|
||||
GoRouter.of(context).replace('/diary-screen');
|
||||
break;
|
||||
case 3:
|
||||
GoRouter.of(context).replace('/chat-select-screen');
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
|
||||
final size = overlay.size;
|
||||
showMenu(
|
||||
context: context,
|
||||
color: Colors.white,
|
||||
shadowColor: Colors.white,
|
||||
surfaceTintColor: Colors.white,
|
||||
items: [
|
||||
PopupMenuItem(
|
||||
child: CustomNavigationMenu(),
|
||||
)
|
||||
],
|
||||
position: RelativeRect.fromLTRB(size.width, size.height, 0, 0),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: widget.child,
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
onTap: _onItemTapped,
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
selectedItemColor: appTheme.blueA400,
|
||||
currentIndex: currentBottomNavBarIndex,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgLogo,
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'Лента',
|
||||
icon: SvgPicture.asset(
|
||||
width: 24,
|
||||
height: 24,
|
||||
ImageConstant.imgFeed,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgFeed,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "diary".tr,
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgDiary,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgDiary,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: "chat".tr,
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgChat,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
activeIcon: SvgPicture.asset(
|
||||
ImageConstant.imgBell,
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: ColorFilter.mode(
|
||||
appTheme.blueA400,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: '',
|
||||
icon: Image.asset(
|
||||
ImageConstant.imgEllipse1,
|
||||
width: 32,
|
||||
height: 32,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
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<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(
|
||||
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:
|
||||
Navigator.pushNamed(context, AppRoutes.feedScreen);
|
||||
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 = 50.v;
|
||||
iconWidth = 50.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;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart';
|
||||
import 'package:eatvio_app/widgets/custom_hyper_switch.dart';
|
||||
import 'package:eatvio_app/widgets/custom_hypo_switch.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:eatvio_app/widgets/next_step_button.dart';
|
||||
import 'dart:convert';
|
||||
@@ -395,10 +396,7 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
}
|
||||
|
||||
void _navigateToProfilePage() {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.myProfile,
|
||||
);
|
||||
GoRouter.of(context).go('/my-profile-screen');
|
||||
}
|
||||
|
||||
String _getErrorMessage(http.Response response) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:eatvio_app/widgets/custom_navigation_menu_item.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
@@ -16,33 +17,30 @@ class CustomNavigationMenu extends StatelessWidget {
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgSettings,
|
||||
text: 'Настройки профиля',
|
||||
onTap: () => Navigator.pushNamed(context, AppRoutes.mySettings),
|
||||
onTap: () => GoRouter.of(context).push('/my-settings-screen'),
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgRecipes,
|
||||
text: 'Мои рецепты',
|
||||
onTap: () =>
|
||||
Navigator.pushNamed(context, AppRoutes.recipeSelectScreen),
|
||||
onTap: () => GoRouter.of(context).push('/recipe-select-screen'),
|
||||
// Действие при нажатии на "Мои рецепты"
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgDiets,
|
||||
text: 'Мои диеты',
|
||||
onTap: () =>
|
||||
Navigator.pushNamed(context, AppRoutes.dietSelectScreen),
|
||||
onTap: () => GoRouter.of(context).push('/diet-select-screen'),
|
||||
// Действие при нажатии на "Мои рецепты"
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgPlans,
|
||||
text: 'Мои планы',
|
||||
onTap: () =>
|
||||
Navigator.pushNamed(context, AppRoutes.planSelectScreen),
|
||||
onTap: () => GoRouter.of(context).push('/plan-select-screen'),
|
||||
// Действие при нажатии на "Мои рецепты"
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgFinance,
|
||||
text: 'Глоссарий',
|
||||
onTap: () => Navigator.pushNamed(context, AppRoutes.glossaryScreen),
|
||||
onTap: () => GoRouter.of(context).push('/glossary-screen'),
|
||||
),
|
||||
MenuItem(
|
||||
icon: ImageConstant.imgSupport,
|
||||
@@ -77,10 +75,7 @@ _onTapLogout(BuildContext context) {
|
||||
if (response.statusCode == 204) {
|
||||
print(response.statusCode);
|
||||
box.delete('token'); // Удаляем токен из Hive
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.authScreen,
|
||||
);
|
||||
GoRouter.of(context).go('/auth-screen');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ class CustomTextFormField extends StatelessWidget {
|
||||
this.keyboardType,
|
||||
this.onFieldSubmitted,
|
||||
this.onSaved,
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
}) : super(
|
||||
key: key,
|
||||
);
|
||||
@@ -57,8 +59,10 @@ class CustomTextFormField extends StatelessWidget {
|
||||
final bool? filled;
|
||||
final TextInputType? keyboardType;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final String? initialValue;
|
||||
final Function(String)? onFieldSubmitted;
|
||||
final void Function(String?)? onSaved;
|
||||
final void Function(String?)? onChanged;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -69,13 +73,14 @@ class CustomTextFormField extends StatelessWidget {
|
||||
width: width ?? double.maxFinite,
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode ?? FocusNode(),
|
||||
focusNode: focusNode ?? null,
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? theme.textTheme.titleMedium,
|
||||
obscureText: obscureText!,
|
||||
textInputAction: textInputAction,
|
||||
maxLines: maxLines ?? 1,
|
||||
onFieldSubmitted: onFieldSubmitted,
|
||||
onChanged: onChanged,
|
||||
decoration: InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
||||
@@ -116,6 +121,7 @@ class CustomTextFormField extends StatelessWidget {
|
||||
validator: validator,
|
||||
onSaved: onSaved,
|
||||
inputFormatters: inputFormatters,
|
||||
initialValue: initialValue,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -124,11 +130,12 @@ class CustomTextFormField extends StatelessWidget {
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode ?? null,
|
||||
autofocus: autofocus ?? false,
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? theme.textTheme.titleMedium,
|
||||
obscureText: obscureText!,
|
||||
textInputAction: textInputAction,
|
||||
maxLines: maxLines ?? 1,
|
||||
initialValue: initialValue,
|
||||
decoration: InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? theme.textTheme.bodyLarge,
|
||||
@@ -211,4 +218,4 @@ class CustomTextFormField extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
}*/
|
||||
|
||||
Reference in New Issue
Block a user