go router

This commit is contained in:
mso7nueh
2024-06-05 12:52:03 +03:00
parent ed0c3fcef1
commit 1951edd8f8
28 changed files with 1160 additions and 1448 deletions

View File

@@ -3,7 +3,7 @@ name: Android Release
on: [push, pull_request]
env:
flutter_version: "3.19.0"
flutter_version: "3.22.0"
java_version: "12.x"
flutter_channel: "stable"

View File

@@ -3,7 +3,7 @@ name: Eatvio App Android Test
on: [pull_request]
env:
flutter_version: "3.19.0"
flutter_version: "3.22.0"
java_version: "12.x"
flutter_channel: "stable"

View File

@@ -1,14 +1,44 @@
import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart';
import 'package:eatvio_app/presentation/chat/chat_select_screen/chat_select_screen.dart';
import 'package:eatvio_app/presentation/diary/diary_edit_screen/diary_edit_screen.dart';
import 'package:eatvio_app/presentation/diets/diet_select_screen/diet_select_screen.dart';
import 'package:eatvio_app/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart';
import 'package:eatvio_app/presentation/feed/blog_post_screen/blog_post_screen.dart';
import 'package:eatvio_app/presentation/feed/feed_screen/feed_screen.dart';
import 'package:eatvio_app/presentation/glossary/glossary_screen/glossary_screen.dart';
import 'package:eatvio_app/presentation/plans/plan_select_screen/plan_select_screen.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_profile_screen.dart';
import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_screen.dart';
import 'package:eatvio_app/presentation/recipe/recipe_select_screen/recipe_select_screen.dart';
import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
import 'package:go_router/go_router.dart';
import 'package:hive_flutter/hive_flutter.dart';
class AppRouter {
static GoRouter appRouter = GoRouter(
initialLocation: '/my-profile-screen',
initialLocation: '/auth-screen',
routes: [
GoRoute(
path: '/auth-screen',
name: 'authScreen',
redirect: (context, state) async {
final box = await Hive.openBox('token');
final token = box.get('token');
if (token != null) {
return '/my-profile-screen';
}
return null;
},
builder: (context, state) => AuthScreen.builder(context),
routes: [
GoRoute(
path: 'language-select-screen',
name: 'languageSelectScreen',
builder: (context, state) => LanguageSelectScreen.builder(context),
),
],
),
ShellRoute(
builder: (context, state, child) {
return BottomNavigationBarWidget(child: child);
@@ -23,6 +53,21 @@ class AppRouter {
path: '/feed-screen',
name: 'feedScreen',
builder: (context, state) => FeedScreen(),
routes: [
GoRoute(
path: 'blog-post-create-screen',
name: 'blogPostCreateScreen',
builder: (context, state) => BlogPostCreateScreen.builder(context),
),
GoRoute(
path: 'blog-post-screen',
name: 'blogPostScreen',
builder: (context, state) => BlogPostScreen.builder(
context,
state.extra.toString(),
),
),
],
),
GoRoute(
path: '/diary-screen',
@@ -36,6 +81,31 @@ class AppRouter {
),
],
),
GoRoute(
path: '/my-settings-screen',
name: 'mySettingsScreen',
builder: (context, state) => MySettingsScreen.builder(context),
),
GoRoute(
path: '/recipe-select-screen',
name: 'recipeSelectScreen',
builder: (context, state) => RecipeSelectScreen.builder(context),
),
GoRoute(
path: '/diet-select-screen',
name: 'dietSelectScreen',
builder: (context, state) => DietSelectScreen.builder(context),
),
GoRoute(
path: '/plan-select-screen',
name: 'planSelectScreen',
builder: (context, state) => PlanSelectScreen.builder(context),
),
GoRoute(
path: '/glossary-screen',
name: 'glossaryScreen',
builder: (context, state) => GlossaryScreen.builder(context),
),
],
);
}

View File

@@ -1,3 +1,5 @@
import 'package:go_router/go_router.dart';
import 'bloc/auth_bloc.dart';
import 'models/auth_model.dart';
import 'package:eatvio_app/core/app_export.dart';
@@ -101,10 +103,7 @@ class AuthScreen extends StatelessWidget {
final box = await Hive.openBox('token');
final token = res['token'];
box.put('token', token);
Navigator.pushNamed(
context,
AppRoutes.myProfile,
);
GoRouter.of(context).go('/my-profile-screen');
} else {
showDialog(
context: context,
@@ -164,7 +163,7 @@ class AuthScreen extends StatelessWidget {
onTapNoAccount(BuildContext context) {
return () {
Navigator.pushNamed(context, AppRoutes.languageSelectScreen);
GoRouter.of(context).goNamed('languageSelectScreen');
};
}

View File

@@ -59,7 +59,6 @@ class ChatScreen extends StatelessWidget {
),
),
),
bottomNavigationBar: _buildTextField(context),
);
}
@@ -160,18 +159,6 @@ class ChatScreen extends StatelessWidget {
);
}
/// Common widget
///Handling route based on bottom click actions
String getCurrentRoute(BottomBarEnum type) {
switch (type) {
case BottomBarEnum.tf:
return AppRoutes.chatScreen;
default:
return "/";
}
}
///Handling page based on route
Widget getCurrentPage(
BuildContext context,

View File

@@ -1,5 +1,7 @@
// ignore_for_file: unused_local_variable
import 'package:go_router/go_router.dart';
import 'bloc/diary_edit_bloc.dart';
import 'models/diary_edit_model.dart';
import 'package:flutter/material.dart';
@@ -47,10 +49,10 @@ class DiaryEditScreen extends StatelessWidget {
}
Widget _buildDiaryEditScreen(BuildContext context, DiaryEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return RefreshIndicator(
onRefresh: refreshPage(context),
child: Stack(
alignment: Alignment.bottomCenter,
children: [
FormBuilder(
child: SafeArea(
@@ -89,12 +91,7 @@ class DiaryEditScreen extends StatelessWidget {
),
),
),
Positioned(
left: 16.h,
right: 16.h,
bottom: 50.v, // Adjusted position to lift the button higher
child: _buildEndDay(context),
),
_buildEndDay(context),
],
),
);
@@ -106,7 +103,7 @@ class DiaryEditScreen extends StatelessWidget {
margin: EdgeInsets.only(
left: 16.h,
right: 16.h,
bottom: 41.v,
bottom: 16.v,
),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
decoration: BoxDecoration(
@@ -147,7 +144,10 @@ class DiaryEditScreen extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomImageView(imagePath: ImageConstant.imgArrowLeft, onTap: onTapBack()),
CustomImageView(
imagePath: ImageConstant.imgArrowLeft,
onTap: () => GoRouter.of(context).pop(),
),
Padding(
padding: EdgeInsets.only(top: 1.v),
child: Column(
@@ -172,12 +172,6 @@ class DiaryEditScreen extends StatelessWidget {
);
}
onTapBack() {
return () {
NavigatorService.goBack();
};
}
/// Section Widget
_buildAddProduct(BuildContext context, DiaryEditLoadedState state) {
return CustomOutlinedButton(

View File

@@ -6,12 +6,11 @@ import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
class DietCreateScreen extends StatelessWidget {
const DietCreateScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final dietID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<DietCreateBloc>(
create: (context) => DietCreateBloc(DietCreateState(
dietModelObj: DietCreateModel(dietID: dietID.toString())))
..add(DietCreateInitialEvent()),
create: (context) => DietCreateBloc(DietCreateState(dietModelObj: DietCreateModel(dietID: dietID.toString())))..add(DietCreateInitialEvent()),
child: DietCreateScreen());
}
@@ -40,58 +39,54 @@ class DietCreateScreen extends StatelessWidget {
_buildDietCreate(BuildContext context, DietCreateLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 16.0),
TextFormField(
controller: state.name,
decoration: InputDecoration(labelText: 'Заголовок'),
),
SizedBox(height: 16.0),
TextFormField(
controller: state.details,
decoration: InputDecoration(labelText: 'Описание'),
),
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () =>
context.read<DietCreateBloc>().add(CreateDiet()),
child: Text('Создать'),
)
]),
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 16.0),
TextFormField(
controller: state.name,
decoration: InputDecoration(labelText: 'Заголовок'),
),
SizedBox(height: 16.0),
TextFormField(
controller: state.details,
decoration: InputDecoration(labelText: 'Описание'),
),
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () => context.read<DietCreateBloc>().add(CreateDiet()),
child: Text('Создать'),
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
)
]),
),
),
);
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}

