diff --git a/lib/app_router.dart b/lib/app_router.dart index 6f677a8..aeed36c 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -10,7 +10,20 @@ import 'package:eatvio_app/presentation/plans/plan_select_screen/plan_select_scr 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/additional_information_screen/additional_information_screen.dart'; +import 'package:eatvio_app/presentation/registration/allergies_screen/allergies_screen.dart'; +import 'package:eatvio_app/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart'; +import 'package:eatvio_app/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart'; +import 'package:eatvio_app/presentation/registration/city_of_living_screen/city_of_living_screen.dart'; +import 'package:eatvio_app/presentation/registration/credentials_screen/credentials_screen.dart'; +import 'package:eatvio_app/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart'; +import 'package:eatvio_app/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart'; +import 'package:eatvio_app/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart'; +import 'package:eatvio_app/presentation/registration/gender_screen/gender_screen.dart'; +import 'package:eatvio_app/presentation/registration/height_screen/height_screen.dart'; import 'package:eatvio_app/presentation/registration/language_select_screen/language_select_screen.dart'; +import 'package:eatvio_app/presentation/registration/name_screen/name_screen.dart'; +import 'package:eatvio_app/presentation/registration/weight_screen/weight_screen.dart'; import 'package:eatvio_app/widgets/bottom_navigation_bar_widget.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -40,6 +53,97 @@ class AppRouter { path: 'language-select-screen', name: 'languageSelectScreen', builder: (context, state) => LanguageSelectScreen.builder(context), + routes: [ + GoRoute( + path: 'credentials-screen', + name: 'credentialsScreen', + builder: (context, state) => CredentialsScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'name-screen', + name: 'nameScreen', + builder: (context, state) => NameScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'gender-screen', + name: 'genderScreen', + builder: (context, state) => GenderScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'date-of-birth-screen', + name: 'dateOfBirthScreen', + builder: (context, state) => DateOfBirthScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'city-of-living-screen', + name: 'cityOfLivingScreen', + builder: (context, state) => CityOfLivingScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'body-circumferences-screen', + name: 'bodyCircumferencesScreen', + builder: (context, state) => BodyCircumferencesScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'weight-screen', + name: 'weightScreen', + builder: (context, state) => WeightScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'height-screen', + name: 'heightScreen', + builder: (context, state) => HeightScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'blood-pressure-screen', + name: 'bloodPressureScreen', + builder: (context, state) => BloodPressureScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'favorite-sports-screen', + name: 'favoriteSportsScreen', + builder: (context, state) => FavoriteSportsScreen.builder(context, state.extra), + routes: [ + GoRoute( + name: 'allergiesScreen', + path: 'allergiesScreen', + builder: (context, state) => AllergiesScreen.builder(context, state.extra), + routes: [ + GoRoute( + name: 'favoriteFoodsScreen', + path: 'favorite-foods-screen', + builder: (context, state) => FavoriteFoodsScreen.builder(context, state.extra), + routes: [ + GoRoute( + path: 'additional-information-screen', + name: 'additionalInformationScreen', + builder: (context, state) => AdditionalInformationScreen.builder(context, state.extra), + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], ), ], ), diff --git a/lib/core/app_export.dart b/lib/core/app_export.dart index fe2ac98..926e7cb 100644 --- a/lib/core/app_export.dart +++ b/lib/core/app_export.dart @@ -5,7 +5,6 @@ export 'package:eatvio_app/core/errors/exceptions.dart'; export 'package:eatvio_app/core/network/network_info.dart'; export 'package:eatvio_app/core/utils/image_constant.dart'; export 'package:eatvio_app/core/utils/logger.dart'; -export 'package:eatvio_app/core/utils/navigator_service.dart'; export 'package:eatvio_app/core/utils/pref_utils.dart'; export 'package:eatvio_app/core/utils/size_utils.dart'; export 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; diff --git a/lib/core/utils/navigator_service.dart b/lib/core/utils/navigator_service.dart deleted file mode 100644 index e5ea835..0000000 --- a/lib/core/utils/navigator_service.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:flutter/material.dart'; - -class NavigatorService { - static GlobalKey navigatorKey = GlobalKey(); - - static Future pushNamed(String routeName, - {dynamic arguments}) async { - return navigatorKey.currentState - ?.pushNamed(routeName, arguments: arguments); - } - - static void goBack() { - return navigatorKey.currentState?.pop(); - } - - static Future pushNamedAndRemoveUntil(String routeName, - {bool routePredicate = false, dynamic arguments}) async { - return navigatorKey.currentState?.pushNamedAndRemoveUntil( - routeName, (route) => routePredicate, - arguments: arguments); - } - - static Future popAndPushNamed(String routeName, - {dynamic arguments}) async { - return navigatorKey.currentState - ?.popAndPushNamed(routeName, arguments: arguments); - } -} diff --git a/lib/core/utils/progress_dialog_utils.dart b/lib/core/utils/progress_dialog_utils.dart index b111e96..7ac6ed7 100644 --- a/lib/core/utils/progress_dialog_utils.dart +++ b/lib/core/utils/progress_dialog_utils.dart @@ -1,3 +1,4 @@ +import 'package:eatvio_app/app_router.dart'; import 'package:flutter/material.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -5,13 +6,11 @@ class ProgressDialogUtils { static bool isProgressVisible = false; ///common method for showing progress dialog - static void showProgressDialog( - {BuildContext? context, isCancellable = false}) async { - if (!isProgressVisible && - NavigatorService.navigatorKey.currentState?.overlay?.context != null) { + static void showProgressDialog({BuildContext? context, isCancellable = false}) async { + if (!isProgressVisible && AppRouter.navigatorKey.currentState?.overlay?.context != null) { showDialog( barrierDismissible: isCancellable, - context: NavigatorService.navigatorKey.currentState!.overlay!.context, + context: AppRouter.navigatorKey.currentState!.overlay!.context, builder: (BuildContext context) { return Center( child: CircularProgressIndicator.adaptive( @@ -28,9 +27,7 @@ class ProgressDialogUtils { ///common method for hiding progress dialog static void hideProgressDialog() { - if (isProgressVisible) - Navigator.pop( - NavigatorService.navigatorKey.currentState!.overlay!.context); + if (isProgressVisible) Navigator.pop(AppRouter.navigatorKey.currentState!.overlay!.context); isProgressVisible = false; } } diff --git a/lib/localization/app_localization.dart b/lib/localization/app_localization.dart index 4701a67..98ee1eb 100644 --- a/lib/localization/app_localization.dart +++ b/lib/localization/app_localization.dart @@ -1,3 +1,5 @@ +import 'package:eatvio_app/app_router.dart'; + import 'ru/ru_translations.dart'; //import 'en_us/en_us_translations.dart'; import 'package:flutter/foundation.dart'; @@ -17,7 +19,7 @@ class AppLocalization { };*/ static AppLocalization of() { - final context = NavigatorService.navigatorKey.currentContext; + final context = AppRouter.navigatorKey.currentContext; if (context != null) { return Localizations.of(context, AppLocalization)!; } else { diff --git a/lib/presentation/auth/auth_screen/auth_screen.dart b/lib/presentation/auth/auth_screen/auth_screen.dart index 6b6c3a4..7235372 100644 --- a/lib/presentation/auth/auth_screen/auth_screen.dart +++ b/lib/presentation/auth/auth_screen/auth_screen.dart @@ -21,7 +21,9 @@ class AuthScreen extends StatelessWidget { AuthState( authModelObj: AuthModel(), ), - )..add(AuthInitialEvent()), + )..add( + AuthInitialEvent(), + ), child: AuthScreen(), ); } @@ -61,10 +63,11 @@ class AuthScreen extends StatelessWidget { }), SizedBox(height: 50.v), NextStepButton( - text: "no_account".tr.toUpperCase(), - margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapNoAccount(context)), + text: "no_account".tr.toUpperCase(), + margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + onPressed: onTapNoAccount(context), + ), /*NextStepButton( text: "Тест дневника".toUpperCase(), margin: @@ -143,13 +146,29 @@ class AuthScreen extends StatelessWidget { }; } - onTapOk(BuildContext context) => GoRouter.of(context).pop(context); + onTapOk(BuildContext context) { + return () { + GoRouter.of(context).pop(context); + }; + } - onTapDiaryTest(BuildContext context) => GoRouter.of(context).goNamed('diaryScreen'); + onTapDiaryTest(BuildContext context) { + return () { + GoRouter.of(context).goNamed('diaryScreen'); + }; + } - onTapProfileTest(BuildContext context) => GoRouter.of(context).goNamed('mySettingsScreen'); + onTapProfileTest(BuildContext context) { + return () { + GoRouter.of(context).goNamed('mySettingsScreen'); + }; + } - onTapNoAccount(BuildContext context) => GoRouter.of(context).goNamed('languageSelectScreen'); + onTapNoAccount(BuildContext context) { + return () { + GoRouter.of(context).goNamed('languageSelectScreen'); + }; + } /// Section Widget _buildAppBar(BuildContext context) { diff --git a/lib/presentation/auth/auth_screen/bloc/auth_bloc.dart b/lib/presentation/auth/auth_screen/bloc/auth_bloc.dart index cd0203a..6622981 100644 --- a/lib/presentation/auth/auth_screen/bloc/auth_bloc.dart +++ b/lib/presentation/auth/auth_screen/bloc/auth_bloc.dart @@ -2,7 +2,9 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; import '/core/app_export.dart'; import 'package:eatvio_app/presentation/auth/auth_screen/models/auth_model.dart'; + part 'auth_event.dart'; + part 'auth_state.dart'; /// A bloc that manages the state of a Auth according to the event that is dispatched to it. @@ -15,8 +17,11 @@ class AuthBloc extends Bloc { AuthInitialEvent event, Emitter emit, ) async { - emit(state.copyWith( + emit( + state.copyWith( emailController: TextEditingController(), - passwordController: TextEditingController())); + passwordController: TextEditingController(), + ), + ); } } diff --git a/lib/presentation/chat/chat_screen/chat_screen.dart b/lib/presentation/chat/chat_screen/chat_screen.dart index 48169f5..b69a0ec 100644 --- a/lib/presentation/chat/chat_screen/chat_screen.dart +++ b/lib/presentation/chat/chat_screen/chat_screen.dart @@ -1,3 +1,6 @@ +import 'package:eatvio_app/app_router.dart'; +import 'package:go_router/go_router.dart'; + import 'bloc/chat_bloc.dart'; import 'models/chat_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -117,6 +120,6 @@ class ChatScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowleftone(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 ef058bd..68834d0 100644 --- a/lib/presentation/diets/diet_select_screen/diet_select_screen.dart +++ b/lib/presentation/diets/diet_select_screen/diet_select_screen.dart @@ -173,6 +173,6 @@ class DietSelectScreen extends StatelessWidget { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 f6af548..0c06f5d 100644 --- a/lib/presentation/diets/diet_show_screen/diet_show_screen.dart +++ b/lib/presentation/diets/diet_show_screen/diet_show_screen.dart @@ -129,6 +129,6 @@ class DietScreen extends StatelessWidget { /// 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 cddb9cc..1af8a84 100644 --- a/lib/presentation/feed/feed_screen/feed_screen.dart +++ b/lib/presentation/feed/feed_screen/feed_screen.dart @@ -267,7 +267,7 @@ class FeedScreen extends StatelessWidget { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } _buildMenu(BuildContext context, FeedLoadedState state) { 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 519ff0d..810bd3a 100644 --- a/lib/presentation/plans/plan_select_screen/plan_select_screen.dart +++ b/lib/presentation/plans/plan_select_screen/plan_select_screen.dart @@ -174,6 +174,6 @@ class PlanSelectScreen extends StatelessWidget { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 287cf85..a19f6da 100644 --- a/lib/presentation/plans/plan_show_screen/plan_show_screen.dart +++ b/lib/presentation/plans/plan_show_screen/plan_show_screen.dart @@ -1,4 +1,6 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/plan_show_bloc.dart'; import 'models/plan_show_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -127,6 +129,6 @@ class PlanScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowleftone(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 5d3682a..ea56a75 100644 --- a/lib/presentation/profile/my_profile_screen/my_settings_screen.dart +++ b/lib/presentation/profile/my_profile_screen/my_settings_screen.dart @@ -179,6 +179,6 @@ class MySettingsScreen extends StatelessWidget { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 76e8a63..3a81754 100644 --- a/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart +++ b/lib/presentation/recipe/recipe_create_screen/recipe_create_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/recipe_create_bloc.dart'; import 'models/recipe_create_model.dart'; import 'package:eatvio_app/core/app_export.dart'; @@ -384,6 +386,6 @@ class RecipeCreateScreen extends StatelessWidget { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 b204e6f..8e16144 100644 --- a/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart +++ b/lib/presentation/recipe/recipe_edit_screen/recipe_edit_screen.dart @@ -1,3 +1,5 @@ +import 'package:go_router/go_router.dart'; + import 'bloc/recipe_edit_bloc.dart'; import 'models/recipe_edit_model.dart'; import 'package:flutter/material.dart'; @@ -427,6 +429,6 @@ class RecipeEditScreen extends StatelessWidget { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 8ac9416..2a3a108 100644 --- a/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart +++ b/lib/presentation/recipe/recipe_select_screen/recipe_select_screen.dart @@ -172,6 +172,6 @@ class RecipeSelectScreen extends StatelessWidget { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } 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 a51d7f9..f1835f8 100644 --- a/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart +++ b/lib/presentation/recipe/recipe_show_screen/recipe_show_screen.dart @@ -103,7 +103,10 @@ class RecipeScreen extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - CustomImageView(imagePath: ImageConstant.imgArrowLeft, onTap: () => NavigatorService.goBack()), + CustomImageView( + imagePath: ImageConstant.imgArrowLeft, + onTap: () => GoRouter.of(context).pop(), + ), Padding( padding: EdgeInsets.only(top: 1.v), child: Row( @@ -405,7 +408,7 @@ class RecipeScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowleftone(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } Widget _buildStep(BuildContext context, RecipeLoadedState state, int i) { diff --git a/lib/presentation/registration/additional_information_screen/additional_information_screen.dart b/lib/presentation/registration/additional_information_screen/additional_information_screen.dart index 47c01b3..0a695a5 100644 --- a/lib/presentation/registration/additional_information_screen/additional_information_screen.dart +++ b/lib/presentation/registration/additional_information_screen/additional_information_screen.dart @@ -18,15 +18,11 @@ import 'package:http/http.dart' as http; class AdditionalInformationScreen extends StatelessWidget { const AdditionalInformationScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = - ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( - create: (context) => AdditionalInformationBloc( - AdditionalInformationState( - additionalInformationModelObj: - AdditionalInformationModel(userRegistrationSheet: sheet))) - ..add(AdditionalInformationInitialEvent()), + create: (context) => + AdditionalInformationBloc(AdditionalInformationState(additionalInformationModelObj: AdditionalInformationModel(userRegistrationSheet: sheet))) + ..add(AdditionalInformationInitialEvent()), child: AdditionalInformationScreen()); } @@ -48,25 +44,19 @@ class AdditionalInformationScreen extends StatelessWidget { decoration: BoxDecoration( color: theme.colorScheme.onPrimary, borderRadius: BorderRadius.circular(8.h), - border: Border.all( - color: theme.colorScheme.primary, width: 1.h)), + border: Border.all(color: theme.colorScheme.primary, width: 1.h)), child: ClipRRect( borderRadius: BorderRadius.circular(8.h), child: LinearProgressIndicator( - value: 1, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400)))), + value: 1, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), SizedBox(height: 20.v), SizedBox(height: 73.v), _buildTextFormField(context), Spacer(), - BlocBuilder(builder: (context, state) { + BlocBuilder(builder: (context, state) { return NextStepButton( text: "finish".tr.toUpperCase(), - margin: EdgeInsets.only( - left: 16.h, right: 16.h, bottom: 50.v), + margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, onPressed: onTapFinish(state, context)); }), @@ -75,18 +65,11 @@ class AdditionalInformationScreen extends StatelessWidget { onTapFinish(AdditionalInformationState state, BuildContext context) { return () async { - UserRegistrationSheet sheet = - state.additionalInformationModelObj!.userRegistrationSheet; + UserRegistrationSheet sheet = state.additionalInformationModelObj!.userRegistrationSheet; sheet.additionalInfo = state.editTextController!.text; - final response = await http.post( - Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'), - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }, - body: jsonEncode(sheet.toJson()), - encoding: utf8); + final response = await http.post(Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'), + headers: {'Content-Type': 'application/json', 'Accept': 'application/json'}, body: jsonEncode(sheet.toJson()), encoding: utf8); var res = await jsonDecode(response.body); if (response.statusCode == 200) { @@ -104,10 +87,8 @@ class AdditionalInformationScreen extends StatelessWidget { _buildAppBar(BuildContext context) { return CustomAppBar( leadingWidth: 31.h, - leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 18.h, top: 15.v, bottom: 15.v), - onTap: onTapBack(context)), + leading: + AppbarLeadingImage(imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 18.h, top: 15.v, bottom: 15.v), onTap: onTapBack(context)), centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } @@ -131,19 +112,14 @@ class AdditionalInformationScreen extends StatelessWidget { width: 294.h, margin: EdgeInsets.only(left: 24.h, right: 23.h), child: Text("enter_additional_information".tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: CustomTextStyles.titleMediumSegoeUI)), + maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: CustomTextStyles.titleMediumSegoeUI)), SizedBox(height: 10.v), - BlocSelector( + BlocSelector( selector: (state) => state.editTextController, builder: (context, editTextController) { return CustomTextFormField( controller: editTextController, - hintText: - "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", + hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", textInputAction: TextInputAction.done, maxLines: 8); }) @@ -153,7 +129,7 @@ class AdditionalInformationScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } /// Displays an alert dialog when the action is triggered. @@ -164,9 +140,7 @@ class AdditionalInformationScreen extends StatelessWidget { builder: (_) => AlertDialog( title: const Text('Ошибка'), content: Text(text), - actions: [ - TextButton(onPressed: onTapOk(context), child: const Text('Ok')) - ], + actions: [TextButton(onPressed: onTapOk(context), child: const Text('Ok'))], )); } diff --git a/lib/presentation/registration/allergies_screen/allergies_screen.dart b/lib/presentation/registration/allergies_screen/allergies_screen.dart index 75528b6..50d056b 100644 --- a/lib/presentation/registration/allergies_screen/allergies_screen.dart +++ b/lib/presentation/registration/allergies_screen/allergies_screen.dart @@ -14,8 +14,7 @@ import 'package:flutter/material.dart'; class AllergiesScreen extends StatefulWidget { const AllergiesScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => AllergiesBloc(AllergiesState(allergiesModelObj: AllergiesModel(userRegistrationSheet: sheet)))..add(AllergiesInitialEvent()), child: AllergiesScreen()); @@ -28,46 +27,44 @@ class AllergiesScreen extends StatefulWidget { class _AllergiesScreenState extends State { @override Widget build(BuildContext context) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column(children: [ - SizedBox(height: 7.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.76, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), - SizedBox(height: 22.v), - Text("allergies_presence".tr, style: theme.textTheme.headlineSmall), - Spacer(flex: 36), - _buildTextFormField(context), - Spacer(flex: 54), - 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: onTapContinue(state, context)); - }), - BlocBuilder(builder: (context, state) { - return GestureDetector( - onTap: onTapSkip(state, context), - child: Text("skip".tr, style: theme.textTheme.bodyLarge), - ); - }), - ])))); + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column(children: [ + SizedBox(height: 7.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.76, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 22.v), + Text("allergies_presence".tr, style: theme.textTheme.headlineSmall), + Spacer(flex: 36), + _buildTextFormField(context), + Spacer(flex: 54), + 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: onTapContinue(state, context)); + }), + BlocBuilder(builder: (context, state) { + return GestureDetector( + onTap: onTapSkip(state, context), + child: Text("skip".tr, style: theme.textTheme.bodyLarge), + ); + }), + ]))); } onTapSkip(AllergiesState state, BuildContext context) { @@ -117,6 +114,6 @@ class _AllergiesScreenState extends State { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } diff --git a/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart b/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart index 681d5ce..5d4d8cc 100644 --- a/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart +++ b/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart @@ -17,8 +17,7 @@ import 'package:flutter/material.dart'; class BloodPressureScreen extends StatefulWidget { const BloodPressureScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => BloodPressureBloc(BloodPressureState(bloodPressureModelObj: BloodPressureModel(userRegistrationSheet: sheet)))..add(BloodPressureInitialEvent()), @@ -33,118 +32,116 @@ class _BloodPressureScreenState extends State { @override Widget build(BuildContext context) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 9.v), - child: Column(children: [ - SizedBox(height: 7.v), - Container( - height: 16.v, - width: 343.h, - padding: EdgeInsets.symmetric(horizontal: 4.h), - // Apply padding directly to the Container - 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.62, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation(appTheme.blueA400), - ), - ), + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 9.v), + child: Column(children: [ + SizedBox(height: 7.v), + Container( + height: 16.v, + width: 343.h, + padding: EdgeInsets.symmetric(horizontal: 4.h), + // Apply padding directly to the Container + decoration: BoxDecoration( + color: theme.colorScheme.onPrimary, + borderRadius: BorderRadius.circular(8.h), + border: Border.all( + color: theme.colorScheme.primary, + width: 1.h, ), - SizedBox(height: 21.v), - SizedBox( - width: 224.h, - child: Text("your_blood_pressure".tr, - maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: theme.textTheme.headlineSmall)), - SizedBox(height: 21.v), - Container( - margin: EdgeInsets.only(right: 1.h), - padding: EdgeInsets.symmetric(horizontal: 3.h), - child: Column(children: [ - Text("up_pressure".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.upPressureController, - builder: (context, upPressureController) { - return CustomTextFormField(inputFormatters: [digitsOnly], controller: upPressureController, hintText: "90".tr); - }) - ])), - SizedBox(height: 21.v), - Container( - margin: EdgeInsets.only(right: 1.h), - padding: EdgeInsets.symmetric(horizontal: 3.h), - child: Column(children: [ - Text("down_pressure".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.downPressureController, - builder: (context, downPressureController) { - return CustomTextFormField(inputFormatters: [digitsOnly], controller: downPressureController, hintText: "90".tr); - }) - ])), - SizedBox(height: 22.v), - Text("do_you_have_hypotension_tendency".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 4.h), - child: BlocSelector( - selector: (state) => state.bloodPressureModelObj, - builder: (context, bloodPressureModelObj) { - return CustomDropDown( - icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize)), - hintText: "Не выбрано".tr, - items: bloodPressureModelObj?.dropdownItemList ?? [], - onChanged: onChangeHyper(context)); - })), - SizedBox(height: 22.v), - Text("do_you_have_hypertension_tendency".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - Padding( - padding: EdgeInsets.symmetric(horizontal: 4.h), - child: BlocSelector( - selector: (state) => state.bloodPressureModelObj, - builder: (context, bloodPressureModelObj) { - return CustomDropDown( - icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize)), - hintText: "Не выбрано".tr, - items: bloodPressureModelObj?.dropdownItemList ?? [], - onChanged: onChangeHypo(context)); - })), - Spacer(), - 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: onTapContinue(state, context)); - }), - BlocBuilder(builder: (context, state) { - return GestureDetector( - onTap: onTapSkip(state, context), - child: Text("skip".tr, style: theme.textTheme.bodyLarge), - ); - }), - ])))); + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.h), + child: LinearProgressIndicator( + value: 0.62, + backgroundColor: theme.colorScheme.onPrimary, + valueColor: AlwaysStoppedAnimation(appTheme.blueA400), + ), + ), + ), + SizedBox(height: 21.v), + SizedBox( + width: 224.h, + child: Text("your_blood_pressure".tr, + maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: theme.textTheme.headlineSmall)), + SizedBox(height: 21.v), + Container( + margin: EdgeInsets.only(right: 1.h), + padding: EdgeInsets.symmetric(horizontal: 3.h), + child: Column(children: [ + Text("up_pressure".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + BlocSelector( + selector: (state) => state.upPressureController, + builder: (context, upPressureController) { + return CustomTextFormField(inputFormatters: [digitsOnly], controller: upPressureController, hintText: "90".tr); + }) + ])), + SizedBox(height: 21.v), + Container( + margin: EdgeInsets.only(right: 1.h), + padding: EdgeInsets.symmetric(horizontal: 3.h), + child: Column(children: [ + Text("down_pressure".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + BlocSelector( + selector: (state) => state.downPressureController, + builder: (context, downPressureController) { + return CustomTextFormField(inputFormatters: [digitsOnly], controller: downPressureController, hintText: "90".tr); + }) + ])), + SizedBox(height: 22.v), + Text("do_you_have_hypotension_tendency".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + Padding( + padding: EdgeInsets.symmetric(horizontal: 4.h), + child: BlocSelector( + selector: (state) => state.bloodPressureModelObj, + builder: (context, bloodPressureModelObj) { + return CustomDropDown( + icon: Container( + margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), + child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize)), + hintText: "Не выбрано".tr, + items: bloodPressureModelObj?.dropdownItemList ?? [], + onChanged: onChangeHyper(context)); + })), + SizedBox(height: 22.v), + Text("do_you_have_hypertension_tendency".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + Padding( + padding: EdgeInsets.symmetric(horizontal: 4.h), + child: BlocSelector( + selector: (state) => state.bloodPressureModelObj, + builder: (context, bloodPressureModelObj) { + return CustomDropDown( + icon: Container( + margin: EdgeInsets.fromLTRB(30.h, 11.v, 13.h, 11.v), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), + child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize)), + hintText: "Не выбрано".tr, + items: bloodPressureModelObj?.dropdownItemList ?? [], + onChanged: onChangeHypo(context)); + })), + Spacer(), + 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: onTapContinue(state, context)); + }), + BlocBuilder(builder: (context, state) { + return GestureDetector( + onTap: onTapSkip(state, context), + child: Text("skip".tr, style: theme.textTheme.bodyLarge), + ); + }), + ]))); } onTapSkip(BloodPressureState state, BuildContext context) { @@ -222,7 +219,7 @@ class _BloodPressureScreenState extends State { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } List validateFields( diff --git a/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart b/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart index 2df67fc..3610697 100644 --- a/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart +++ b/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart @@ -15,76 +15,75 @@ import 'package:flutter/material.dart'; class BodyCircumferencesScreen extends StatelessWidget { const BodyCircumferencesScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( - create: (context) => BodyCircumferencesBloc(BodyCircumferencesState(bodyCircumferencesModelObj: BodyCircumferencesModel(userRegistrationSheet: sheet))) - ..add(BodyCircumferencesInitialEvent()), - child: BodyCircumferencesScreen()); + create: (context) => BodyCircumferencesBloc(BodyCircumferencesState(bodyCircumferencesModelObj: BodyCircumferencesModel(userRegistrationSheet: sheet))) + ..add(BodyCircumferencesInitialEvent()), + child: BodyCircumferencesScreen(), + ); } @override Widget build(BuildContext context) { final digitsOnly = FilteringTextInputFormatter.digitsOnly; mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column(children: [ - SizedBox(height: 7.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.40, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), - SizedBox(height: 39.v), - Text("initial_measurements".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 93.v), - Column(children: [ - Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.chestCircumferenceController, - builder: (context, chestCircumferenceController) { - return CustomTextFormField(inputFormatters: [digitsOnly], controller: chestCircumferenceController, hintText: "90".tr); - }) - ]), - SizedBox(height: 19.v), - Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - BlocSelector( - selector: (state) => state.waistCircumferenceController, - builder: (context, waistCircumferenceController) { - return CustomTextFormField(inputFormatters: [digitsOnly], controller: waistCircumferenceController, hintText: "60".tr); - }), - SizedBox(height: 21.v), - Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.hipCircumferenceController, - builder: (context, hipCircumferenceController) { - return CustomTextFormField( - inputFormatters: [digitsOnly], controller: hipCircumferenceController, hintText: "90".tr, textInputAction: TextInputAction.done); - }), - Spacer(), - 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: onTapContinue(state, context)); + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column(children: [ + SizedBox(height: 7.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.40, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 39.v), + Text("initial_measurements".tr, style: theme.textTheme.headlineSmall), + SizedBox(height: 93.v), + Column(children: [ + Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 3.v), + BlocSelector( + selector: (state) => state.chestCircumferenceController, + builder: (context, chestCircumferenceController) { + return CustomTextFormField(inputFormatters: [digitsOnly], controller: chestCircumferenceController, hintText: "90".tr); + }) + ]), + SizedBox(height: 19.v), + Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 5.v), + BlocSelector( + selector: (state) => state.waistCircumferenceController, + builder: (context, waistCircumferenceController) { + return CustomTextFormField(inputFormatters: [digitsOnly], controller: waistCircumferenceController, hintText: "60".tr); }), - ])))); + SizedBox(height: 21.v), + Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 3.v), + BlocSelector( + selector: (state) => state.hipCircumferenceController, + builder: (context, hipCircumferenceController) { + return CustomTextFormField( + inputFormatters: [digitsOnly], controller: hipCircumferenceController, hintText: "90".tr, textInputAction: TextInputAction.done); + }), + Spacer(), + 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: onTapContinue(state, context)); + }), + ]))); } onTapContinue(BodyCircumferencesState state, BuildContext context) { @@ -145,7 +144,7 @@ class BodyCircumferencesScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } /// Navigates to the weightScreen when the action is triggered. diff --git a/lib/presentation/registration/city_of_living_screen/city_of_living_screen.dart b/lib/presentation/registration/city_of_living_screen/city_of_living_screen.dart index 3e78a1f..5ce9150 100644 --- a/lib/presentation/registration/city_of_living_screen/city_of_living_screen.dart +++ b/lib/presentation/registration/city_of_living_screen/city_of_living_screen.dart @@ -15,12 +15,12 @@ import 'package:flutter/material.dart'; class CityOfLivingScreen extends StatelessWidget { const CityOfLivingScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( - create: (context) => - CityOfLivingBloc(CityOfLivingState(cityOfLivingModelObj: CityOfLivingModel(userRegistrationSheet: sheet)))..add(CityOfLivingInitialEvent()), - child: CityOfLivingScreen()); + create: (context) => + CityOfLivingBloc(CityOfLivingState(cityOfLivingModelObj: CityOfLivingModel(userRegistrationSheet: sheet)))..add(CityOfLivingInitialEvent()), + child: CityOfLivingScreen(), + ); } @override @@ -1144,102 +1144,100 @@ class CityOfLivingScreen extends StatelessWidget { "Ясный", "Яхрома" ]; - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column(children: [ - SizedBox(height: 7.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.32, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), - SizedBox(height: 39.v), - Text("place_of_living".tr, style: theme.textTheme.headlineSmall), - Spacer(flex: 34), - Text("country".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.cityOfLivingModelObj, - builder: (context, cityOfLivingModelObj) { - 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: cityOfLivingModelObj?.dropdownItemList ?? [], - onChanged: onDropDownChange(context)); - }), - SizedBox(height: 22.v), - Text("Населенный пункт", style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - BlocBuilder(builder: (context, state) { - return RawAutocomplete( - optionsBuilder: (TextEditingValue textEditingValue) => _options.where((String option) { - return option.toLowerCase().startsWith(textEditingValue.text.toLowerCase()); - }), - fieldViewBuilder: ( - BuildContext context, - TextEditingController textEditingController, - FocusNode focusNode, - VoidCallback onFieldSubmitted, - ) { - return CustomTextFormField( - controller: textEditingController, - focusNode: focusNode, - onFieldSubmitted: (String value) => onFieldSubmitted(), - ); - }, - optionsViewBuilder: ( - BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options, - ) { - return Align( - alignment: Alignment.topLeft, - child: Material( - elevation: 4.0, - child: SizedBox( - height: 200.0, - child: ListView.builder( - padding: const EdgeInsets.all(8.0), - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final String option = options.elementAt(index); - return GestureDetector( - onTap: () => onSelected(option), - child: ListTile( - title: Text(option), - ), - ); - }, - ), - ), - ), - ); - }, + return Scaffold( + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column(children: [ + SizedBox(height: 7.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.32, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 39.v), + Text("place_of_living".tr, style: theme.textTheme.headlineSmall), + Spacer(flex: 34), + Text("country".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + BlocSelector( + selector: (state) => state.cityOfLivingModelObj, + builder: (context, cityOfLivingModelObj) { + 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: cityOfLivingModelObj?.dropdownItemList ?? [], + onChanged: onDropDownChange(context)); + }), + SizedBox(height: 22.v), + Text("Населенный пункт", style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + BlocBuilder(builder: (context, state) { + return RawAutocomplete( + optionsBuilder: (TextEditingValue textEditingValue) => _options.where((String option) { + return option.toLowerCase().startsWith(textEditingValue.text.toLowerCase()); + }), + fieldViewBuilder: ( + BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted, + ) { + return CustomTextFormField( + controller: textEditingController, + focusNode: focusNode, + onFieldSubmitted: (String value) => onFieldSubmitted(), ); - }), - Spacer(flex: 65), - 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: onTapContinue(state, context)); - }), - ])))); + }, + optionsViewBuilder: ( + BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options, + ) { + return Align( + alignment: Alignment.topLeft, + child: Material( + elevation: 4.0, + child: SizedBox( + height: 200.0, + child: ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final String option = options.elementAt(index); + return GestureDetector( + onTap: () => onSelected(option), + child: ListTile( + title: Text(option), + ), + ); + }, + ), + ), + ), + ); + }, + ); + }), + Spacer(flex: 65), + 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: onTapContinue(state, context)); + }), + ]))); } onTapContinue(CityOfLivingState state, BuildContext context) { @@ -1273,7 +1271,7 @@ class CityOfLivingScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } diff --git a/lib/presentation/registration/credentials_screen/credentials_screen.dart b/lib/presentation/registration/credentials_screen/credentials_screen.dart index ba51783..90723f6 100644 --- a/lib/presentation/registration/credentials_screen/credentials_screen.dart +++ b/lib/presentation/registration/credentials_screen/credentials_screen.dart @@ -12,9 +12,7 @@ import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; class CredentialsScreen extends StatelessWidget { - static Widget builder(BuildContext context) { - final sheet = - ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => CredentialsBloc( CredentialsState( @@ -42,45 +40,33 @@ class CredentialsScreen extends StatelessWidget { decoration: BoxDecoration( color: theme.colorScheme.onPrimary, borderRadius: BorderRadius.circular(8.h), - border: Border.all( - color: theme.colorScheme.primary, width: 1.h)), + border: Border.all(color: theme.colorScheme.primary, width: 1.h)), child: ClipRRect( borderRadius: BorderRadius.circular(8.h), child: LinearProgressIndicator( - value: 0.05, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400)))), + value: 0.05, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), SizedBox(height: 39.v), - Text("user_registration".tr, - style: theme.textTheme.headlineSmall), + Text("user_registration".tr, style: theme.textTheme.headlineSmall), SizedBox(height: 16.v), Text("email".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), - BlocSelector( + BlocSelector( selector: (state) => state.emailController, builder: (context, emailController) { - return CustomTextFormField( - controller: emailController, - textInputAction: TextInputAction.done); + return CustomTextFormField(controller: emailController, textInputAction: TextInputAction.done); }), SizedBox(height: 22.v), Text("username".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), - BlocSelector( + BlocSelector( selector: (state) => state.nameController, builder: (context, nameController) { - return CustomTextFormField( - controller: nameController, - textInputAction: TextInputAction.done); + return CustomTextFormField(controller: nameController, textInputAction: TextInputAction.done); }), SizedBox(height: 19.v), Text("password".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 5.v), - BlocSelector( + BlocSelector( selector: (state) => state.passwordController, builder: (context, passwordController) { return CustomTextFormField( @@ -89,25 +75,18 @@ class CredentialsScreen extends StatelessWidget { ); }), SizedBox(height: 21.v), - Text("password_confirmation".tr, - style: theme.textTheme.bodyLarge), + Text("password_confirmation".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), - BlocSelector( + BlocSelector( selector: (state) => state.passwordConfirmationController, builder: (context, passwordConfirmationController) { - return CustomTextFormField( - obscureText: true, - controller: passwordConfirmationController, - textInputAction: TextInputAction.done); + return CustomTextFormField(obscureText: true, controller: passwordConfirmationController, textInputAction: TextInputAction.done); }), Spacer(), - BlocBuilder( - builder: (context, state) { + BlocBuilder(builder: (context, state) { return NextStepButton( text: "continue".tr.toUpperCase(), - margin: - EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), + margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, onPressed: onTapContinue(state, context)); }), @@ -116,19 +95,15 @@ class CredentialsScreen extends StatelessWidget { onTapContinue(CredentialsState state, BuildContext context) { return () { - List errors = validateFields( - state.emailController!.text, - state.nameController!.text, - state.passwordController!.text, - state.passwordConfirmationController!.text); + List errors = + validateFields(state.emailController!.text, state.nameController!.text, state.passwordController!.text, state.passwordConfirmationController!.text); if (errors.isEmpty) { - UserRegistrationSheet sheet = - state.credentialsModelObj!.userRegistrationSheet; + UserRegistrationSheet sheet = state.credentialsModelObj!.userRegistrationSheet; sheet.email = state.emailController!.text; sheet.name = state.nameController!.text; sheet.password = state.passwordController!.text; sheet.passwordConfirmation = state.passwordConfirmationController!.text; - GoRouter.of(context).goNamed('nameScreen'); + GoRouter.of(context).goNamed('nameScreen', extra: sheet); } else { String errorMessage = ''; @@ -161,14 +136,10 @@ class CredentialsScreen extends StatelessWidget { /// 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 name, String password, String passwordConfirmation) { + List validateFields(String email, String name, String password, String passwordConfirmation) { List errors = []; if (!isEmail(email)) { diff --git a/lib/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart b/lib/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart index 7f86075..5f68a3d 100644 --- a/lib/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart +++ b/lib/presentation/registration/date_of_birth_screen/date_of_birth_screen.dart @@ -13,12 +13,17 @@ import 'package:flutter/material.dart'; class DateOfBirthScreen extends StatefulWidget { const DateOfBirthScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( - create: (context) => - DateOfBirthBloc(DateOfBirthState(dateOfBirthModelObj: DateOfBirthModel(userRegistrationSheet: sheet)))..add(DateOfBirthInitialEvent()), - child: DateOfBirthScreen()); + create: (context) => DateOfBirthBloc( + DateOfBirthState( + dateOfBirthModelObj: DateOfBirthModel( + userRegistrationSheet: sheet, + ), + ), + )..add(DateOfBirthInitialEvent()), + child: DateOfBirthScreen(), + ); } @override @@ -32,37 +37,36 @@ class _DateOfBirthScreenState extends State { Widget build(BuildContext context) { mediaQueryData = MediaQuery.of(context); return BlocBuilder(builder: (context, state) { - return SafeArea( - child: Scaffold( - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column(children: [ - 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.24, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), - SizedBox(height: 38.v), - Text("date_of_birth".tr, style: theme.textTheme.headlineSmall), - Spacer(flex: 39), - _buildDateInput(context), - Spacer(flex: 60), - 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: onTapContinue(state, context)); - }), - ])))); + return Scaffold( + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column(children: [ + 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.24, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 38.v), + Text("date_of_birth".tr, style: theme.textTheme.headlineSmall), + Spacer(flex: 39), + _buildDateInput(context), + Spacer(flex: 60), + 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: onTapContinue(state, context)); + }), + ]))); }); } @@ -116,7 +120,7 @@ class _DateOfBirthScreenState extends State { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } /// Displays a date picker dialog to update the selected date diff --git a/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart b/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart index a0c35dd..94771a1 100644 --- a/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart +++ b/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart @@ -14,8 +14,7 @@ import 'package:flutter/material.dart'; class FavoriteFoodsScreen extends StatefulWidget { const FavoriteFoodsScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => FavoriteFoodsBloc(FavoriteFoodsState(favoriteFoodsModelObj: FavoriteFoodsModel(userRegistrationSheet: sheet)))..add(FavoriteFoodsInitialEvent()), @@ -29,52 +28,50 @@ class FavoriteFoodsScreen extends StatefulWidget { class _FavoriteFoodsScreenState extends State { @override Widget build(BuildContext context) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column(children: [ - SizedBox(height: 7.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.90, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), - SizedBox(height: 19.v), - Container( - width: 327.h, - margin: EdgeInsets.only(left: 8.h, right: 7.h), - child: Text("favorite_unfavorite_foods".tr, - maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: theme.textTheme.headlineSmall)), - SizedBox(height: 13.v), - _buildTextFormFieldFav(context), - SizedBox(height: 12.v), - _buildTextFormFieldUnfav(context), - Spacer(), - BlocBuilder(builder: (context, state) { - return NextStepButton( - text: "continue".tr.toUpperCase(), - margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 40.v), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapContinue(state, context)); - }), - BlocBuilder(builder: (context, state) { - return GestureDetector( - onTap: onTapSkip(state, context), - child: Text("skip".tr, style: theme.textTheme.bodyLarge), - ); - }), - ])))); + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column(children: [ + SizedBox(height: 7.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.90, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 19.v), + Container( + width: 327.h, + margin: EdgeInsets.only(left: 8.h, right: 7.h), + child: Text("favorite_unfavorite_foods".tr, + maxLines: 2, overflow: TextOverflow.ellipsis, textAlign: TextAlign.center, style: theme.textTheme.headlineSmall)), + SizedBox(height: 13.v), + _buildTextFormFieldFav(context), + SizedBox(height: 12.v), + _buildTextFormFieldUnfav(context), + Spacer(), + BlocBuilder(builder: (context, state) { + return NextStepButton( + text: "continue".tr.toUpperCase(), + margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 40.v), + buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + onPressed: onTapContinue(state, context)); + }), + BlocBuilder(builder: (context, state) { + return GestureDetector( + onTap: onTapSkip(state, context), + child: Text("skip".tr, style: theme.textTheme.bodyLarge), + ); + }), + ]))); } onTapSkip(FavoriteFoodsState state, BuildContext context) { @@ -138,7 +135,7 @@ class _FavoriteFoodsScreenState extends State { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } /// Navigates to the scheduleScreen when the action is triggered. diff --git a/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart b/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart index a9217ec..66f98d2 100644 --- a/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart +++ b/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart @@ -14,8 +14,7 @@ import 'package:flutter/material.dart'; class FavoriteSportsScreen extends StatefulWidget { const FavoriteSportsScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => FavoriteSportsBloc(FavoriteSportsState(favoriteSportsModelObj: FavoriteSportsModel(userRegistrationSheet: sheet))) ..add(FavoriteSportsInitialEvent()), @@ -29,46 +28,44 @@ class FavoriteSportsScreen extends StatefulWidget { class _FavoriteSportsScreenState extends State { @override Widget build(BuildContext context) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v), - child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ - 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.83, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), - SizedBox(height: 38.v), - Text("your_favorite_sports".tr, style: theme.textTheme.headlineSmall), - Spacer(flex: 32), - _buildTextFormFieldSection(context), - Spacer(flex: 67), - 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: onTapContinue(state, context)); - }), - BlocBuilder(builder: (context, state) { - return GestureDetector( - onTap: onTapSkip(state, context), - child: Text("skip".tr, style: theme.textTheme.bodyLarge), - ); - }), - ])))); + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 5.v), + child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ + 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.83, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 38.v), + Text("your_favorite_sports".tr, style: theme.textTheme.headlineSmall), + Spacer(flex: 32), + _buildTextFormFieldSection(context), + Spacer(flex: 67), + 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: onTapContinue(state, context)); + }), + BlocBuilder(builder: (context, state) { + return GestureDetector( + onTap: onTapSkip(state, context), + child: Text("skip".tr, style: theme.textTheme.bodyLarge), + ); + }), + ]))); } onTapSkip(FavoriteSportsState state, BuildContext context) { @@ -120,6 +117,6 @@ class _FavoriteSportsScreenState extends State { } onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } diff --git a/lib/presentation/registration/gender_screen/gender_screen.dart b/lib/presentation/registration/gender_screen/gender_screen.dart index 4e90621..68909d7 100644 --- a/lib/presentation/registration/gender_screen/gender_screen.dart +++ b/lib/presentation/registration/gender_screen/gender_screen.dart @@ -13,8 +13,7 @@ import 'package:flutter/material.dart'; class GenderScreen extends StatefulWidget { const GenderScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => GenderBloc( GenderState( @@ -33,58 +32,57 @@ class _GenderScreenState extends State { Widget build(BuildContext context) { mediaQueryData = MediaQuery.of(context); return BlocBuilder(builder: (context, state) { - return SafeArea( - child: Scaffold( - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column(children: [ - SizedBox(height: 7.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.16, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), - SizedBox(height: 36.v), - Text("your_gender".tr, style: theme.textTheme.headlineSmall), - RadioListTile( - title: Text('Мужской'), - value: 'male', - groupValue: state.selectedRadioValue, - onChanged: onMale(context), - secondary: Image.asset( - 'assets/images/img_male.png', - width: 40, - height: 40, - ), - ), - RadioListTile( - title: Text('Женский'), - value: 'female', - groupValue: state.selectedRadioValue, - onChanged: onFemale(context), - secondary: Image.asset( - 'assets/images/img_female.png', - width: 40, - height: 40, - ), - ), - Spacer(flex: 66), - 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: onTapNext(state, context)); - }), - ])))); + return Scaffold( + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column(children: [ + SizedBox(height: 7.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.16, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 36.v), + Text("your_gender".tr, style: theme.textTheme.headlineSmall), + RadioListTile( + title: Text('Мужской'), + value: 'male', + groupValue: state.selectedRadioValue, + onChanged: onMale(context), + secondary: Image.asset( + 'assets/images/img_male.png', + width: 40, + height: 40, + ), + ), + RadioListTile( + title: Text('Женский'), + value: 'female', + groupValue: state.selectedRadioValue, + onChanged: onFemale(context), + secondary: Image.asset( + 'assets/images/img_female.png', + width: 40, + height: 40, + ), + ), + Spacer(flex: 66), + 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: onTapNext(state, context)); + }), + ]))); }); } @@ -111,20 +109,23 @@ class _GenderScreenState extends State { /// Section Widget _buildAppBar(BuildContext context) { return CustomAppBar( - leadingWidth: 29.h, - leading: AppbarLeadingImage(imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), onTap: onTapBack()), - centerTitle: true, - title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); + leadingWidth: 29.h, + leading: AppbarLeadingImage(imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), onTap: onTapBack()), + centerTitle: true, + title: AppbarTitleImage( + imagePath: ImageConstant.imgLogoEatvio, + ), + ); } Function onTapBack() { return () { - GoRouter.of(context).goNamed('dateOfBirthScreen'); + GoRouter.of(context).pop(); }; } /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } diff --git a/lib/presentation/registration/height_screen/height_screen.dart b/lib/presentation/registration/height_screen/height_screen.dart index 243fe89..071285f 100644 --- a/lib/presentation/registration/height_screen/height_screen.dart +++ b/lib/presentation/registration/height_screen/height_screen.dart @@ -15,8 +15,7 @@ import 'package:flutter/material.dart'; class HeightScreen extends StatelessWidget { const HeightScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => HeightBloc(HeightState(heightModelObj: HeightModel(userRegistrationSheet: sheet)))..add(HeightInitialEvent()), child: HeightScreen()); @@ -25,84 +24,82 @@ class HeightScreen extends StatelessWidget { @override Widget build(BuildContext context) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - SizedBox(height: 7.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, - ), + return Scaffold( + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column( + children: [ + SizedBox(height: 7.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.55, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400, - ), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.h), + child: LinearProgressIndicator( + value: 0.55, + backgroundColor: theme.colorScheme.onPrimary, + valueColor: AlwaysStoppedAnimation( + appTheme.blueA400, ), ), ), - SizedBox(height: 39.v), - Column( - children: [ - Text( - "height_measurements".tr, - style: theme.textTheme.headlineSmall, - ), - SizedBox(height: 174.v), - Column( - children: [ - Text( - "your_height".tr, - style: theme.textTheme.bodyLarge, - ), - SizedBox(height: 4.v), - BlocBuilder(builder: (context, state) { - return CustomTextFormField( - width: 150.h, - textInputAction: TextInputAction.done, - controller: state.heightController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - ); - }) - ], - ), - ], - ), - Spacer(), - BlocBuilder( - builder: (context, state) { - return NextStepButton( - text: "continue".tr.toUpperCase(), - margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 50.v, + ), + SizedBox(height: 39.v), + Column( + children: [ + Text( + "height_measurements".tr, + style: theme.textTheme.headlineSmall, + ), + SizedBox(height: 174.v), + Column( + children: [ + Text( + "your_height".tr, + style: theme.textTheme.bodyLarge, ), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapNext(state, context), - ); - }, - ), - ], - ), + SizedBox(height: 4.v), + BlocBuilder(builder: (context, state) { + return CustomTextFormField( + width: 150.h, + textInputAction: TextInputAction.done, + controller: state.heightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + ); + }) + ], + ), + ], + ), + Spacer(), + 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: onTapNext(state, context), + ); + }, + ), + ], ), ), ); @@ -133,6 +130,6 @@ class HeightScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } diff --git a/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart b/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart index a3cc105..bfd4085 100644 --- a/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart +++ b/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart @@ -128,6 +128,6 @@ class _MedicineIntakeScreenState extends State { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } } diff --git a/lib/presentation/registration/name_screen/name_screen.dart b/lib/presentation/registration/name_screen/name_screen.dart index 6501c00..e1f0327 100644 --- a/lib/presentation/registration/name_screen/name_screen.dart +++ b/lib/presentation/registration/name_screen/name_screen.dart @@ -14,10 +14,8 @@ import 'package:flutter/material.dart'; class NameScreen extends StatelessWidget { const NameScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = - ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => NameBloc( NameState( @@ -30,65 +28,55 @@ class NameScreen extends StatelessWidget { @override Widget build(BuildContext context) { mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - resizeToAvoidBottomInset: false, - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column(children: [ - SizedBox(height: 7.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.1, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400)))), - SizedBox(height: 39.v), - Text("what_is_your_name".tr, - style: theme.textTheme.headlineSmall), - SizedBox(height: 93.v), - Text("first_name".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.firstNameController, - builder: (context, firstNameController) { - return CustomTextFormField( - controller: firstNameController, - textInputAction: TextInputAction.done); - }), - SizedBox(height: 19.v), - Text("last_name".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - BlocSelector( - selector: (state) => state.lastNameController, - builder: (context, lastNameController) { - return CustomTextFormField( - controller: lastNameController, - ); - }), - Spacer(), - 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: () => _onTapNext( - context, state), // Assign callback function here + return Scaffold( + resizeToAvoidBottomInset: false, + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column(children: [ + SizedBox(height: 7.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.1, backgroundColor: theme.colorScheme.onPrimary, valueColor: AlwaysStoppedAnimation(appTheme.blueA400)))), + SizedBox(height: 39.v), + Text("what_is_your_name".tr, style: theme.textTheme.headlineSmall), + SizedBox(height: 93.v), + Text("first_name".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 3.v), + BlocSelector( + selector: (state) => state.firstNameController, + builder: (context, firstNameController) { + return CustomTextFormField(controller: firstNameController, textInputAction: TextInputAction.done); + }), + SizedBox(height: 19.v), + Text("last_name".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 5.v), + BlocSelector( + selector: (state) => state.lastNameController, + builder: (context, lastNameController) { + return CustomTextFormField( + controller: lastNameController, ); }), - ])))); + Spacer(), + 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: () => _onTapNext(context, state), // Assign callback function here + ); + }), + ]))); } /// Section Widget @@ -96,22 +84,19 @@ class NameScreen extends StatelessWidget { return CustomAppBar( leadingWidth: 29.h, leading: AppbarLeadingImage( - imagePath: ImageConstant.imgArrowLeft, - margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), - onTap: () => onTapArrowLeft(context)), + imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v), onTap: () => onTapArrowLeft(context)), centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } _onTapNext(BuildContext context, NameState state) { if (state.firstNameController != null && state.lastNameController != null) { - List errors = validateFields( - state.firstNameController!.text, state.lastNameController!.text); + List errors = validateFields(state.firstNameController!.text, state.lastNameController!.text); if (errors.isEmpty) { UserRegistrationSheet sheet = state.nameModelObj!.userRegistrationSheet; diff --git a/lib/presentation/registration/weight_screen/weight_screen.dart b/lib/presentation/registration/weight_screen/weight_screen.dart index 28b0913..7bf28f1 100644 --- a/lib/presentation/registration/weight_screen/weight_screen.dart +++ b/lib/presentation/registration/weight_screen/weight_screen.dart @@ -15,8 +15,7 @@ import 'package:flutter/material.dart'; class WeightScreen extends StatelessWidget { const WeightScreen({Key? key}) : super(key: key); - static Widget builder(BuildContext context) { - final sheet = ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; + static Widget builder(BuildContext context, sheet) { return BlocProvider( create: (context) => WeightBloc(WeightState(weightModelObj: WeightModel(userRegistrationSheet: sheet)))..add(WeightInitialEvent()), child: WeightScreen()); @@ -24,85 +23,82 @@ class WeightScreen extends StatelessWidget { @override Widget build(BuildContext context) { - mediaQueryData = MediaQuery.of(context); - return SafeArea( - child: Scaffold( - appBar: _buildAppBar(context), - body: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - SizedBox(height: 7.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, - ), + return Scaffold( + appBar: _buildAppBar(context), + body: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column( + children: [ + SizedBox(height: 7.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.55, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400, - ), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(8.h), + child: LinearProgressIndicator( + value: 0.55, + backgroundColor: theme.colorScheme.onPrimary, + valueColor: AlwaysStoppedAnimation( + appTheme.blueA400, ), ), ), - SizedBox(height: 39.v), - Column( - children: [ - Text( - "weight_measurements".tr, - style: theme.textTheme.headlineSmall, - ), - SizedBox(height: 174.v), - Column( - children: [ - Text( - "your_weight".tr, - style: theme.textTheme.bodyLarge, - ), - SizedBox(height: 4.v), - BlocBuilder(builder: (context, state) { - return CustomTextFormField( - width: 150.h, - textInputAction: TextInputAction.done, - controller: state.weightController, - keyboardType: TextInputType.number, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - ], - ); - }) - ], - ), - ], - ), - Spacer(), - BlocBuilder( - builder: (context, state) { - return NextStepButton( - text: "continue".tr.toUpperCase(), - margin: EdgeInsets.only( - left: 16.h, - right: 16.h, - bottom: 50.v, + ), + SizedBox(height: 39.v), + Column( + children: [ + Text( + "weight_measurements".tr, + style: theme.textTheme.headlineSmall, + ), + SizedBox(height: 174.v), + Column( + children: [ + Text( + "your_weight".tr, + style: theme.textTheme.bodyLarge, ), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: onTapNext(state, context), - ); - }, - ), - ], - ), + SizedBox(height: 4.v), + BlocBuilder(builder: (context, state) { + return CustomTextFormField( + width: 150.h, + textInputAction: TextInputAction.done, + controller: state.weightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + ); + }) + ], + ), + ], + ), + Spacer(), + 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: onTapNext(state, context), + ); + }, + ), + ], ), ), ); @@ -133,6 +129,6 @@ class WeightScreen extends StatelessWidget { /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); + GoRouter.of(context).pop(); } }