diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index e8f9d11f..4a2d90f8 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -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" diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index b5f75243..27c7c439 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -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" diff --git a/lib/app_router.dart b/lib/app_router.dart index b5869654..255df7aa 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -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), + ), ], ); } diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index 558d5657..ff4408de 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -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'); }; } diff --git a/lib/presentation/chat/chat_screen/chat_screen.dart b/lib/presentation/chat/chat_screen/chat_screen.dart index 37c3df52..a132f880 100644 --- a/lib/presentation/chat/chat_screen/chat_screen.dart +++ b/lib/presentation/chat/chat_screen/chat_screen.dart @@ -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, diff --git a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart index 3de4ff40..698d6e0c 100644 --- a/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart +++ b/lib/presentation/diary/diary_edit_screen/diary_edit_screen.dart @@ -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( diff --git a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart index 6896701c..eae238b7 100644 --- a/lib/presentation/diets/diet_create_screen/diet_create_screen.dart +++ b/lib/presentation/diets/diet_create_screen/diet_create_screen.dart @@ -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( - 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().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().add(CreateDiet()), + child: Text('Создать'), ) ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ) + ]), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart b/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart index 75f02810..665927b1 100644 --- a/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart +++ b/lib/presentation/diets/diet_edit_screen/diet_edit_screen.dart @@ -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( - 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().add(EditDiet()), + onPressed: () => context.read().add(EditDiet()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart index c44308d8..207cbb6d 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart @@ -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(); } diff --git a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart index dcc20aea..d05a39a8 100644 --- a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart @@ -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( - 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().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() - .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(); diff --git a/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart b/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart index fc1d7c14..be78f7e3 100644 --- a/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart +++ b/lib/presentation/feed/blog_post_create_screen/blog_post_create_screen.dart @@ -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( - 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: [ + 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: [ - 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) {}); -} diff --git a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart b/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart index 1bba76d6..ac5a8338 100644 --- a/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart +++ b/lib/presentation/feed/blog_post_edit_screen/blog_post_edit_screen.dart @@ -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( - 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().add(EditBlogPost()), + onPressed: () => context.read().add(EditBlogPost()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/feed/blog_post_screen/blog_post_screen.dart b/lib/presentation/feed/blog_post_screen/blog_post_screen.dart index 04637420..0b524122 100644 --- a/lib/presentation/feed/blog_post_screen/blog_post_screen.dart +++ b/lib/presentation/feed/blog_post_screen/blog_post_screen.dart @@ -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( - 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( 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() - .add(CreateComment(state.commentController!.text)), + onPressed: () => context.read().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(); } } diff --git a/lib/presentation/feed/feed_screen/feed_screen.dart b/lib/presentation/feed/feed_screen/feed_screen.dart index 4e8be2c2..cddb9cca 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -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( onSelected: (value) => print("tap"), diff --git a/lib/presentation/glossary/glossary_screen/glossary_screen.dart b/lib/presentation/glossary/glossary_screen/glossary_screen.dart index 65dc65cb..42b84775 100644 --- a/lib/presentation/glossary/glossary_screen/glossary_screen.dart +++ b/lib/presentation/glossary/glossary_screen/glossary_screen.dart @@ -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( - 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().add(ChangeProductGroup(value.id)); diff --git a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart index af04abc7..9ab5cada 100644 --- a/lib/presentation/plans/plan_create_screen/plan_create_screen.dart +++ b/lib/presentation/plans/plan_create_screen/plan_create_screen.dart @@ -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( - 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().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().add(CreatePlan()), + child: Text('Создать'), + ) + ]), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart b/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart index 71ac12b7..c163f2c7 100644 --- a/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart +++ b/lib/presentation/plans/plan_edit_screen/plan_edit_screen.dart @@ -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( - 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().add(EditPlan()), + onPressed: () => context.read().add(EditPlan()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart index 7f3486a2..a82a6679 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart @@ -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(); } diff --git a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart index d34e1a43..8e2f2431 100644 --- a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart @@ -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( - 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().add(DeleteEntry(state.plan?['id'])), + child: Text('Удалить'), ), - SizedBox(height: 16.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - ElevatedButton( - onPressed: () { - // Действие для редактирования - }, - child: Text('Редактировать'), - ), - ElevatedButton( - onPressed: () => context - .read() - .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(); diff --git a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart index 82ddc56b..0f2ac434 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -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( - 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(); } diff --git a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart index b663db22..84c484a0 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -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( - 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); diff --git a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart index 31a723a9..7785466f 100644 --- a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -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( - 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().add(EditRecipe()), + onPressed: () => context.read().add(EditRecipe()), child: Text('Сохранить'), ) - ]), - ) - ]), - ), - bottomNavigationBar: _buildBottomBar(context))); + ], + ), + ) + ], + ), + ), + ), + ); } } - -_buildBottomBar(BuildContext context) { - return CustomBottomBar(onChanged: (BottomBarEnum type) {}); -} diff --git a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart index 0623c053..0b45fda2 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -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(); } diff --git a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart index ee757764..d250e1f3 100644 --- a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart +++ b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart @@ -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( - 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().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() - .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(); diff --git a/lib/presentation/registration/language_select_screen/language_select_screen.dart b/lib/presentation/registration/language_select_screen/language_select_screen.dart index 56e644a0..80b3a8bf 100644 --- a/lib/presentation/registration/language_select_screen/language_select_screen.dart +++ b/lib/presentation/registration/language_select_screen/language_select_screen.dart @@ -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( - 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(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( + 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( - 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( - 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( - 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( + 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, diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 16235b16..d8708717 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -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) => diff --git a/lib/widgets/custom_bottom_bar.dart b/lib/widgets/custom_bottom_bar.dart index b8e54605..f7ecba52 100644 --- a/lib/widgets/custom_bottom_bar.dart +++ b/lib/widgets/custom_bottom_bar.dart @@ -67,6 +67,7 @@ class _BottomNavigationBarWidgetState extends State { }, selectedFontSize: 12, unselectedFontSize: 12, + selectedItemColor: appTheme.blueA400, currentIndex: currentBottomNavBarIndex, items: [ BottomNavigationBarItem( @@ -76,18 +77,46 @@ class _BottomNavigationBarWidgetState extends State { 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 { ); } } - -// ignore: must_be_immutable -class CustomBottomBar extends StatefulWidget { - CustomBottomBar({this.onChanged}); - - Function(BottomBarEnum)? onChanged; - - @override - CustomBottomBarState createState() => CustomBottomBarState(); -} - -class CustomBottomBarState extends State { - int selectedIndex = 2; - - List bottomMenuList = [ - BottomMenuModel( - icon: ImageConstant.imgLogo, - activeIcon: ImageConstant.imgLogo, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgFeed, - activeIcon: ImageConstant.imgFeed, - title: "Лента", - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgDiary, - activeIcon: ImageConstant.imgDiary, - title: "diary".tr, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgChat, - activeIcon: ImageConstant.imgChat, - title: "chat".tr, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgBell, - activeIcon: ImageConstant.imgBell, - type: BottomBarEnum.tf, - image: false, - ), - BottomMenuModel( - icon: ImageConstant.imgEllipse1, - activeIcon: ImageConstant.imgEllipse1, - type: BottomBarEnum.tf, - image: true, - ), - ]; - - @override - Widget build(BuildContext context) { - return Container( - height: 83.v, - decoration: BoxDecoration( - border: Border.all( - color: appTheme.whiteA700, - width: 1.h, - ), - ), - child: BottomNavigationBar( - backgroundColor: Colors.transparent, - showSelectedLabels: false, - showUnselectedLabels: false, - selectedFontSize: 0, - elevation: 0, - currentIndex: selectedIndex, - type: BottomNavigationBarType.fixed, - items: List.generate(bottomMenuList.length, bottomMenu), - onTap: changeMeny, - ), - ); - } - - void changeMeny(index) { - setState(() { - selectedIndex = index; - }); - - switch (index) { - case 0: - Navigator.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; -} diff --git a/lib/widgets/custom_navigation_menu.dart b/lib/widgets/custom_navigation_menu.dart index 4bbdc758..03d11a98 100644 --- a/lib/widgets/custom_navigation_menu.dart +++ b/lib/widgets/custom_navigation_menu.dart @@ -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'); } }; }