View File

@@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class DietEditScreen extends StatelessWidget {
const DietEditScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final dietID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<DietEditBloc>(
create: (context) => DietEditBloc(DietEditState(
dietModelObj: DietEditModel(dietID: dietID.toString())))
..add(DietEditInitialEvent()),
create: (context) => DietEditBloc(DietEditState(dietModelObj: DietEditModel(dietID: dietID.toString())))..add(DietEditInitialEvent()),
child: DietEditScreen());
}
@@ -42,42 +41,43 @@ class DietEditScreen extends StatelessWidget {
_buildDietEdit(BuildContext context, DietEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.diet?['image'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! + (state.diet?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
placeholder: (context, url) =>
CircularProgressIndicator(),
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
@@ -97,18 +97,16 @@ class DietEditScreen extends StatelessWidget {
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () =>
context.read<DietEditBloc>().add(EditDiet()),
onPressed: () => context.read<DietEditBloc>().add(EditDiet()),
child: Text('Сохранить'),
)
]),
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
],
),
)
],
),
),
),
);
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}

View File

@@ -1,3 +1,5 @@
import 'package:go_router/go_router.dart';
import 'bloc/diet_select_bloc.dart';
import 'models/diet_select_model.dart';
import 'package:eatvio_app/core/app_export.dart';
@@ -39,75 +41,71 @@ class DietSelectScreen extends StatelessWidget {
}
_buildSetingsScreen(BuildContext context, DietSelectLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: onTapBack(context),
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(
children: [
AppbarSubtitle(
text: "Диеты",
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v),
),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () => Navigator.pushNamed(
context,
AppRoutes.dietCreateScreen,
),
child: Icon(Icons.create_outlined)),
)
],
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: () => GoRouter.of(context).pop(),
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(
children: [
AppbarSubtitle(
text: "Диеты",
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v),
),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () => Navigator.pushNamed(
context,
AppRoutes.dietCreateScreen,
),
child: Icon(Icons.create_outlined)),
)
],
),
),
),
SizedBox(height: 20),
_buildDietList(context, state)
],
),
),
SizedBox(height: 20),
_buildDietList(context, state)
],
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
);
}
@@ -174,10 +172,6 @@ class DietSelectScreen extends StatelessWidget {
};
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
onTapArrowLeft(BuildContext context) {
NavigatorService.goBack();
}

View File

