From ee37f02d78e1aa0612e0e769762b9cbdca19e62b Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Mon, 15 Jul 2024 12:45:52 +0300 Subject: [PATCH] feature(registration): refactor i5 --- .../registration_cubit.dart | 14 +- .../pages/registration_screen.dart | 6 +- .../repositories/registration_repository.dart | 16 + .../services/registration_service.dart | 15 + .../services/registration_service.g.dart | 74 ++++ lib/locator_service.dart | 6 + .../additional_information_screen.dart | 146 ++------ .../allergies_screen/allergies_screen.dart | 92 ++--- .../bloc/blood_pressure_bloc.dart | 23 +- .../blood_pressure_screen.dart | 321 +++++++----------- .../favorite_foods_screen.dart | 127 ++----- .../favorite_sports_screen.dart | 93 ++--- .../height_screen/height_screen.dart | 52 ++- .../medicine_intake_screen.dart | 99 ++---- .../weight_screen/weight_screen.dart | 104 +++--- 15 files changed, 470 insertions(+), 718 deletions(-) create mode 100644 lib/features/registration/repositories/registration_repository.dart create mode 100644 lib/features/registration/services/registration_service.dart create mode 100644 lib/features/registration/services/registration_service.g.dart diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart index 5e59454f..e882eadd 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -1,10 +1,22 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart'; +import 'package:eatvio_app/features/registration/repositories/registration_repository.dart'; import 'package:eatvio_app/presentation/registration/language_select_screen/models/language_select_model.dart'; class RegistrationCubit extends Cubit { - RegistrationCubit() : super(RegistrationState(sheet: LanguageSelectModel().userRegistrationSheet)); + final RegistrationRepository registrationRepository; + + RegistrationCubit({required this.registrationRepository}) : super(RegistrationState(sheet: LanguageSelectModel().userRegistrationSheet)); updateSheet(UserRegistrationSheet sheet) => emit(RegistrationState(sheet: sheet)); + + tryRegistration() async { + try { + final response = await registrationRepository.tryRegister(state.sheet); + print(response); + } catch (e) { + print(e); + } + } } diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index 3f3da557..074d67f8 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -1,6 +1,7 @@ import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart'; +import 'package:eatvio_app/locator_service.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'; @@ -62,7 +63,7 @@ class _RegistrationScreenState extends State { @override Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => RegistrationCubit(), + create: (BuildContext context) => sl(), child: BlocBuilder( builder: (BuildContext context, RegistrationState state) { return PopScope( @@ -275,6 +276,9 @@ class _RegistrationScreenState extends State { ); return false; } + case 15: + context.read().tryRegistration(); + return true; default: return true; } diff --git a/lib/features/registration/repositories/registration_repository.dart b/lib/features/registration/repositories/registration_repository.dart new file mode 100644 index 00000000..bbaf43f3 --- /dev/null +++ b/lib/features/registration/repositories/registration_repository.dart @@ -0,0 +1,16 @@ +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/services/registration_service.dart'; + +class RegistrationRepository { + final RegistrationService registrationService; + + RegistrationRepository({required this.registrationService}); + + tryRegister(UserRegistrationSheet sheet) async { + try { + return await registrationService.register(sheet: sheet); + } catch (e) { + rethrow; + } + } +} \ No newline at end of file diff --git a/lib/features/registration/services/registration_service.dart b/lib/features/registration/services/registration_service.dart new file mode 100644 index 00000000..f7c41ecb --- /dev/null +++ b/lib/features/registration/services/registration_service.dart @@ -0,0 +1,15 @@ +import 'package:dio/dio.dart'; +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:retrofit/retrofit.dart'; + +part 'registration_service.g.dart'; + +@RestApi() +abstract class RegistrationService { + factory RegistrationService(Dio dio, {String baseUrl}) = _RegistrationService; + + @POST('/register') + Future register({ + @Body() required UserRegistrationSheet sheet, + }); +} diff --git a/lib/features/registration/services/registration_service.g.dart b/lib/features/registration/services/registration_service.g.dart new file mode 100644 index 00000000..44140792 --- /dev/null +++ b/lib/features/registration/services/registration_service.g.dart @@ -0,0 +1,74 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'registration_service.dart'; + +// ************************************************************************** +// RetrofitGenerator +// ************************************************************************** + +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element + +class _RegistrationService implements RegistrationService { + _RegistrationService( + this._dio, { + this.baseUrl, + }); + + final Dio _dio; + + String? baseUrl; + + @override + Future register({required UserRegistrationSheet sheet}) async { + final _extra = {}; + final queryParameters = {}; + final _headers = {}; + final _data = sheet; + await _dio.fetch(_setStreamType(Options( + method: 'POST', + headers: _headers, + extra: _extra, + ) + .compose( + _dio.options, + '/register', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + )))); + } + + RequestOptions _setStreamType(RequestOptions requestOptions) { + if (T != dynamic && + !(requestOptions.responseType == ResponseType.bytes || + requestOptions.responseType == ResponseType.stream)) { + if (T == String) { + requestOptions.responseType = ResponseType.plain; + } else { + requestOptions.responseType = ResponseType.json; + } + } + return requestOptions; + } + + String _combineBaseUrls( + String dioBaseUrl, + String? baseUrl, + ) { + if (baseUrl == null || baseUrl.trim().isEmpty) { + return dioBaseUrl; + } + + final url = Uri.parse(baseUrl); + + if (url.isAbsolute) { + return url.toString(); + } + + return Uri.parse(dioBaseUrl).resolveUri(url).toString(); + } +} diff --git a/lib/locator_service.dart b/lib/locator_service.dart index dfd61987..dc09164c 100644 --- a/lib/locator_service.dart +++ b/lib/locator_service.dart @@ -11,6 +11,9 @@ import 'package:eatvio_app/features/chat/services/chat_service.dart'; import 'package:eatvio_app/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart'; import 'package:eatvio_app/features/feed/repositories/feed_repository.dart'; import 'package:eatvio_app/features/feed/services/feed_service.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; +import 'package:eatvio_app/features/registration/repositories/registration_repository.dart'; +import 'package:eatvio_app/features/registration/services/registration_service.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:get_it/get_it.dart'; @@ -22,6 +25,7 @@ Future init() async { sl.registerLazySingleton(() => NewMessagesCubit()); sl.registerLazySingleton(() => NotificationsCubit()); + sl.registerFactory(() => RegistrationCubit(registrationRepository: sl())); sl.registerFactory(() => ChatRoomCubit(chatRepository: sl(), initializationCubit: sl())); sl.registerFactory(() => FeedCubit(feedRepository: sl())); sl.registerFactory(() => BlogPostCubit(blogPostRepository: sl())); @@ -30,11 +34,13 @@ Future init() async { sl.registerLazySingleton(() => ChatRepository(chatService: sl())); sl.registerLazySingleton(() => FeedRepository(feedService: sl())); sl.registerLazySingleton(() => BlogPostRepository(blogPostService: sl())); + sl.registerLazySingleton(() => RegistrationRepository(registrationService: sl())); // Services sl.registerLazySingleton(() => ChatService(sl())); sl.registerLazySingleton(() => FeedService(sl())); sl.registerLazySingleton(() => BlogPostService(sl())); + sl.registerLazySingleton(() => RegistrationService(sl())); // External sl.registerLazySingleton( 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 32fbd61b..ec4578cc 100644 --- a/lib/presentation/registration/additional_information_screen/additional_information_screen.dart +++ b/lib/presentation/registration/additional_information_screen/additional_information_screen.dart @@ -1,14 +1,8 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/additional_information_bloc.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; -import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:flutter/material.dart'; -import 'dart:convert'; -import 'package:hive/hive.dart'; -import 'package:http/http.dart' as http; class AdditionalInformationScreen extends StatefulWidget { final UserRegistrationSheet sheet; @@ -20,6 +14,14 @@ class AdditionalInformationScreen extends StatefulWidget { } class _AdditionalInformationScreenState extends State { + final editTextController = TextEditingController(); + + @override + void initState() { + super.initState(); + editTextController.text = widget.sheet.additionalInfo; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -29,117 +31,31 @@ class _AdditionalInformationScreenState extends State( - // builder: (context, state) { - // return NextStepButton( - // text: "finish".tr.toUpperCase(), - // margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - // buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - // onPressed: onTapFinish(state, context), - // ); - // }, - // ), + Container( + 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, + ), + ), + SizedBox(height: 10.v), + CustomTextFormField( + controller: editTextController, + hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", + textInputAction: TextInputAction.done, + maxLines: 8, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(additionalInfo: newValue)); + }, + ), ], ), ), ); } - - onTapFinish(AdditionalInformationState state, BuildContext context) { - return () async { - 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, - ); - - var res = await jsonDecode(response.body); - if (response.statusCode == 200) { - final box = await Hive.openBox('token'); - final token = res['token']; - box.put('token', token); - GoRouter.of(context).goNamed('myProfileScreen'); - } else { - showErrorMessage(context, res['message']); - } - }; - } - - onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Section Widget - _buildTextFormField(BuildContext context) { - return SizedBox( - width: 343.h, - child: Stack( - alignment: Alignment.center, - children: [ - Align( - alignment: Alignment.center, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - 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, - ), - ), - SizedBox(height: 10.v), - BlocSelector( - selector: (state) => state.editTextController, - builder: (context, editTextController) { - return CustomTextFormField( - controller: editTextController, - hintText: "У меня крепкое здоровье, но последнее время часто утомляюсь, однако, это мне не мешает радоваться жизни", - textInputAction: TextInputAction.done, - maxLines: 8, - ); - }, - ), - ], - ), - ), - ], - ), - ); - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - GoRouter.of(context).pop(); - } - - /// Displays an alert dialog when the action is triggered. - /// The dialog box contains a title and a message with the `Теперь вы можете пользоваться полным функционалом приложения` - showErrorMessage(BuildContext context, String text) { - showDialog( - context: context, - builder: (_) => AlertDialog( - title: const Text('Ошибка'), - content: Text(text), - actions: [TextButton(onPressed: onTapOk(context), child: const Text('Ok'))], - ), - ); - } - - onTapOk(BuildContext context) { - return () { - Navigator.pop(context); - }; - } } diff --git a/lib/presentation/registration/allergies_screen/allergies_screen.dart b/lib/presentation/registration/allergies_screen/allergies_screen.dart index 56702d97..3261c92f 100644 --- a/lib/presentation/registration/allergies_screen/allergies_screen.dart +++ b/lib/presentation/registration/allergies_screen/allergies_screen.dart @@ -1,10 +1,6 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/allergies_bloc.dart'; -// ignore: unused_import -import 'models/allergies_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; @@ -18,6 +14,14 @@ class AllergiesScreen extends StatefulWidget { } class _AllergiesScreenState extends State { + final enterInformationController = TextEditingController(); + + @override + void initState() { + super.initState(); + enterInformationController.text = widget.sheet.aboutAllergy; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -29,75 +33,21 @@ class _AllergiesScreenState extends State { children: [ Text("allergies_presence".tr, style: theme.textTheme.headlineSmall), SizedBox(height: 22.v), - _buildTextFormField(context), - // 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), - // ); - // }, - // ), + Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), + SizedBox(height: 2.v), + CustomTextFormField( + controller: enterInformationController, + hintText: "enter_information".tr, + textInputAction: TextInputAction.done, + maxLines: 8, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutAllergy: newValue)); + }, + ), ], ), ), ); } - - onTapSkip(AllergiesState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet; - GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet); - }; - } - - onTapContinue(AllergiesState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet; - // sheet.aboutAllergy = state.enterInformationController!.text; - GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet); - }; - } - - onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Section Widget - _buildTextFormField(BuildContext context) { - return Column( - children: [ - Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.enterInformationController, - builder: (context, enterInformationController) { - return CustomTextFormField( - controller: enterInformationController, - hintText: "enter_information".tr, - textInputAction: TextInputAction.done, - maxLines: 8, - ); - }, - ), - ], - ); - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - GoRouter.of(context).pop(); - } } diff --git a/lib/presentation/registration/blood_pressure_screen/bloc/blood_pressure_bloc.dart b/lib/presentation/registration/blood_pressure_screen/bloc/blood_pressure_bloc.dart index 2fda1b59..64e3e019 100644 --- a/lib/presentation/registration/blood_pressure_screen/bloc/blood_pressure_bloc.dart +++ b/lib/presentation/registration/blood_pressure_screen/bloc/blood_pressure_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/registration/blood_pressure_screen/models/blood_pressure_model.dart'; + part 'blood_pressure_event.dart'; + part 'blood_pressure_state.dart'; /// A bloc that manages the state of a BloodPressure according to the event that is dispatched to it. @@ -43,7 +45,11 @@ class BloodPressureBloc extends Bloc { id: 1, title: "Да", ), - SelectionPopupModel(id: 2, title: "Нет", isSelected: true), + SelectionPopupModel( + id: 2, + title: "Нет", + isSelected: true, + ), ]; } @@ -51,11 +57,16 @@ class BloodPressureBloc extends Bloc { BloodPressureInitialEvent event, Emitter emit, ) async { - emit(state.copyWith( + emit( + state.copyWith( upPressureController: TextEditingController(), - downPressureController: TextEditingController(),),); - emit(state.copyWith( - bloodPressureModelObj: state.bloodPressureModelObj - ?.copyWith(dropdownItemList: fillDropdownItemList()),),); + downPressureController: TextEditingController(), + ), + ); + emit( + state.copyWith( + bloodPressureModelObj: state.bloodPressureModelObj?.copyWith(dropdownItemList: fillDropdownItemList()), + ), + ); } } 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 d5c24688..35669330 100644 --- a/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart +++ b/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart @@ -1,9 +1,5 @@ -import 'package:eatvio_app/app_router.dart'; -import 'package:go_router/go_router.dart'; - -import 'bloc/blood_pressure_bloc.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:flutter/services.dart'; -import 'models/blood_pressure_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; @@ -20,210 +16,147 @@ class BloodPressureScreen extends StatefulWidget { } class _BloodPressureScreenState extends State { + final List selectionPopupList = [ + SelectionPopupModel( + id: 1, + title: "Да", + ), + SelectionPopupModel( + id: 2, + title: "Нет", + ), + ]; + + late SelectionPopupModel selectedPopupHypo; + late SelectionPopupModel selectedPopupHyper; + final digitsOnly = FilteringTextInputFormatter.digitsOnly; + final upPressureController = TextEditingController(); + final downPressureController = TextEditingController(); + + @override + void initState() { + super.initState(); + selectedPopupHypo = selectionPopupList[1]; + selectedPopupHyper = selectionPopupList[1]; + upPressureController.text = widget.sheet.bloodPressureUp; + downPressureController.text = widget.sheet.bloodPressureDown; + if (widget.sheet.hasHyper.isNotEmpty) { + widget.sheet.hasHyper == 'Да' ? selectedPopupHyper = selectionPopupList[0] : selectedPopupHyper = selectionPopupList[1]; + } + if (widget.sheet.hasHypo.isNotEmpty) { + widget.sheet.hasHypo == 'Да' ? selectedPopupHypo = selectionPopupList[0] : selectedPopupHypo = selectionPopupList[1]; + } + } @override Widget build(BuildContext context) { return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80), child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 9.v), - child: Column( - children: [ - SizedBox( - width: 224.h, - child: Text( - "your_blood_pressure".tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.center, - style: theme.textTheme.headlineSmall, - ), + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 12.h, vertical: 9.v), + child: Column( + children: [ + 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("up_pressure".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: upPressureController, + hintText: "90".tr, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureUp: newValue)); + }, + ), + ], ), - 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: 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), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: downPressureController, + hintText: "90".tr, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(bloodPressureDown: newValue)); + }, + ), + ], ), - 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_hypotension_tendency".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + Padding( + padding: EdgeInsets.symmetric(horizontal: 4.h), + child: 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: selectionPopupList, + value: selectedPopupHypo, + onChanged: (newPopup) { + setState(() { + selectedPopupHypo = newPopup; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHypo: selectedPopupHypo.title)); + }); + }, ), - 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), - ); - }, + ), + 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: 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: selectionPopupList, + value: selectedPopupHyper, + onChanged: (newPopup) { + setState(() { + selectedPopupHyper = newPopup; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hasHyper: selectedPopupHyper.title)); + }); + }, ), - // 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) { - return () { - UserRegistrationSheet sheet = state.bloodPressureModelObj!.userRegistrationSheet; - AppRouter.navigatorKey.currentContext?.goNamed('allergiesScreen', extra: sheet); - }; - } - - onTapContinue(BloodPressureState state, BuildContext context) { - return () { - List errors = validateFields(state.upPressureController!.text, state.downPressureController!.text); - if (errors.isEmpty) { - UserRegistrationSheet sheet = state.bloodPressureModelObj!.userRegistrationSheet; - // sheet.bloodPressureUp = state.upPressureController!.text; - // sheet.bloodPressureDown = state.downPressureController!.text; - AppRouter.navigatorKey.currentContext?.goNamed('allergiesScreen', extra: sheet); - } else { - String errorMessage = ''; - - for (var error in errors) { - errorMessage += error + '\n\n'; - } - - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text('Ошибка'), - content: Text(errorMessage), - actions: [ - TextButton( - onPressed: onTapOK(context), - child: Text('OK'), - ), - ], - ), - ); - } - }; - } - - onTapOK(BuildContext context) { - return () { - Navigator.pop(context); - }; - } - - onChangeHypo(BuildContext context) { - return (value) { - context.read().add(ChangeHyperDropDownEvent(value: value)); - }; - } - - onChangeHyper(BuildContext context) { - return (value) { - context.read().add(ChangeHypoDownEvent(value: value)); - }; - } - - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - GoRouter.of(context).pop(); - } - - List validateFields( - String bloodPressureUp, - String bloodPressureDown, - ) { - List errors = []; - - if (bloodPressureUp.isEmpty | bloodPressureDown.isEmpty) { - errors.add('pressure_empty'.tr); - } - - if (![bloodPressureUp, bloodPressureDown].every((pressure) => int.tryParse(pressure) != null)) { - errors.add('pressure_is_not_a_number'.tr); - } - - return errors; - } } 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 b4f54d9b..b26f0c24 100644 --- a/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart +++ b/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart @@ -1,6 +1,4 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/favorite_foods_bloc.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; @@ -16,6 +14,16 @@ class FavoriteFoodsScreen extends StatefulWidget { } class _FavoriteFoodsScreenState extends State { + final favoriteFoodsController = TextEditingController(); + final unFavoriteFoodsController = TextEditingController(); + + @override + void initState() { + super.initState(); + favoriteFoodsController.text = widget.sheet.favoriteFoods; + unFavoriteFoodsController.text = widget.sheet.unfavoriteFoods; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -37,100 +45,33 @@ class _FavoriteFoodsScreenState extends State { ), ), SizedBox(height: 13.v), - _buildTextFormFieldFav(context), + Text("favorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), + SizedBox(height: 2.v), + CustomTextFormField( + controller: favoriteFoodsController, + hintText: "enter_information".tr, + maxLines: 7, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(favoriteFoods: newValue)); + }, + ), SizedBox(height: 12.v), - _buildTextFormFieldUnfav(context), - // 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), - // ); - // }, - // ), + Text("unfavorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), + SizedBox(height: 2.v), + CustomTextFormField( + controller: unFavoriteFoodsController, + hintText: "enter_information".tr, + textInputAction: TextInputAction.done, + maxLines: 7, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(unfavoriteFoods: newValue)); + }, + ), ], ), ), ); } - - onTapSkip(FavoriteFoodsState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.favoriteFoodsModelObj!.userRegistrationSheet; - GoRouter.of(context).goNamed('additionalInformationScreen', extra: sheet); - }; - } - - onTapContinue(FavoriteFoodsState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.favoriteFoodsModelObj!.userRegistrationSheet; - // sheet.favoriteFoods = state.favoriteFoodsController!.text; - // sheet.unfavoriteFoods = state.unfavoriteFoodsController!.text; - GoRouter.of(context).goNamed('additionalInformationScreen', extra: sheet); - }; - } - - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Section Widget - _buildTextFormFieldFav(BuildContext context) { - return Column( - children: [ - Text("favorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.favoriteFoodsController, - builder: (context, favoriteFoodsController) { - return CustomTextFormField(controller: favoriteFoodsController, hintText: "enter_information".tr, maxLines: 7); - }, - ), - ], - ); - } - - /// Section Widget - _buildTextFormFieldUnfav(BuildContext context) { - return Column( - children: [ - Text("unfavorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.unfavoriteFoodsController, - builder: (context, unfavoriteFoodsController) { - return CustomTextFormField( - controller: unfavoriteFoodsController, - hintText: "enter_information".tr, - textInputAction: TextInputAction.done, - maxLines: 7, - ); - }, - ), - ], - ); - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - GoRouter.of(context).pop(); - } - - /// Navigates to the scheduleScreen when the action is triggered. - navigateToAdditionalInformationScreen(BuildContext context) { - GoRouter.of(context).goNamed('additionalInformationScreen'); - } } 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 fd3a42fb..86c7d24e 100644 --- a/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart +++ b/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart @@ -1,8 +1,4 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/favorite_sports_bloc.dart'; -// ignore: unused_import -import 'models/favorite_sports_model.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; @@ -18,6 +14,14 @@ class FavoriteSportsScreen extends StatefulWidget { } class _FavoriteSportsScreenState extends State { + final enterInformationController = TextEditingController(); + + @override + void initState() { + super.initState(); + enterInformationController.text = widget.sheet.aboutSportHobbies; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -30,76 +34,21 @@ class _FavoriteSportsScreenState extends State { children: [ Text("your_favorite_sports".tr, style: theme.textTheme.headlineSmall), SizedBox(height: 22.v), - _buildTextFormFieldSection(context), - // 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), - // ); - // }, - // ), + Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), + SizedBox(height: 2.v), + CustomTextFormField( + controller: enterInformationController, + hintText: "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!", + textInputAction: TextInputAction.done, + maxLines: 8, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutSportHobbies: newValue)); + }, + ), ], ), ), ); } - - onTapSkip(FavoriteSportsState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.favoriteSportsModelObj!.userRegistrationSheet; - GoRouter.of(context).goNamed('favoriteFoodsScreen', extra: sheet); - }; - } - - onTapContinue(FavoriteSportsState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.favoriteSportsModelObj!.userRegistrationSheet; - // sheet.aboutSportHobbies = state.enterinformationController!.text; - GoRouter.of(context).goNamed('favoriteFoodsScreen', extra: sheet); - }; - } - - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Section Widget - _buildTextFormFieldSection(BuildContext context) { - return Column( - children: [ - Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.enterinformationController, - builder: (context, enterinformationController) { - return CustomTextFormField( - controller: enterinformationController, - hintText: - "Я занимаюсь плаванием , почти каждый вечер прогулки на свежем воздухе, пару раз в месяц играю в волейбол. Стараюсь не сидеть на месте!", - textInputAction: TextInputAction.done, - maxLines: 8, - ); - }, - ), - ], - ); - } - - onTapArrowLeft(BuildContext context) { - 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 a41dad92..9936418e 100644 --- a/lib/presentation/registration/height_screen/height_screen.dart +++ b/lib/presentation/registration/height_screen/height_screen.dart @@ -1,6 +1,4 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/height_bloc.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/services.dart'; @@ -17,6 +15,14 @@ class HeightScreen extends StatefulWidget { } class _HeightScreenState extends State { + final heightController = TextEditingController(); + + @override + void initState() { + super.initState(); + heightController.text = widget.sheet.height; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -38,17 +44,17 @@ class _HeightScreenState extends State { 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, - ], - ); + CustomTextFormField( + width: 150.h, + textInputAction: TextInputAction.done, + controller: heightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(height: newValue)); }, ), ], @@ -58,22 +64,4 @@ class _HeightScreenState extends State { ), ); } - - onTapNext(HeightState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.heightModelObj!.userRegistrationSheet; - GoRouter.of(context).goNamed('bloodPressureScreen', extra: sheet); - }; - } - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - 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 5ccc203e..1e6f4ff3 100644 --- a/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart +++ b/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart @@ -1,6 +1,4 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/medicine_intake_bloc.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; @@ -16,6 +14,14 @@ class MedicineIntakeScreen extends StatefulWidget { } class _MedicineIntakeScreenState extends State { + final enterInformationController = TextEditingController(); + + @override + void initState() { + super.initState(); + enterInformationController.text = widget.sheet.aboutTakingPils; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -36,83 +42,22 @@ class _MedicineIntakeScreenState extends State { style: theme.textTheme.headlineSmall, ), ), - SizedBox(height: 86.v), - _buildTextFormField(context), - // 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), - // ); - // }, - // ), - // BlocBuilder( - // builder: (context, state) { - // return GestureDetector( - // onTap: onTapSkip(state, context), - // child: Text("skip".tr, style: theme.textTheme.bodyLarge), - // ); - // }, - // ), + SizedBox(height: 16.v), + Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), + SizedBox(height: 2.v), + CustomTextFormField( + controller: enterInformationController, + hintText: "enter_information".tr, + textInputAction: TextInputAction.done, + maxLines: 8, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(aboutTakingPils: newValue)); + }, + ), ], ), ), ); } - - onTapSkip(MedicineIntakeState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.medicineIntakeModelObj!.userRegistrationSheet; - GoRouter.of(context).goNamed( - 'favoriteSportsScreen', - extra: sheet, - ); - }; - } - - onTapNext(MedicineIntakeState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.medicineIntakeModelObj!.userRegistrationSheet; - // sheet.aboutTakingPils = state.enterInformationController!.text; - GoRouter.of(context).goNamed( - 'favoriteSportsScreen', - extra: sheet, - ); - }; - } - - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Section Widget - _buildTextFormField(BuildContext context) { - return Column( - children: [ - Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.enterInformationController, - builder: (context, enterInformationController) { - return CustomTextFormField( - controller: enterInformationController, - hintText: "enter_information".tr, - textInputAction: TextInputAction.done, - maxLines: 8, - ); - }, - ), - ], - ); - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - GoRouter.of(context).pop(); - } } diff --git a/lib/presentation/registration/weight_screen/weight_screen.dart b/lib/presentation/registration/weight_screen/weight_screen.dart index f65f0f3d..a8a59ca2 100644 --- a/lib/presentation/registration/weight_screen/weight_screen.dart +++ b/lib/presentation/registration/weight_screen/weight_screen.dart @@ -1,75 +1,67 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/weight_bloc.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/services.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:flutter/material.dart'; -class WeightScreen extends StatelessWidget { +class WeightScreen extends StatefulWidget { final UserRegistrationSheet sheet; const WeightScreen({super.key, required this.sheet}); + @override + State createState() => _WeightScreenState(); +} + +class _WeightScreenState extends State { + final weightController = TextEditingController(); + + @override + void initState() { + super.initState(); + weightController.text = widget.sheet.weight; + } + @override Widget build(BuildContext context) { return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80), child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text( - "weight_measurements".tr, - style: theme.textTheme.headlineSmall, - ), - SizedBox(height: 16.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, - ], - ); - }, - ), - ], - ), - ], - ), + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column( + children: [ + Text( + "weight_measurements".tr, + style: theme.textTheme.headlineSmall, + ), + SizedBox(height: 16.v), + Column( + children: [ + Text( + "your_weight".tr, + style: theme.textTheme.bodyLarge, + ), + SizedBox(height: 4.v), + CustomTextFormField( + width: 150.h, + textInputAction: TextInputAction.done, + controller: weightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(weight: newValue)); + }, + ), + ], + ), + ], + ), ), ); } - - onTapNext(WeightState state, BuildContext context) { - return () { - UserRegistrationSheet sheet = state.weightModelObj!.userRegistrationSheet; - GoRouter.of(context).goNamed('heightScreen', extra: sheet); - }; - } - - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - GoRouter.of(context).pop(); - } }