diff --git a/lib/app_router.dart b/lib/app_router.dart index a7de9889..6f677a80 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -12,12 +12,16 @@ import 'package:eatvio_app/presentation/profile/my_profile_screen/my_settings_sc 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/bottom_navigation_bar_widget.dart'; +import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hive_flutter/hive_flutter.dart'; class AppRouter { + static GlobalKey navigatorKey = GlobalKey(); + static GoRouter appRouter = GoRouter( initialLocation: '/auth-screen', + navigatorKey: navigatorKey, routes: [ GoRoute( path: '/auth-screen', diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index ff4408de..6b6c3a45 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -143,33 +143,23 @@ class AuthScreen extends StatelessWidget { }; } - onTapOk(BuildContext context) { - return () { - Navigator.pop(context); - }; - } + onTapOk(BuildContext context) => GoRouter.of(context).pop(context); - onTapDiaryTest(BuildContext context) { - return () { - Navigator.pushNamed(context, AppRoutes.diaryEdit); - }; - } + onTapDiaryTest(BuildContext context) => GoRouter.of(context).goNamed('diaryScreen'); - onTapProfileTest(BuildContext context) { - return () { - Navigator.pushNamed(context, AppRoutes.mySettings); - }; - } + onTapProfileTest(BuildContext context) => GoRouter.of(context).goNamed('mySettingsScreen'); - onTapNoAccount(BuildContext context) { - return () { - GoRouter.of(context).goNamed('languageSelectScreen'); - }; - } + onTapNoAccount(BuildContext context) => GoRouter.of(context).goNamed('languageSelectScreen'); /// Section Widget _buildAppBar(BuildContext context) { - return CustomAppBar(leadingWidth: 29.h, centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); + return CustomAppBar( + leadingWidth: 29.h, + centerTitle: true, + title: AppbarTitleImage( + imagePath: ImageConstant.imgLogoEatvio, + ), + ); } List validateFields(String email, String password) { diff --git a/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart b/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart index 52cf81df..3d8f73a4 100644 --- a/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart +++ b/lib/presentation/chat/chat_screen/bloc/chat_bloc.dart @@ -1,6 +1,7 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:go_router/go_router.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; @@ -24,9 +25,7 @@ class ChatBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? chatID = state.chatModelObj?.chatID; final response = await http.get( diff --git a/lib/presentation/chat/chat_select_screen/bloc/chat_select_bloc.dart b/lib/presentation/chat/chat_select_screen/bloc/chat_select_bloc.dart index f543c5aa..fe6d0a72 100644 --- a/lib/presentation/chat/chat_select_screen/bloc/chat_select_bloc.dart +++ b/lib/presentation/chat/chat_select_screen/bloc/chat_select_bloc.dart @@ -47,9 +47,7 @@ class ChatSelectBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final response = await http.get( Uri.parse(dotenv.env['SERVER_ROOT']! + '/chat/index'), diff --git a/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart b/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart index 52f9de3a..55f5ee49 100644 --- a/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart +++ b/lib/presentation/chat/chat_select_screen/widgets/chat_entry_widget.dart @@ -28,23 +28,23 @@ class ChatEntryWidget extends StatelessWidget { borderRadius: BorderRadiusStyle.circleBorder8, ), child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CachedNetworkImage( - imageUrl: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!, - 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, - ), + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CachedNetworkImage( + imageUrl: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!, + imageBuilder: (context, imageProvider) => CircleAvatar( + backgroundImage: imageProvider, + radius: 25, ), - /*CustomImageView( + placeholder: (context, url) => CircularProgressIndicator(), + errorWidget: (context, url, error) => CircleAvatar( + child: Icon(Icons.person), + backgroundColor: Colors.white, + radius: 25, + ), + ), + /*CustomImageView( imagePath: dotenv.env['STORAGE_URL']! + chatEntryObj.userImage!, height: 60.adaptSize, @@ -53,57 +53,55 @@ class ChatEntryWidget extends StatelessWidget { 30.h, ), ),*/ - Expanded( - child: Padding( - padding: EdgeInsets.only( - left: 12.h, - top: 2.v, - bottom: 11.v, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - width: 227.h, - child: Row( - children: [ - Text( - chatEntryObj.username!.length <= 15 - ? chatEntryObj.username! - : chatEntryObj.username!.substring(0, 15) + - '...', - style: theme.textTheme.titleMedium, - ), - Spacer(), - CustomImageView( - imagePath: ImageConstant.imageNotFound, - height: 9.v, - width: 16.h, - margin: EdgeInsets.only( - top: 4.v, - bottom: 6.v, - ), - ), - Padding( - padding: EdgeInsets.only(left: 6.h), - child: Text( - chatEntryObj.dateText!, - style: theme.textTheme.bodyMedium, - ), - ) - ], - ), - ), - SizedBox(height: 6.v), - Text( - chatEntryObj.greetingText!, - style: CustomTextStyles.bodyMediumBluegray800, - ) - ], - ), + Expanded( + child: Padding( + padding: EdgeInsets.only( + left: 12.h, + top: 2.v, + bottom: 11.v, ), - ) - ]), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 227.h, + child: Row( + children: [ + Text( + chatEntryObj.username!.length <= 15 ? chatEntryObj.username! : chatEntryObj.username!.substring(0, 15) + '...', + style: theme.textTheme.titleMedium, + ), + Spacer(), + CustomImageView( + imagePath: ImageConstant.imageNotFound, + height: 9.v, + width: 16.h, + margin: EdgeInsets.only( + top: 4.v, + bottom: 6.v, + ), + ), + Padding( + padding: EdgeInsets.only(left: 6.h), + child: Text( + chatEntryObj.dateText!, + style: theme.textTheme.bodyMedium, + ), + ) + ], + ), + ), + SizedBox(height: 6.v), + Text( + chatEntryObj.greetingText!, + style: CustomTextStyles.bodyMediumBluegray800, + ) + ], + ), + ), + ) + ], + ), ), ); } diff --git a/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart b/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart index e517c1ac..e4e0cbc8 100644 --- a/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart +++ b/lib/presentation/diets/diet_create_screen/bloc/diet_create_bloc.dart @@ -1,13 +1,16 @@ import 'dart:async'; +import 'package:eatvio_app/app_router.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:go_router/go_router.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import '/core/app_export.dart'; import 'package:eatvio_app/presentation/diets/diet_create_screen/models/diet_create_model.dart'; + part 'diet_create_event.dart'; part 'diet_create_state.dart'; @@ -25,9 +28,7 @@ class DietCreateBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } if (state is DietCreateLoadedState) { var currentState = state as DietCreateLoadedState; @@ -55,7 +56,7 @@ class DietCreateBloc extends Bloc { ); if (response.statusCode == 200) { - NavigatorService.pushNamed(AppRoutes.dietSelectScreen); + AppRouter.navigatorKey.currentContext?.goNamed('dietSelectScreen'); } else { print( 'Failed to create blog post. Status Code: ${response.statusCode} ${response.body}'); diff --git a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart b/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart index d8167793..e69101c0 100644 --- a/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart +++ b/lib/presentation/diets/diet_edit_screen/bloc/diet_edit_bloc.dart @@ -1,14 +1,18 @@ import 'dart:async'; +import 'package:eatvio_app/app_router.dart'; import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:go_router/go_router.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; import 'dart:convert'; import '/core/app_export.dart'; import 'package:eatvio_app/presentation/diets/diet_edit_screen/models/diet_edit_model.dart'; + part 'diet_edit_event.dart'; + part 'diet_edit_state.dart'; /// A bloc that manages the state of a DietEdit according to the event that is dispatched to it. @@ -26,9 +30,7 @@ class DietEditBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + AppRouter.navigatorKey.currentContext?.goNamed('authScreen'); } final String? dietID = state.dietModelObj?.dietID; final response = await http.get( @@ -74,15 +76,15 @@ class DietEditBloc extends Bloc { var currentState = state as DietEditLoadedState; int duration = int.parse(currentState.duration!.text) * 7; print(duration); - var response = await sendDiet(currentState.diet, currentState.name?.text, - currentState.details?.text, duration.toString()); + var response = await sendDiet(currentState.diet, currentState.name?.text, currentState.details?.text, duration.toString()); if (response.statusCode == 200) { - NavigatorService.pushNamed(AppRoutes.dietScreen, - arguments: currentState.diet?['id'].toString()); + AppRouter.navigatorKey.currentContext?.goNamed( + 'dietScreen', + extra: currentState.diet?['id'].toString(), + ); } else { - print( - 'Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); + print('Failed to edit blog post. Status Code: ${response.statusCode} ${response.body}'); } } } diff --git a/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart b/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart index 49def2d1..21e7dbdd 100644 --- a/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart +++ b/lib/presentation/diets/diet_select_screen/bloc/diet_select_bloc.dart @@ -28,9 +28,7 @@ class DietSelectBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); // Если токен есть, запускаем приложение + // go to auth screen } final response = await http.get( Uri.parse(dotenv.env['SERVER_ROOT']! + '/diets/index'), diff --git a/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart b/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart index a1216bd0..7c11ea66 100644 --- a/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart +++ b/lib/presentation/diets/diet_show_screen/bloc/diet_show_bloc.dart @@ -26,9 +26,7 @@ class DietBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? dietID = state.dietModelObj?.dietID; final response = await http.get( diff --git a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart b/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart index e07d2dc6..5fb90f4d 100644 --- a/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart +++ b/lib/presentation/feed/blog_post_create_screen/bloc/blog_post_create_bloc.dart @@ -26,9 +26,7 @@ class BlogPostCreateBloc final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } if (state is BlogPostCreateLoadedState) { var currentState = state as BlogPostCreateLoadedState; diff --git a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart b/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart index f3b193e4..9783704b 100644 --- a/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart +++ b/lib/presentation/feed/blog_post_edit_screen/bloc/blog_post_edit_bloc.dart @@ -26,9 +26,7 @@ class BlogPostEditBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? blog_postID = state.blog_postModelObj?.blog_postID; final response = await http.get( diff --git a/lib/presentation/feed/blog_post_screen/bloc/blog_post_bloc.dart b/lib/presentation/feed/blog_post_screen/bloc/blog_post_bloc.dart index d0655339..d26638db 100644 --- a/lib/presentation/feed/blog_post_screen/bloc/blog_post_bloc.dart +++ b/lib/presentation/feed/blog_post_screen/bloc/blog_post_bloc.dart @@ -29,9 +29,7 @@ class BlogPostBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? blog_postID = state.blog_postModelObj?.blog_postID; final response = await http.get( diff --git a/lib/presentation/feed/feed_screen/bloc/feed_bloc.dart b/lib/presentation/feed/feed_screen/bloc/feed_bloc.dart index 3932f495..0040ad24 100644 --- a/lib/presentation/feed/feed_screen/bloc/feed_bloc.dart +++ b/lib/presentation/feed/feed_screen/bloc/feed_bloc.dart @@ -28,9 +28,7 @@ class FeedBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); // Если токен есть, запускаем приложение + // go to auth screen } final response = await http.get( Uri.parse(dotenv.env['SERVER_ROOT']! + '/feed/index'), diff --git a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart b/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart index d1065260..c40fd218 100644 --- a/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart +++ b/lib/presentation/glossary/glossary_screen/bloc/glossary_screen_bloc.dart @@ -26,9 +26,7 @@ class GlossaryBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final responseProductGroups = await http.get( Uri.parse(dotenv.env['SERVER_ROOT']! + '/glossary/getProductGroups'), diff --git a/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart b/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart index b06092c3..5569baec 100644 --- a/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart +++ b/lib/presentation/plans/plan_create_screen/bloc/plan_create_bloc.dart @@ -25,9 +25,7 @@ class PlanCreateBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } if (state is PlanCreateLoadedState) { var currentState = state as PlanCreateLoadedState; diff --git a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart b/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart index e8fa9eae..a8051c15 100644 --- a/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart +++ b/lib/presentation/plans/plan_edit_screen/bloc/plan_edit_bloc.dart @@ -26,9 +26,7 @@ class PlanEditBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? planID = state.planModelObj?.planID; final response = await http.get( diff --git a/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart b/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart index 40d5f6fd..e53e6582 100644 --- a/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart +++ b/lib/presentation/plans/plan_select_screen/bloc/plan_select_bloc.dart @@ -28,9 +28,7 @@ class PlanSelectBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); // Если токен есть, запускаем приложение + // go to auth screen } final response = await http.get( Uri.parse(dotenv.env['SERVER_ROOT']! + '/plans/index'), diff --git a/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart b/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart index 616b521a..654f3ec6 100644 --- a/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart +++ b/lib/presentation/plans/plan_show_screen/bloc/plan_show_bloc.dart @@ -26,9 +26,7 @@ class PlanBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? planID = state.planModelObj?.planID; final response = await http.get( diff --git a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart index 52969177..804bab6f 100644 --- a/lib/presentation/profile/my_profile_screen/my_profile_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_profile_screen.dart @@ -1,4 +1,4 @@ -import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; +import 'package:go_router/go_router.dart'; import 'bloc/my_profile_bloc.dart'; import 'models/my_profile_model.dart'; @@ -34,9 +34,10 @@ class MyProfileScreen extends StatelessWidget { builder: (context, state) { if (state is MyProfileInitialState) { // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), ); } else if (state is MyProfileLoadedState) { // Данные загружены, можно строить экран. @@ -46,7 +47,11 @@ class MyProfileScreen extends StatelessWidget { return Center(child: Text(state.errorMessage)); } else { // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), + ); } }, ); @@ -55,8 +60,9 @@ class MyProfileScreen extends StatelessWidget { _buildMyProfileScreen(BuildContext context, MyProfileLoadedState state) { mediaQueryData = MediaQuery.of(context); return Scaffold( - appBar: CustomAppBar( - height: 0, + appBar: AppBar( + toolbarHeight: 0, + automaticallyImplyLeading: false, ), backgroundColor: Colors.grey[200], resizeToAvoidBottomInset: true, @@ -811,10 +817,7 @@ class MyProfileScreen extends StatelessWidget { ); if (response.statusCode == 201) { - Navigator.pushNamed( - context, - AppRoutes.myProfile, - ); + GoRouter.of(context).go('/my-profile-screen'); } else { // Ошибка от сервера print("Ошибка при отправке данных. Код ответа: ${response.statusCode}"); @@ -903,10 +906,7 @@ class MyProfileScreen extends StatelessWidget { ); if (response.statusCode == 201) { - Navigator.pushNamed( - context, - AppRoutes.myProfile, - ); + GoRouter.of(context).go('/my-profile-screen'); } else { // Ошибка от сервера print("Ошибка при отправке данных. Код ответа: ${response.statusCode}"); 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 fe6de3c5..5d3682a3 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -24,16 +24,21 @@ class MySettingsScreen extends StatelessWidget { builder: (context, state) { if (state is MyProfileInitialState) { // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), ); } else if (state is MyProfileLoadedState) { // Данные загружены, можно строить экран. return _buildSetingsScreen(context, state); } else { // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), + ); } }, ); diff --git a/lib/presentation/recipe/recipe_create_screen/bloc/recipe_create_bloc.dart b/lib/presentation/recipe/recipe_create_screen/bloc/recipe_create_bloc.dart index 05535dde..483dcd38 100644 --- a/lib/presentation/recipe/recipe_create_screen/bloc/recipe_create_bloc.dart +++ b/lib/presentation/recipe/recipe_create_screen/bloc/recipe_create_bloc.dart @@ -28,9 +28,7 @@ class RecipeCreateBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } if (state is RecipeCreateLoadedState) { var currentState = state as RecipeCreateLoadedState; diff --git a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart b/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart index 1e971c2d..eb87a144 100644 --- a/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart +++ b/lib/presentation/recipe/recipe_edit_screen/bloc/recipe_edit_bloc.dart @@ -29,9 +29,7 @@ class RecipeEditBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? recipeID = state.recipeModelObj?.recipeID; final response = await http.get( diff --git a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart b/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart index fc9a96f4..b597cbbc 100644 --- a/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart +++ b/lib/presentation/recipe/recipe_select_screen/bloc/recipe_select_bloc.dart @@ -28,9 +28,7 @@ class RecipeSelectBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); // Если токен есть, запускаем приложение + // go to auth screen } final response = await http.get( Uri.parse(dotenv.env['SERVER_ROOT']! + '/recipe/index'), 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 1e0b1eba..195fab7e 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -13,9 +13,7 @@ import 'package:flutter/material.dart'; class RecipeSelectScreen extends StatelessWidget { static Widget builder(BuildContext context) { return BlocProvider( - create: (context) => RecipeSelectBloc( - RecipeSelectState(myProfileModelObj: RecipeSelectModel())) - ..add(RecipeSelectInitialEvent()), + create: (context) => RecipeSelectBloc(RecipeSelectState(myProfileModelObj: RecipeSelectModel()))..add(RecipeSelectInitialEvent()), child: RecipeSelectScreen()); } @@ -23,17 +21,20 @@ class RecipeSelectScreen extends StatelessWidget { return BlocBuilder( builder: (context, state) { if (state is RecipeSelectInitialState) { - // Это начальное состояние, данные ещё не загружены. - return CircularProgressIndicator( - color: Colors.white, - backgroundColor: Colors.white, + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), ); } else if (state is RecipeSelectLoadedState) { // Данные загружены, можно строить экран. return _buildRecipeScreen(context, state); } else { - // Другие состояния, если они есть. - return Container(); // Пустой контейнер для необработанных состояний. + return Scaffold( + body: Center( + child: CircularProgressIndicator(), + ), + ); } }, ); @@ -75,8 +76,7 @@ class RecipeSelectScreen extends StatelessWidget { leadingWidth: 28.h, leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only( - left: 16.h, top: 15.v, bottom: 15.v), + margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), onTap: () => GoRouter.of(context).pop(), ), title: Padding( @@ -85,8 +85,7 @@ class RecipeSelectScreen extends StatelessWidget { children: [ AppbarSubtitle( text: "Рецепты", - margin: EdgeInsets.only( - left: 80.h, top: 12.v, bottom: 9.v), + margin: EdgeInsets.only(left: 80.h, top: 12.v, bottom: 9.v), ), Spacer(), Padding( diff --git a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart b/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart index 982266c0..b431b045 100644 --- a/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart +++ b/lib/presentation/recipe/recipe_show_screen/bloc/recipe_show_bloc.dart @@ -29,9 +29,7 @@ class RecipeBloc extends Bloc { final box = await Hive.openBox('token'); final token = box.get('token'); if (token == null) { - NavigatorService.popAndPushNamed( - AppRoutes.authScreen, - ); + // go to auth screen } final String? recipeID = state.recipeModelObj?.recipeID; final response = await http.get( diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index fd656020..2cbe9aab 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -68,8 +68,7 @@ class AppRoutes { static const String scheduleScreen = '/schedule_screen'; - static const String additionalInformationScreen = - '/additional_information_screen'; + static const String additionalInformationScreen = '/additional_information_screen'; static const String languageSelectScreen = '/language_select_screen'; @@ -129,82 +128,45 @@ class AppRoutes { static const String glossaryScreen = '/glossary'; static Map get routes => { - dateOfBirthScreen: (context) => - _buildFadeRoute(context, DateOfBirthScreen.builder), - cityOfLivingScreen: (context) => - _buildFadeRoute(context, CityOfLivingScreen.builder), - bodyCircumferencesScreen: (context) => - _buildFadeRoute(context, BodyCircumferencesScreen.builder), - weightScreen: (context) => - _buildFadeRoute(context, WeightScreen.builder), - heightScreen: (context) => - _buildFadeRoute(context, HeightScreen.builder), + dateOfBirthScreen: (context) => _buildFadeRoute(context, DateOfBirthScreen.builder), + cityOfLivingScreen: (context) => _buildFadeRoute(context, CityOfLivingScreen.builder), + bodyCircumferencesScreen: (context) => _buildFadeRoute(context, BodyCircumferencesScreen.builder), + weightScreen: (context) => _buildFadeRoute(context, WeightScreen.builder), + heightScreen: (context) => _buildFadeRoute(context, HeightScreen.builder), nameScreen: (context) => _buildFadeRoute(context, NameScreen.builder), - credentialsScreen: (context) => - _buildFadeRoute(context, CredentialsScreen.builder), - allergiesScreen: (context) => - _buildFadeRoute(context, AllergiesScreen.builder), - medicineIntakeScreen: (context) => - _buildFadeRoute(context, MedicineIntakeScreen.builder), - splashScreen: (context) => - _buildFadeRoute(context, SplashScreen.builder), - authScreen: (context) => _buildFadeRoute(context, AuthScreen.builder), - genderScreen: (context) => - _buildFadeRoute(context, GenderScreen.builder), - bloodPressureScreen: (context) => - _buildFadeRoute(context, BloodPressureScreen.builder), - favoriteSportsScreen: (context) => - _buildFadeRoute(context, FavoriteSportsScreen.builder), - favoriteFoodsScreen: (context) => - _buildFadeRoute(context, FavoriteFoodsScreen.builder), - additionalInformationScreen: (context) => - _buildFadeRoute(context, AdditionalInformationScreen.builder), - languageSelectScreen: (context) => - _buildFadeRoute(context, LanguageSelectScreen.builder), - appNavigationScreen: (context) => - _buildFadeRoute(context, AppNavigationScreen.builder), - initialRoute: (context) => - _buildFadeRoute(context, SplashScreen.builder), - myProfile: (context) => - _buildFadeRoute(context, MyProfileScreen.builder), - mySettings: (context) => - _buildFadeRoute(context, MySettingsScreen.builder), - diaryEdit: (context) => - _buildFadeRoute(context, DiaryEditScreen.builder), + credentialsScreen: (context) => _buildFadeRoute(context, CredentialsScreen.builder), + allergiesScreen: (context) => _buildFadeRoute(context, AllergiesScreen.builder), + medicineIntakeScreen: (context) => _buildFadeRoute(context, MedicineIntakeScreen.builder), + splashScreen: (context) => _buildFadeRoute(context, SplashScreen.builder), + genderScreen: (context) => _buildFadeRoute(context, GenderScreen.builder), + bloodPressureScreen: (context) => _buildFadeRoute(context, BloodPressureScreen.builder), + favoriteSportsScreen: (context) => _buildFadeRoute(context, FavoriteSportsScreen.builder), + favoriteFoodsScreen: (context) => _buildFadeRoute(context, FavoriteFoodsScreen.builder), + additionalInformationScreen: (context) => _buildFadeRoute(context, AdditionalInformationScreen.builder), + languageSelectScreen: (context) => _buildFadeRoute(context, LanguageSelectScreen.builder), + appNavigationScreen: (context) => _buildFadeRoute(context, AppNavigationScreen.builder), + initialRoute: (context) => _buildFadeRoute(context, SplashScreen.builder), + myProfile: (context) => _buildFadeRoute(context, MyProfileScreen.builder), + mySettings: (context) => _buildFadeRoute(context, MySettingsScreen.builder), + diaryEdit: (context) => _buildFadeRoute(context, DiaryEditScreen.builder), chatScreen: (context) => _buildFadeRoute(context, ChatScreen.builder), - chatSelectScreen: (context) => - _buildFadeRoute(context, ChatSelectScreen.builder), - recipeSelectScreen: (context) => - _buildFadeRoute(context, RecipeSelectScreen.builder), - recipeScreen: (context) => - _buildFadeRoute(context, RecipeScreen.builder), - recipeEditScreen: (context) => - _buildFadeRoute(context, RecipeEditScreen.builder), - recipeCreateScreen: (context) => - _buildFadeRoute(context, RecipeCreateScreen.builder), - dietSelectScreen: (context) => - _buildFadeRoute(context, DietSelectScreen.builder), + chatSelectScreen: (context) => _buildFadeRoute(context, ChatSelectScreen.builder), + recipeSelectScreen: (context) => _buildFadeRoute(context, RecipeSelectScreen.builder), + recipeScreen: (context) => _buildFadeRoute(context, RecipeScreen.builder), + recipeEditScreen: (context) => _buildFadeRoute(context, RecipeEditScreen.builder), + recipeCreateScreen: (context) => _buildFadeRoute(context, RecipeCreateScreen.builder), + dietSelectScreen: (context) => _buildFadeRoute(context, DietSelectScreen.builder), dietScreen: (context) => _buildFadeRoute(context, DietScreen.builder), - dietEditScreen: (context) => - _buildFadeRoute(context, DietEditScreen.builder), - dietCreateScreen: (context) => - _buildFadeRoute(context, DietCreateScreen.builder), - planSelectScreen: (context) => - _buildFadeRoute(context, PlanSelectScreen.builder), + dietEditScreen: (context) => _buildFadeRoute(context, DietEditScreen.builder), + dietCreateScreen: (context) => _buildFadeRoute(context, DietCreateScreen.builder), + planSelectScreen: (context) => _buildFadeRoute(context, PlanSelectScreen.builder), planScreen: (context) => _buildFadeRoute(context, PlanScreen.builder), - planEditScreen: (context) => - _buildFadeRoute(context, PlanEditScreen.builder), - planCreateScreen: (context) => - _buildFadeRoute(context, PlanCreateScreen.builder), + planEditScreen: (context) => _buildFadeRoute(context, PlanEditScreen.builder), + planCreateScreen: (context) => _buildFadeRoute(context, PlanCreateScreen.builder), feedScreen: (context) => _buildFadeRoute(context, FeedScreen.builder), - // blogPostScreen: (context) => - // _buildFadeRoute(context, BlogPostScreen.builder), - blogPostEditScreen: (context) => - _buildFadeRoute(context, BlogPostEditScreen.builder), - blogPostCreateScreen: (context) => - _buildFadeRoute(context, BlogPostCreateScreen.builder), - glossaryScreen: (context) => - _buildFadeRoute(context, GlossaryScreen.builder), + blogPostEditScreen: (context) => _buildFadeRoute(context, BlogPostEditScreen.builder), + blogPostCreateScreen: (context) => _buildFadeRoute(context, BlogPostCreateScreen.builder), + glossaryScreen: (context) => _buildFadeRoute(context, GlossaryScreen.builder), }; static Widget _buildFadeRoute(BuildContext context, WidgetBuilder builder) { @@ -220,14 +182,10 @@ class FadeTransitionPage extends PageRouteBuilder { FadeTransitionPage({required this.builder}) : super( - pageBuilder: (BuildContext context, Animation animation, - Animation secondaryAnimation) { + pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { return builder(context); }, - transitionsBuilder: (BuildContext context, - Animation animation, - Animation secondaryAnimation, - Widget child) { + transitionsBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { return FadeTransition(opacity: animation, child: child); }, ); diff --git a/lib/widgets/bottom_navigation_bar_widget.dart b/lib/widgets/bottom_navigation_bar_widget.dart index 6f29ef34..68197c17 100644 --- a/lib/widgets/bottom_navigation_bar_widget.dart +++ b/lib/widgets/bottom_navigation_bar_widget.dart @@ -73,13 +73,21 @@ class _BottomNavigationBarWidgetState extends State { items: [ BottomNavigationBarItem( label: '', - icon: SvgPicture.asset(ImageConstant.imgLogo), + icon: SvgPicture.asset( + ImageConstant.imgLogo, + ), ), BottomNavigationBarItem( label: 'Лента', - icon: SvgPicture.asset(ImageConstant.imgFeed), + icon: SvgPicture.asset( + width: 24, + height: 24, + ImageConstant.imgFeed, + ), activeIcon: SvgPicture.asset( ImageConstant.imgFeed, + width: 24, + height: 24, colorFilter: ColorFilter.mode( appTheme.blueA400, BlendMode.srcIn, @@ -88,9 +96,15 @@ class _BottomNavigationBarWidgetState extends State { ), BottomNavigationBarItem( label: "diary".tr, - icon: SvgPicture.asset(ImageConstant.imgDiary), + icon: SvgPicture.asset( + ImageConstant.imgDiary, + width: 24, + height: 24, + ), activeIcon: SvgPicture.asset( ImageConstant.imgDiary, + width: 24, + height: 24, colorFilter: ColorFilter.mode( appTheme.blueA400, BlendMode.srcIn, @@ -99,9 +113,15 @@ class _BottomNavigationBarWidgetState extends State { ), BottomNavigationBarItem( label: "chat".tr, - icon: SvgPicture.asset(ImageConstant.imgChat), + icon: SvgPicture.asset( + ImageConstant.imgChat, + width: 24, + height: 24, + ), activeIcon: SvgPicture.asset( ImageConstant.imgChat, + width: 24, + height: 24, colorFilter: ColorFilter.mode( appTheme.blueA400, BlendMode.srcIn, @@ -110,9 +130,15 @@ class _BottomNavigationBarWidgetState extends State { ), BottomNavigationBarItem( label: '', - icon: SvgPicture.asset(ImageConstant.imgBell), + icon: SvgPicture.asset( + ImageConstant.imgBell, + width: 24, + height: 24, + ), activeIcon: SvgPicture.asset( ImageConstant.imgBell, + width: 24, + height: 24, colorFilter: ColorFilter.mode( appTheme.blueA400, BlendMode.srcIn, diff --git a/lib/widgets/custom_expandable_list.dart b/lib/widgets/custom_expandable_list.dart index 00d66cea..c3d552b7 100644 --- a/lib/widgets/custom_expandable_list.dart +++ b/lib/widgets/custom_expandable_list.dart @@ -3,6 +3,7 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/presentation/profile/my_profile_screen/bloc/my_profile_bloc.dart'; import 'package:eatvio_app/widgets/custom_hyper_switch.dart'; import 'package:eatvio_app/widgets/custom_hypo_switch.dart'; +import 'package:go_router/go_router.dart'; import 'package:intl/intl.dart'; import 'package:eatvio_app/widgets/next_step_button.dart'; import 'dart:convert'; @@ -395,10 +396,7 @@ class _ExpandableListState extends State { } void _navigateToProfilePage() { - Navigator.pushNamed( - context, - AppRoutes.myProfile, - ); + GoRouter.of(context).go('/my-profile-screen'); } String _getErrorMessage(http.Response response) {