@@ -8,13 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class DietScreen extends StatelessWidget {
const DietScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final dietID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<DietBloc>(
create: (context) => DietBloc(
DietState(dietModelObj: DietModel(dietID: dietID.toString())))
..add(DietInitialEvent()),
child: DietScreen());
create: (context) => DietBloc(DietState(dietModelObj: DietModel(dietID: dietID.toString())))..add(DietInitialEvent()), child: DietScreen());
}
Widget build(BuildContext context) {
@@ -42,92 +40,78 @@ class DietScreen extends StatelessWidget {
_buildDiet(BuildContext context, DietLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! + (state.diet?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.diet?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
placeholder: (context, url) =>
CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
radius: 25,
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
radius: 25,
),
),
SizedBox(height: 16.0),
Text(state.diet?['name'], style: CustomTextStyles.titleMediumBlack),
SizedBox(height: 8.0),
Text(
state.diet?['details'],
),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () => Navigator.pushNamed(
context,
AppRoutes.dietEditScreen,
arguments: state.diet?['id'].toString(),
),
child: Text('Редактировать'),
),
SizedBox(height: 16.0),
Text(state.diet?['name'],
style: CustomTextStyles.titleMediumBlack),
SizedBox(height: 8.0),
Text(
state.diet?['details'],
ElevatedButton(
onPressed: () => context.read<DietBloc>().add(DeleteEntry(state.diet?['id'])),
child: Text('Удалить'),
),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () => Navigator.pushNamed(
context,
AppRoutes.dietEditScreen,
arguments: state.diet?['id'].toString(),
),
child: Text('Редактировать'),
),
ElevatedButton(
onPressed: () => context
.read<DietBloc>()
.add(DeleteEntry(state.diet?['id'])),
child: Text('Удалить'),
),
],
)
]),
],
)
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
}
///Handling route based on bottom click actions
String getCurrentRoute(BottomBarEnum type) {
switch (type) {
case BottomBarEnum.tf:
return AppRoutes.dietScreen;
default:
return "/";
}
]),
)
],
),
),
),
);
}
///Handling page based on route
@@ -143,10 +127,6 @@ class DietScreen extends StatelessWidget {
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
/// Navigates to the previous screen.
onTapArrowleftone(BuildContext context) {
NavigatorService.goBack();

View File

@@ -2,18 +2,16 @@ import 'bloc/blog_post_create_bloc.dart';
import 'models/blog_post_create_model.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
class BlogPostCreateScreen extends StatelessWidget {
const BlogPostCreateScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final blog_postID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<BlogPostCreateBloc>(
create: (context) => BlogPostCreateBloc(BlogPostCreateState(
blog_postModelObj:
BlogPostCreateModel(blog_postID: blog_postID.toString())))
create: (context) => BlogPostCreateBloc(BlogPostCreateState(blog_postModelObj: BlogPostCreateModel(blog_postID: blog_postID.toString())))
..add(BlogPostCreateInitialEvent()),
child: BlogPostCreateScreen());
}
@@ -41,92 +39,85 @@ class BlogPostCreateScreen extends StatelessWidget {
}
_buildBlogPostCreate(BuildContext context, BlogPostCreateLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Column(
children: <Widget>[
Text("Заголовок новости", style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.title,
validator: _validateTitle,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
SizedBox(height: 8.0),
Text("Ссылка на YouTube", style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.youtube_url,
validator: _validateYouTubeLink,
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
Column(
children: <Widget>[
Text("Заголовок новости",
style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.title,
validator: _validateTitle,
),
SizedBox(height: 8.0),
Text("Ссылка на YouTube",
style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.youtube_url,
validator: _validateYouTubeLink,
),
SizedBox(height: 8.0),
Text("Описание", style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.description,
validator: _validateDescription,
maxLines: 6,
),
SizedBox(height: 16.0),
// Add widget for image upload here
CustomOutlinedButton(
onPressed: () => _submitForm(
context,
state.title!.text,
state.description!.text,
state.youtube_url!.text),
buttonStyle:
CustomButtonStyles.outlinePrimaryTL15,
text: 'Создать',
),
],
),
]))
])),
bottomNavigationBar: _buildBottomBar(context)));
SizedBox(height: 8.0),
Text("Описание", style: theme.textTheme.bodyLarge),
CustomTextFormField(
controller: state.description,
validator: _validateDescription,
maxLines: 6,
),
SizedBox(height: 16.0),
// Add widget for image upload here
CustomOutlinedButton(
onPressed: () => _submitForm(context, state.title!.text, state.description!.text, state.youtube_url!.text),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
text: 'Создать',
),
],
),
],
),
)
],
),
),
);
}
}
_submitForm(
BuildContext context, String title, String description, String youtubeURL) {
_submitForm(BuildContext context, String title, String description, String youtubeURL) {
String? titleError = _validateTitle(title);
String? descriptionError = _validateDescription(description);
String? youtubeURLError = _validateYouTubeLink(youtubeURL);
if (titleError != null ||
descriptionError != null ||
youtubeURLError != null) {
if (titleError != null || descriptionError != null || youtubeURLError != null) {
// Display error messages or handle invalid input as needed
// For example, show a snackbar with the error message
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(titleError ?? descriptionError ?? youtubeURLError!)),
SnackBar(content: Text(titleError ?? descriptionError ?? youtubeURLError!)),
);
} else {
// Proceed with form submission
@@ -158,11 +149,6 @@ String? _validateYouTubeLink(value) {
}
bool _isValidUrl(String url) {
final RegExp urlRegExp =
new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$");
final RegExp urlRegExp = new RegExp(r"^(http|https):\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$");
return urlRegExp.hasMatch(url);
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}

View File

@@ -8,13 +8,12 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class BlogPostEditScreen extends StatelessWidget {
const BlogPostEditScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final blog_postID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<BlogPostEditBloc>(
create: (context) => BlogPostEditBloc(BlogPostEditState(
blog_postModelObj:
BlogPostEditModel(blog_postID: blog_postID.toString())))
..add(BlogPostEditInitialEvent()),
create: (context) =>
BlogPostEditBloc(BlogPostEditState(blog_postModelObj: BlogPostEditModel(blog_postID: blog_postID.toString())))..add(BlogPostEditInitialEvent()),
child: BlogPostEditScreen());
}
@@ -43,42 +42,43 @@ class BlogPostEditScreen extends StatelessWidget {
_buildBlogPostEdit(BuildContext context, BlogPostEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.blog_post?['image'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! + (state.blog_post?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
placeholder: (context, url) =>
CircularProgressIndicator(),
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
@@ -103,18 +103,16 @@ class BlogPostEditScreen extends StatelessWidget {
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () =>
context.read<BlogPostEditBloc>().add(EditBlogPost()),
onPressed: () => context.read<BlogPostEditBloc>().add(EditBlogPost()),
child: Text('Сохранить'),
)
]),
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
],
),
)
],
),
),
),
);
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}

View File

@@ -1,10 +1,11 @@
import 'package:go_router/go_router.dart';
import 'bloc/blog_post_bloc.dart';
import 'models/blog_post_model.dart';
import 'widgets/comment_widget.dart';
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
import 'package:eatvio_app/widgets/custom_edit_text_form_field.dart';
import 'package:eatvio_app/widgets/custom_outlined_button.dart';
import 'package:cached_network_image/cached_network_image.dart';
@@ -12,60 +13,73 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class BlogPostScreen extends StatelessWidget {
const BlogPostScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final blog_postID = ModalRoute.of(context)!.settings.arguments;
static Widget builder(BuildContext context, String blog_postID) {
return BlocProvider<BlogPostBloc>(
create: (context) => BlogPostBloc(BlogPostState(
blog_postModelObj:
BlogPostModel(blog_postID: blog_postID.toString())))
..add(BlogPostInitialEvent()),
child: BlogPostScreen());
create: (context) => BlogPostBloc(
BlogPostState(
blog_postModelObj: BlogPostModel(
blog_postID: blog_postID.toString(),
),
),
)..add(
BlogPostInitialEvent(),
),
child: BlogPostScreen(),
);
}
Widget build(BuildContext context) {
return BlocBuilder<BlogPostBloc, BlogPostState>(
builder: (context, state) {
if (state is BlogPostInitialState) {
// Это начальное состояние, данные ещё не загружены.
return Container(
color: Colors.white,
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
} else if (state is BlogPostLoadedState) {
// Данные загружены, можно строить экран.
return _buildBlogPost(context, state);
} else if (state is BlogPostErrorState) {
// Произошла ошибка при загрузке данных.
return Center(child: Text(state.errorMessage));
return Center(
child: Text(state.errorMessage),
);
} else {
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
// Другие состояния, если они есть.
return Container(); // Пустой контейнер для необработанных состояний.
}
},
);
}
_buildBlogPost(BuildContext context, BlogPostLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 15.v),
_buildHeaderRow(context, state),
SizedBox(height: 15.v),
_buildBlogPostData(context, state),
SizedBox(height: 15.v),
_buildTextField(context, state),
SizedBox(height: 15.v),
_buildCommentSection(context, state),
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 15.v),
_buildHeaderRow(context, state),
SizedBox(height: 15.v),
_buildBlogPostData(context, state),
SizedBox(height: 15.v),
_buildTextField(context, state),
SizedBox(height: 15.v),
_buildCommentSection(context, state),
],
),
),
),
);
}
_buildHeaderRow(BuildContext context, BlogPostLoadedState state) {
@@ -92,8 +106,9 @@ class BlogPostScreen extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CustomImageView(
imagePath: ImageConstant.imgArrowLeft,
onTap: () => NavigatorService.goBack()),
imagePath: ImageConstant.imgArrowLeft,
onTap: () => GoRouter.of(context).pop(),
),
Padding(
padding: EdgeInsets.only(top: 1.v),
child: Row(
@@ -106,8 +121,7 @@ class BlogPostScreen extends StatelessWidget {
),
),
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.author?['profile_photo_path'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! + (state.author?['profile_photo_path'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
@@ -181,8 +195,7 @@ class BlogPostScreen extends StatelessWidget {
Align(
alignment: Alignment.topLeft,
child: Text(
DateFormat('dd.MM.yyyy')
.format(DateTime.parse(state.blog_post?['updated_at'])),
DateFormat('dd.MM.yyyy').format(DateTime.parse(state.blog_post?['updated_at'])),
style: theme.textTheme.bodyMedium,
)),
SizedBox(height: 16.0),
@@ -342,9 +355,7 @@ class BlogPostScreen extends StatelessWidget {
decoration: BoxDecoration(
color: Colors.transparent,
),
onPressed: () => context
.read<BlogPostBloc>()
.add(CreateComment(state.commentController!.text)),
onPressed: () => context.read<BlogPostBloc>().add(CreateComment(state.commentController!.text)),
// Установите прозрачный фон
)
],
@@ -377,12 +388,8 @@ class BlogPostScreen extends StatelessWidget {
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
/// Navigates to the previous screen.
onTapArrowleftone(BuildContext context) {
NavigatorService.goBack();
GoRouter.of(context).pop();
}
}

View File

@@ -1,3 +1,5 @@
import 'package:go_router/go_router.dart';
import 'bloc/feed_bloc.dart';
import 'models/feed_model.dart';
import 'package:cached_network_image/cached_network_image.dart';
@@ -101,10 +103,7 @@ class FeedScreen extends StatelessWidget {
flex: 1,
child: CustomOutlinedButton(
text: "+",
onPressed: () => Navigator.pushNamed(
context,
AppRoutes.blogPostCreateScreen,
),
onPressed: () => GoRouter.of(context).goNamed('blogPostCreateScreen'),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
),
),
@@ -169,10 +168,9 @@ class FeedScreen extends StatelessWidget {
DateFormat('dd.MM.yyyy').format(DateTime.parse(post?['post']['updated_at'])),
style: theme.textTheme.bodyMedium,
),
onTap: () => Navigator.pushNamed(
context,
AppRoutes.blogPostScreen,
arguments: post?['post']['id'].toString(),
onTap: () => GoRouter.of(context).goNamed(
'blogPostScreen',
extra: post?['post']['id'].toString(),
),
trailing: PopupMenuButton<String>(
onSelected: (value) => print("tap"),

View File

@@ -12,12 +12,10 @@ import 'package:eatvio_app/presentation/glossary/glossary_screen/widgets/glossar
class GlossaryScreen extends StatelessWidget {
const GlossaryScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
return BlocProvider<GlossaryBloc>(
create: (context) =>
GlossaryBloc(GlossaryState(glossaryModelObj: GlossaryModel()))
..add(GlossaryInitialEvent()),
child: GlossaryScreen());
create: (context) => GlossaryBloc(GlossaryState(glossaryModelObj: GlossaryModel()))..add(GlossaryInitialEvent()), child: GlossaryScreen());
}
Widget build(BuildContext context) {
@@ -43,32 +41,28 @@ class GlossaryScreen extends StatelessWidget {
}
_buildGlossary(BuildContext context, GlossaryLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 20),
_buildSearch(context),
SizedBox(height: 20),
_buildMenu(context),
SizedBox(height: 20),
_buildProducts(context, state)
],
),
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 20),
_buildSearch(context),
SizedBox(height: 20),
_buildMenu(context),
SizedBox(height: 20),
_buildProducts(context, state)
],
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
);
}
@@ -184,16 +178,12 @@ class GlossaryScreen extends StatelessWidget {
vertical: 9,
),
onChanged: _changeProductGroup(context, state),
width: MediaQuery.of(context)
.size
.width, // Set a percentage value as per your layout
width: MediaQuery.of(context).size.width, // Set a percentage value as per your layout
),
SizedBox(
height: 8,
),
Align(
alignment: Alignment.centerLeft,
child: Text("*КБЖУ указано за 100гр")),
Align(alignment: Alignment.centerLeft, child: Text("*КБЖУ указано за 100гр")),
SizedBox(
height: 8,
),
@@ -268,8 +258,7 @@ class GlossaryScreen extends StatelessWidget {
child: Column(children: [
Text("Жиры - ${product['fats_on_100gr'].toString()}"),
SizedBox(height: 8),
Text(
"Углеводы - ${product['carbohydrates_on_100gr'].toString()}")
Text("Углеводы - ${product['carbohydrates_on_100gr'].toString()}")
]),
)
])
@@ -298,16 +287,6 @@ class GlossaryScreen extends StatelessWidget {
return result;
}
///Handling route based on bottom click actions
String getCurrentRoute(BottomBarEnum type) {
switch (type) {
case BottomBarEnum.tf:
return AppRoutes.glossaryScreen;
default:
return "/";
}
}
///Handling page based on route
Widget getCurrentPage(
BuildContext context,
@@ -321,10 +300,6 @@ class GlossaryScreen extends StatelessWidget {
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
_changeProductGroup(BuildContext context, GlossaryLoadedState state) {
return (value) {
context.read<GlossaryBloc>().add(ChangeProductGroup(value.id));

View File

@@ -6,12 +6,11 @@ import 'package:eatvio_app/widgets/custom_bottom_bar.dart';
class PlanCreateScreen extends StatelessWidget {
const PlanCreateScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final planID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<PlanCreateBloc>(
create: (context) => PlanCreateBloc(PlanCreateState(
planModelObj: PlanCreateModel(planID: planID.toString())))
..add(PlanCreateInitialEvent()),
create: (context) => PlanCreateBloc(PlanCreateState(planModelObj: PlanCreateModel(planID: planID.toString())))..add(PlanCreateInitialEvent()),
child: PlanCreateScreen());
}
@@ -40,58 +39,56 @@ class PlanCreateScreen extends StatelessWidget {
_buildPlanCreate(BuildContext context, PlanCreateLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 16.0),
TextFormField(
controller: state.name,
decoration: InputDecoration(labelText: 'Заголовок'),
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
SizedBox(height: 16.0),
TextFormField(
controller: state.details,
decoration: InputDecoration(labelText: 'Описание'),
),
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () =>
context.read<PlanCreateBloc>().add(CreatePlan()),
child: Text('Создать'),
)
]),
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 16.0),
TextFormField(
controller: state.name,
decoration: InputDecoration(labelText: 'Заголовок'),
),
SizedBox(height: 16.0),
TextFormField(
controller: state.details,
decoration: InputDecoration(labelText: 'Описание'),
),
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () => context.read<PlanCreateBloc>().add(CreatePlan()),
child: Text('Создать'),
)
]),
)
],
),
),
),
);
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}

View File

@@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class PlanEditScreen extends StatelessWidget {
const PlanEditScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final planID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<PlanEditBloc>(
create: (context) => PlanEditBloc(PlanEditState(
planModelObj: PlanEditModel(planID: planID.toString())))
..add(PlanEditInitialEvent()),
create: (context) => PlanEditBloc(PlanEditState(planModelObj: PlanEditModel(planID: planID.toString())))..add(PlanEditInitialEvent()),
child: PlanEditScreen());
}
@@ -42,42 +41,43 @@ class PlanEditScreen extends StatelessWidget {
_buildPlanEdit(BuildContext context, PlanEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.plan?['image'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! + (state.plan?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
placeholder: (context, url) =>
CircularProgressIndicator(),
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
@@ -97,18 +97,16 @@ class PlanEditScreen extends StatelessWidget {
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () =>
context.read<PlanEditBloc>().add(EditPlan()),
onPressed: () => context.read<PlanEditBloc>().add(EditPlan()),
child: Text('Сохранить'),
)
]),
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
],
),
)
],
),
),
),
);
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}

View File

@@ -1,3 +1,5 @@
import 'package:go_router/go_router.dart';
import 'bloc/plan_select_bloc.dart';
import 'models/plan_select_model.dart';
import 'package:eatvio_app/core/app_export.dart';
@@ -39,75 +41,71 @@ class PlanSelectScreen extends StatelessWidget {
}
_buildSetingsScreen(BuildContext context, PlanSelectLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: onTapBack(context),
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(
children: [
AppbarSubtitle(
text: "Планы",
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v),
),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () => Navigator.pushNamed(
context,
AppRoutes.planCreateScreen,
),
child: Icon(Icons.create_outlined)),
)
],
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: () => GoRouter.of(context).pop(),
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(
children: [
AppbarSubtitle(
text: "Планы",
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v),
),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () => Navigator.pushNamed(
context,
AppRoutes.planCreateScreen,
),
child: Icon(Icons.create_outlined)),
)
],
),
),
),
SizedBox(height: 20),
_buildPlanList(context, state)
],
),
),
SizedBox(height: 20),
_buildPlanList(context, state)
],
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
);
}
@@ -174,10 +172,6 @@ class PlanSelectScreen extends StatelessWidget {
};
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
onTapArrowLeft(BuildContext context) {
NavigatorService.goBack();
}

View File

@@ -8,13 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class PlanScreen extends StatelessWidget {
const PlanScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final planID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<PlanBloc>(
create: (context) => PlanBloc(
PlanState(planModelObj: PlanModel(planID: planID.toString())))
..add(PlanInitialEvent()),
child: PlanScreen());
create: (context) => PlanBloc(PlanState(planModelObj: PlanModel(planID: planID.toString())))..add(PlanInitialEvent()), child: PlanScreen());
}
Widget build(BuildContext context) {
@@ -42,91 +40,76 @@ class PlanScreen extends StatelessWidget {
_buildPlan(BuildContext context, PlanLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! + (state.plan?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.plan?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
placeholder: (context, url) =>
CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
radius: 25,
),
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
radius: 25,
),
),
SizedBox(height: 16.0),
Text(state.plan?['name'], style: CustomTextStyles.titleMediumBlack),
SizedBox(height: 8.0),
Text(
state.plan?['details'],
),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () {
// Действие для редактирования
},
child: Text('Редактировать'),
),
SizedBox(height: 16.0),
Text(state.plan?['name'],
style: CustomTextStyles.titleMediumBlack),
SizedBox(height: 8.0),
Text(
state.plan?['details'],
ElevatedButton(
onPressed: () => context.read<PlanBloc>().add(DeleteEntry(state.plan?['id'])),
child: Text('Удалить'),
),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () {
// Действие для редактирования
},
child: Text('Редактировать'),
),
ElevatedButton(
onPressed: () => context
.read<PlanBloc>()
.add(DeleteEntry(state.plan?['id'])),
child: Text('Удалить'),
),
],
)
]),
],
)
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
}
///Handling route based on bottom click actions
String getCurrentRoute(BottomBarEnum type) {
switch (type) {
case BottomBarEnum.tf:
return AppRoutes.planScreen;
default:
return "/";
}
]),
)
],
),
),
),
);
}
///Handling page based on route
@@ -142,10 +125,6 @@ class PlanScreen extends StatelessWidget {
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
/// Navigates to the previous screen.
onTapArrowleftone(BuildContext context) {
NavigatorService.goBack();

View File

@@ -1,3 +1,5 @@
import 'package:go_router/go_router.dart';
import 'bloc/my_profile_bloc.dart';
import 'models/my_profile_model.dart';
import 'package:eatvio_app/core/app_export.dart';
@@ -15,10 +17,7 @@ import 'package:flutter/material.dart';
class MySettingsScreen extends StatelessWidget {
static Widget builder(BuildContext context) {
return BlocProvider<MyProfileBloc>(
create: (context) =>
MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))
..add(MyProfileInitialEvent()),
child: MySettingsScreen());
create: (context) => MyProfileBloc(MyProfileState(myProfileModelObj: MyProfileModel()))..add(MyProfileInitialEvent()), child: MySettingsScreen());
}
Widget build(BuildContext context) {
@@ -42,136 +41,125 @@ class MySettingsScreen extends StatelessWidget {
}
_buildSetingsScreen(BuildContext context, MyProfileLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 30),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 30),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
onTap: () => GoRouter.of(context).pop(),
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: onTapBack(context)),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(children: [
AppbarSubtitle(
text: state.user?['name'],
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v))
])),
)),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Язык'),
LanguageDropdown(),
],
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(children: [AppbarSubtitle(text: state.user?['name'], margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v))])),
)),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Уведомления'),
NotificationSwitch('Уведомление об обновлениях'),
NotificationSwitch('Напоминания о заполнении'),
],
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Дополнительная информация'),
ExpandableList('Персональные данные'),
AboutList('О нас', ['ООО Итвио', '2023-н.в.']),
],
),
child: Column(
children: [
SectionTitle('Язык'),
LanguageDropdown(),
],
),
],
),
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Уведомления'),
NotificationSwitch('Уведомление об обновлениях'),
NotificationSwitch('Напоминания о заполнении'),
],
),
),
SizedBox(height: 20),
Container(
padding: EdgeInsets.symmetric(
horizontal: 24.h,
vertical: 12.v,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
children: [
SectionTitle('Дополнительная информация'),
ExpandableList('Персональные данные'),
AboutList('О нас', ['ООО Итвио', '2023-н.в.']),
],
),
),
],
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
);
}
@@ -182,10 +170,6 @@ class MySettingsScreen extends StatelessWidget {
};
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
onTapArrowLeft(BuildContext context) {
NavigatorService.goBack();
}

View File

@@ -11,12 +11,12 @@ import 'package:eatvio_app/widgets/custom_outlined_button.dart';
class RecipeCreateScreen extends StatelessWidget {
const RecipeCreateScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final recipeID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<RecipeCreateBloc>(
create: (context) => RecipeCreateBloc(RecipeCreateState(
recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString())))
..add(RecipeCreateInitialEvent()),
create: (context) =>
RecipeCreateBloc(RecipeCreateState(recipeModelObj: RecipeCreateModel(recipeID: recipeID.toString())))..add(RecipeCreateInitialEvent()),
child: RecipeCreateScreen());
}
@@ -52,25 +52,28 @@ class RecipeCreateScreen extends StatelessWidget {
}
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: ListView(children: [
_buldAppBar(context),
SizedBox(height: 20.v),
_buildRecipeInfo(state, context),
SizedBox(height: 20.v),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: steps,
),
SizedBox(height: 20.v),
_buildAdditional(context, state)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: ListView(
children: [
_buldAppBar(context),
SizedBox(height: 20.v),
_buildRecipeInfo(state, context),
SizedBox(height: 20.v),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: steps,
),
SizedBox(height: 20.v),
_buildAdditional(context, state)
],
),
),
),
);
}
_buldAppBar(BuildContext context) {
@@ -337,9 +340,7 @@ _buildAdditional(BuildContext context, RecipeCreateLoadedState state) {
),
),
SizedBox(height: 8.0),
Align(
alignment: Alignment.centerLeft,
child: Text("Ссылка на видео (необязательно)")),
Align(alignment: Alignment.centerLeft, child: Text("Ссылка на видео (необязательно)")),
CustomTextFormField(
controller: state.description,
hintText: "YouTube",
@@ -361,10 +362,6 @@ _buildAdditional(BuildContext context, RecipeCreateLoadedState state) {
);
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
Function onTapBack(BuildContext context) {
return () {
onTapArrowLeft(context);

View File

@@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class RecipeEditScreen extends StatelessWidget {
const RecipeEditScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final recipeID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<RecipeEditBloc>(
create: (context) => RecipeEditBloc(RecipeEditState(
recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))
..add(RecipeEditInitialEvent()),
create: (context) => RecipeEditBloc(RecipeEditState(recipeModelObj: RecipeEditModel(recipeID: recipeID.toString())))..add(RecipeEditInitialEvent()),
child: RecipeEditScreen());
}
@@ -42,42 +41,43 @@ class RecipeEditScreen extends StatelessWidget {
_buildRecipeEdit(BuildContext context, RecipeEditLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.recipe?['image'] ?? ''),
imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
placeholder: (context, url) =>
CircularProgressIndicator(),
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
@@ -102,18 +102,16 @@ class RecipeEditScreen extends StatelessWidget {
SizedBox(height: 16.0),
// Здесь нужно добавить виджет для загрузки картинки
ElevatedButton(
onPressed: () =>
context.read<RecipeEditBloc>().add(EditRecipe()),
onPressed: () => context.read<RecipeEditBloc>().add(EditRecipe()),
child: Text('Сохранить'),
)
]),
)
]),
),
bottomNavigationBar: _buildBottomBar(context)));
],
),
)
],
),
),
),
);
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}

View File

@@ -1,3 +1,5 @@
import 'package:go_router/go_router.dart';
import 'bloc/recipe_select_bloc.dart';
import 'models/recipe_select_model.dart';
import 'package:eatvio_app/core/app_export.dart';
@@ -39,75 +41,71 @@ class RecipeSelectScreen extends StatelessWidget {
}
_buildRecipeScreen(BuildContext context, RecipeSelectLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: onTapBack(context),
return Scaffold(
backgroundColor: Colors.grey[200],
resizeToAvoidBottomInset: true,
body: SingleChildScrollView(
child: Container(
width: double.maxFinite,
decoration: BoxDecoration(color: Colors.grey[200]),
child: Padding(
padding: EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SizedBox(height: 10),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(
children: [
AppbarSubtitle(
text: "Рецепты",
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v),
),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () => Navigator.pushNamed(
context,
AppRoutes.recipeCreateScreen,
),
child: Icon(Icons.create_outlined)),
)
],
),
],
),
child: CustomAppBar(
height: 54.v,
leadingWidth: 28.h,
leading: AppbarLeadingImage(
imagePath: ImageConstant.imgArrowLeft,
margin: EdgeInsets.only(
left: 16.h, top: 15.v, bottom: 15.v),
onTap: () => GoRouter.of(context).pop(),
),
title: Padding(
padding: EdgeInsets.only(left: 20.h),
child: Row(
children: [
AppbarSubtitle(
text: "Рецепты",
margin: EdgeInsets.only(
left: 80.h, top: 12.v, bottom: 9.v),
),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 20.0),
child: GestureDetector(
onTap: () => Navigator.pushNamed(
context,
AppRoutes.recipeCreateScreen,
),
child: Icon(Icons.create_outlined)),
)
],
),
),
),
SizedBox(height: 20),
_buildRecipeList(context, state),
],
),
),
SizedBox(height: 20),
_buildRecipeList(context, state),
],
),
),
),
bottomNavigationBar: _buildBottomBar(context),
),
);
}
@@ -174,10 +172,6 @@ class RecipeSelectScreen extends StatelessWidget {
};
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
onTapArrowLeft(BuildContext context) {
NavigatorService.goBack();
}

View File

@@ -8,12 +8,11 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
class RecipeScreen extends StatelessWidget {
const RecipeScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final recipeID = ModalRoute.of(context)!.settings.arguments;
return BlocProvider<RecipeBloc>(
create: (context) => RecipeBloc(RecipeState(
recipeModelObj: RecipeModel(recipeID: recipeID.toString())))
..add(RecipeInitialEvent()),
create: (context) => RecipeBloc(RecipeState(recipeModelObj: RecipeModel(recipeID: recipeID.toString())))..add(RecipeInitialEvent()),
child: RecipeScreen());
}
@@ -42,90 +41,74 @@ class RecipeScreen extends StatelessWidget {
_buildRecipe(BuildContext context, RecipeLoadedState state) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
child: Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
width: double.maxFinite,
decoration: AppDecoration.fillGray,
child: ListView(
children: [
SizedBox(height: 30.v),
Container(
margin: EdgeInsets.only(
left: 16.h,
right: 20.h,
bottom: 10.h,
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
padding: EdgeInsets.all(12.h),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(12)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
],
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! + (state.recipe?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
child: Column(mainAxisSize: MainAxisSize.min, children: [
CachedNetworkImage(
imageUrl: dotenv.env['STORAGE_URL']! +
(state.recipe?['image'] ?? ''),
imageBuilder: (context, imageProvider) => CircleAvatar(
backgroundImage: imageProvider,
radius: 25,
),
placeholder: (context, url) =>
CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
radius: 25,
),
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => CircleAvatar(
child: Icon(Icons.person),
backgroundColor: Colors.white,
radius: 25,
),
),
SizedBox(height: 16.0),
Text(state.recipe?['title'], style: CustomTextStyles.titleMediumBlack),
SizedBox(height: 8.0),
Text(
state.recipe?['description'],
),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () => Navigator.pushNamed(context, AppRoutes.recipeEditScreen, arguments: state.recipe?['id'].toString()),
child: Text('Редактировать'),
),
SizedBox(height: 16.0),
Text(state.recipe?['title'],
style: CustomTextStyles.titleMediumBlack),
SizedBox(height: 8.0),
Text(
state.recipe?['description'],
ElevatedButton(
onPressed: () => context.read<RecipeBloc>().add(DeleteEntry(state.recipe?['id'])),
child: Text('Удалить'),
),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
ElevatedButton(
onPressed: () => Navigator.pushNamed(
context, AppRoutes.recipeEditScreen,
arguments: state.recipe?['id'].toString()),
child: Text('Редактировать'),
),
ElevatedButton(
onPressed: () => context
.read<RecipeBloc>()
.add(DeleteEntry(state.recipe?['id'])),
child: Text('Удалить'),
),
],
)
]),
],
)
],
),
),
bottomNavigationBar: _buildBottomBar(context)));
}
///Handling route based on bottom click actions
String getCurrentRoute(BottomBarEnum type) {
switch (type) {
case BottomBarEnum.tf:
return AppRoutes.recipeScreen;
default:
return "/";
}
]),
)
],
),
),
),
);
}
///Handling page based on route
@@ -141,10 +124,6 @@ class RecipeScreen extends StatelessWidget {
}
}
_buildBottomBar(BuildContext context) {
return CustomBottomBar(onChanged: (BottomBarEnum type) {});
}
/// Navigates to the previous screen.
onTapArrowleftone(BuildContext context) {
NavigatorService.goBack();

View File

@@ -9,97 +9,104 @@ import 'package:flutter/material.dart';
class LanguageSelectScreen extends StatelessWidget {
const LanguageSelectScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
return BlocProvider<LanguageSelectBloc>(
create: (context) => LanguageSelectBloc(
LanguageSelectState(languageSelectModelObj: LanguageSelectModel()))
..add(LanguageSelectInitialEvent()),
child: LanguageSelectScreen());
create: (context) => LanguageSelectBloc(
LanguageSelectState(
languageSelectModelObj: LanguageSelectModel(),
),
)..add(LanguageSelectInitialEvent()),
child: LanguageSelectScreen(),
);
}
@override
Widget build(BuildContext context) {
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v),
child: Column(children: [
CustomImageView(
imagePath: ImageConstant.imgLogoEatvio,
height: 50.adaptSize,
width: 50.adaptSize),
SizedBox(height: 20.v),
Container(
height: 16.v,
width: 343.h,
return Scaffold(
body: Container(
width: double.maxFinite,
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v),
child: Column(
children: [
CustomImageView(imagePath: ImageConstant.imgLogoEatvio, height: 50.adaptSize, width: 50.adaptSize),
SizedBox(height: 20.v),
Container(
height: 16.v,
width: 343.h,
decoration: BoxDecoration(
color: theme.colorScheme.onPrimary,
borderRadius: BorderRadius.circular(8.h),
border: Border.all(
color: theme.colorScheme.primary,
width: 1.h,
),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.h),
child: LinearProgressIndicator(
value: 0,
backgroundColor: theme.colorScheme.onPrimary,
valueColor: AlwaysStoppedAnimation<Color>(appTheme.blueA400),
),
),
),
SizedBox(height: 20.v),
Container(
width: 262.h,
margin: EdgeInsets.only(left: 41.h, right: 39.h),
child: Text(
"preferred_language".tr,
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: theme.textTheme.headlineSmall,
),
),
Spacer(flex: 36),
BlocSelector<LanguageSelectBloc, LanguageSelectState, LanguageSelectModel?>(
selector: (state) => state.languageSelectModelObj,
builder: (
context,
languageSelectModelObj,
) {
return CustomDropDown(
icon: Container(
margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v),
decoration: BoxDecoration(
color: theme.colorScheme.onPrimary,
borderRadius: BorderRadius.circular(8.h),
border: Border.all(
color: theme.colorScheme.primary, width: 1.h)),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.h),
child: LinearProgressIndicator(
value: 0,
backgroundColor: theme.colorScheme.onPrimary,
valueColor: AlwaysStoppedAnimation<Color>(
appTheme.blueA400)))),
SizedBox(height: 20.v),
Container(
width: 262.h,
margin: EdgeInsets.only(left: 41.h, right: 39.h),
child: Text("preferred_language".tr,
maxLines: 2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: theme.textTheme.headlineSmall)),
Spacer(flex: 36),
BlocSelector<LanguageSelectBloc, LanguageSelectState,
LanguageSelectModel?>(
selector: (state) => state.languageSelectModelObj,
builder: (
context,
languageSelectModelObj,
) {
return CustomDropDown(
icon: Container(
margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.h),
),
child: CustomImageView(
imagePath: ImageConstant.imgFavorite,
height: 12.adaptSize,
width: 12.adaptSize,
),
),
hintText: "Не выбрано".tr,
items: languageSelectModelObj?.dropdownItemList ?? [],
onChanged: (value) =>
_onDropDownChanged(context, value),
);
}),
Spacer(flex: 63),
])),
bottomNavigationBar:
BlocBuilder<LanguageSelectBloc, LanguageSelectState>(
builder: (context, state) {
return NextStepButton(
text: "continue".tr.toUpperCase(),
margin:
EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: _saveAndPush(state, context));
})));
borderRadius: BorderRadius.circular(1.h),
),
child: CustomImageView(
imagePath: ImageConstant.imgFavorite,
height: 12.adaptSize,
width: 12.adaptSize,
),
),
hintText: "Не выбрано".tr,
items: languageSelectModelObj?.dropdownItemList ?? [],
onChanged: (value) => _onDropDownChanged(context, value),
);
}),
Spacer(flex: 63),
],
),
),
bottomNavigationBar: BlocBuilder<LanguageSelectBloc, LanguageSelectState>(
builder: (context, state) {
return NextStepButton(
text: "continue".tr.toUpperCase(),
margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: _saveAndPush(state, context),
);
},
),
);
}
void Function()? _saveAndPush(
LanguageSelectState state, BuildContext context) {
void Function()? _saveAndPush(LanguageSelectState state, BuildContext context) {
return () {
UserRegistrationSheet sheet =
state.languageSelectModelObj!.userRegistrationSheet;
UserRegistrationSheet sheet = state.languageSelectModelObj!.userRegistrationSheet;
Navigator.pushNamed(
context,
AppRoutes.credentialsScreen,

View File

@@ -198,8 +198,8 @@ class AppRoutes {
planCreateScreen: (context) =>
_buildFadeRoute(context, PlanCreateScreen.builder),
feedScreen: (context) => _buildFadeRoute(context, FeedScreen.builder),
blogPostScreen: (context) =>
_buildFadeRoute(context, BlogPostScreen.builder),
// blogPostScreen: (context) =>
// _buildFadeRoute(context, BlogPostScreen.builder),
blogPostEditScreen: (context) =>
_buildFadeRoute(context, BlogPostEditScreen.builder),
blogPostCreateScreen: (context) =>

View File

@@ -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;
}

View File

@@ -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');
}
};
}