diff --git a/lib/presentation/additional_information_screen/additional_information_screen.dart b/lib/presentation/additional_information_screen/additional_information_screen.dart index 05274de2..4ee525de 100644 --- a/lib/presentation/additional_information_screen/additional_information_screen.dart +++ b/lib/presentation/additional_information_screen/additional_information_screen.dart @@ -8,15 +8,19 @@ import 'package:eatvio_app/widgets/next_step_button.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; +import 'dart:convert'; class AdditionalInformationScreen extends StatefulWidget { const AdditionalInformationScreen({Key? key}) : super(key: key); static Widget builder(BuildContext context) { + final sheet = + ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; return BlocProvider( create: (context) => AdditionalInformationBloc( AdditionalInformationState( - additionalInformationModelObj: AdditionalInformationModel())) + additionalInformationModelObj: + AdditionalInformationModel(userRegistrationSheet: sheet))) ..add(AdditionalInformationInitialEvent()), child: AdditionalInformationScreen()); } @@ -59,12 +63,23 @@ class _AdditionalInformationScreenState SizedBox(height: 73.v), _buildTextFormField(context), Spacer(), - NextStepButton( - text: "finish".tr.toUpperCase(), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - showSuccessMessage(context); - }), + BlocBuilder(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: () { + var message; + UserRegistrationSheet sheet = state + .additionalInformationModelObj! + .userRegistrationSheet; + sheet.additionalInfo = state.editTextController!.text; + message = sheet.toJson(); + print(message); + }); + }), SizedBox(height: 17.v), ])))); } @@ -120,13 +135,12 @@ class _AdditionalInformationScreenState /// Displays an alert dialog when the action is triggered. /// The dialog box contains a title and a message with the `Теперь вы можете пользоваться полным функционалом приложения` - showSuccessMessage(BuildContext context) { + showSuccessMessage(BuildContext context, String text) { showDialog( context: context, builder: (_) => AlertDialog( title: const Text('Регистрация завершена!'), - content: const Text( - 'Теперь вы можете пользоваться полным функционалом приложения'), + content: const Text(text), actions: [ TextButton( onPressed: () { diff --git a/lib/presentation/additional_information_screen/models/additional_information_model.dart b/lib/presentation/additional_information_screen/models/additional_information_model.dart index 3eccd2a0..3e5243d2 100644 --- a/lib/presentation/additional_information_screen/models/additional_information_model.dart +++ b/lib/presentation/additional_information_screen/models/additional_information_model.dart @@ -1,16 +1,21 @@ // ignore_for_file: must_be_immutable import 'package:equatable/equatable.dart'; +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; /// This class defines the variables used in the [additional_information_screen], /// and is typically used to hold data that is passed between different parts of the application. class AdditionalInformationModel extends Equatable { - AdditionalInformationModel(); + UserRegistrationSheet userRegistrationSheet; + AdditionalInformationModel({required this.userRegistrationSheet}); AdditionalInformationModel copyWith() { - return AdditionalInformationModel(); + return AdditionalInformationModel( + userRegistrationSheet: + userRegistrationSheet ?? this.userRegistrationSheet, + ); } @override - List get props => []; + List get props => [userRegistrationSheet]; } diff --git a/lib/presentation/allergies_screen/allergies_screen.dart b/lib/presentation/allergies_screen/allergies_screen.dart index ac2e3aca..0e4de30d 100644 --- a/lib/presentation/allergies_screen/allergies_screen.dart +++ b/lib/presentation/allergies_screen/allergies_screen.dart @@ -13,10 +13,12 @@ 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; return BlocProvider( - create: (context) => - AllergiesBloc(AllergiesState(allergiesModelObj: AllergiesModel())) - ..add(AllergiesInitialEvent()), + create: (context) => AllergiesBloc(AllergiesState( + allergiesModelObj: AllergiesModel(userRegistrationSheet: sheet))) + ..add(AllergiesInitialEvent()), child: AllergiesScreen()); } @@ -58,12 +60,25 @@ class _AllergiesScreenState extends State { Spacer(flex: 36), _buildTextFormField(context), Spacer(flex: 63), - NextStepButton( - text: "continue".tr.toUpperCase(), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - navigateToMedicine(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: () { + UserRegistrationSheet sheet = + state.allergiesModelObj!.userRegistrationSheet; + sheet.aboutAllergy = + state.enterInformationController!.text; + Navigator.pushNamed( + context, + AppRoutes.medicineIntakeScreen, + arguments: sheet, + ); + }); + }), SizedBox(height: 17.v), Text("skip".tr, style: theme.textTheme.bodyLarge) ])))); diff --git a/lib/presentation/allergies_screen/models/allergies_model.dart b/lib/presentation/allergies_screen/models/allergies_model.dart index 4ba134a3..5553fa4e 100644 --- a/lib/presentation/allergies_screen/models/allergies_model.dart +++ b/lib/presentation/allergies_screen/models/allergies_model.dart @@ -1,16 +1,21 @@ // ignore_for_file: must_be_immutable import 'package:equatable/equatable.dart'; +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; /// This class defines the variables used in the [allergies_screen], /// and is typically used to hold data that is passed between different parts of the application. class AllergiesModel extends Equatable { - AllergiesModel(); + UserRegistrationSheet userRegistrationSheet; + AllergiesModel({required this.userRegistrationSheet}); AllergiesModel copyWith() { - return AllergiesModel(); + return AllergiesModel( + userRegistrationSheet: + userRegistrationSheet ?? this.userRegistrationSheet, + ); } @override - List get props => []; + List get props => [userRegistrationSheet]; } diff --git a/lib/presentation/blood_pressure_screen/bloc/blood_pressure_bloc.dart b/lib/presentation/blood_pressure_screen/bloc/blood_pressure_bloc.dart index 8eefb84b..c2c3632c 100644 --- a/lib/presentation/blood_pressure_screen/bloc/blood_pressure_bloc.dart +++ b/lib/presentation/blood_pressure_screen/bloc/blood_pressure_bloc.dart @@ -9,20 +9,41 @@ part 'blood_pressure_state.dart'; class BloodPressureBloc extends Bloc { BloodPressureBloc(BloodPressureState initialState) : super(initialState) { on(_onInitialize); - on(_changeDropDown); + on(_changeHypoDropDown); + on(_changeHyperDropDown); } - _changeDropDown( - ChangeDropDownEvent event, + _changeHyperDropDown( + ChangeHyperDropDownEvent event, Emitter emit, ) { - emit(state.copyWith(selectedDropDownValue: event.value)); + if (event.value.id == 1) { + state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = true; + } else { + state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = false; + } + emit(state.copyWith(selectedHyperValue: event.value)); + } + + _changeHypoDropDown( + ChangeHypoDownEvent event, + Emitter emit, + ) { + if (event.value.id == 1) { + state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = true; + } else { + state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = false; + } + emit(state.copyWith(selectedHypoValue: event.value)); } List fillDropdownItemList() { return [ - SelectionPopupModel(id: 1, title: "Да", isSelected: true), - SelectionPopupModel(id: 2, title: "Нет"), + SelectionPopupModel( + id: 1, + title: "Да", + ), + SelectionPopupModel(id: 2, title: "Нет", isSelected: true), ]; } @@ -31,9 +52,8 @@ class BloodPressureBloc extends Bloc { Emitter emit, ) async { emit(state.copyWith( - valueController: TextEditingController(), - valueController1: TextEditingController(), - valueController2: TextEditingController())); + upPressureController: TextEditingController(), + downPressureController: TextEditingController())); emit(state.copyWith( bloodPressureModelObj: state.bloodPressureModelObj ?.copyWith(dropdownItemList: fillDropdownItemList()))); diff --git a/lib/presentation/blood_pressure_screen/bloc/blood_pressure_event.dart b/lib/presentation/blood_pressure_screen/bloc/blood_pressure_event.dart index 98e86810..677d2436 100644 --- a/lib/presentation/blood_pressure_screen/bloc/blood_pressure_event.dart +++ b/lib/presentation/blood_pressure_screen/bloc/blood_pressure_event.dart @@ -16,8 +16,19 @@ class BloodPressureInitialEvent extends BloodPressureEvent { } ///event for dropdown selection -class ChangeDropDownEvent extends BloodPressureEvent { - ChangeDropDownEvent({required this.value}); +class ChangeHyperDropDownEvent extends BloodPressureEvent { + ChangeHyperDropDownEvent({required this.value}); + + SelectionPopupModel value; + + @override + List get props => [ + value, + ]; +} + +class ChangeHypoDownEvent extends BloodPressureEvent { + ChangeHypoDownEvent({required this.value}); SelectionPopupModel value; diff --git a/lib/presentation/blood_pressure_screen/bloc/blood_pressure_state.dart b/lib/presentation/blood_pressure_screen/bloc/blood_pressure_state.dart index 08bdff74..d1db1c49 100644 --- a/lib/presentation/blood_pressure_screen/bloc/blood_pressure_state.dart +++ b/lib/presentation/blood_pressure_screen/bloc/blood_pressure_state.dart @@ -5,42 +5,44 @@ part of 'blood_pressure_bloc.dart'; /// Represents the state of BloodPressure in the application. class BloodPressureState extends Equatable { BloodPressureState({ - this.valueController, - this.valueController1, - this.valueController2, - this.selectedDropDownValue, + this.upPressureController, + this.downPressureController, + this.selectedHyperValue, + this.selectedHypoValue, this.bloodPressureModelObj, }); - TextEditingController? valueController; + TextEditingController? upPressureController; - TextEditingController? valueController1; + TextEditingController? downPressureController; - TextEditingController? valueController2; + SelectionPopupModel? selectedHypoValue; - SelectionPopupModel? selectedDropDownValue; + SelectionPopupModel? selectedHyperValue; BloodPressureModel? bloodPressureModelObj; @override List get props => [ - valueController, - valueController1, - selectedDropDownValue, + upPressureController, + downPressureController, + selectedHyperValue, + selectedHypoValue, bloodPressureModelObj, ]; BloodPressureState copyWith({ - TextEditingController? valueController, - TextEditingController? valueController1, - TextEditingController? valueController2, - SelectionPopupModel? selectedDropDownValue, + TextEditingController? upPressureController, + TextEditingController? downPressureController, + SelectionPopupModel? selectedHyperValue, + SelectionPopupModel? selectedHypoValue, BloodPressureModel? bloodPressureModelObj, }) { return BloodPressureState( - valueController: valueController ?? this.valueController, - valueController1: valueController1 ?? this.valueController1, - selectedDropDownValue: - selectedDropDownValue ?? this.selectedDropDownValue, + upPressureController: upPressureController ?? this.upPressureController, + downPressureController: + downPressureController ?? this.downPressureController, + selectedHyperValue: selectedHyperValue ?? this.selectedHyperValue, + selectedHypoValue: selectedHypoValue ?? this.selectedHypoValue, bloodPressureModelObj: bloodPressureModelObj ?? this.bloodPressureModelObj, ); diff --git a/lib/presentation/blood_pressure_screen/blood_pressure_screen.dart b/lib/presentation/blood_pressure_screen/blood_pressure_screen.dart index 73bdcab7..f5c10e1d 100644 --- a/lib/presentation/blood_pressure_screen/blood_pressure_screen.dart +++ b/lib/presentation/blood_pressure_screen/blood_pressure_screen.dart @@ -1,4 +1,5 @@ import 'bloc/blood_pressure_bloc.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/app_bar/appbar_leading_image.dart'; @@ -7,15 +8,19 @@ import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/custom_drop_down.dart'; import 'package:eatvio_app/widgets/next_step_button.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/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; return BlocProvider( - create: (context) => BloodPressureBloc( - BloodPressureState(bloodPressureModelObj: BloodPressureModel())) + create: (context) => BloodPressureBloc(BloodPressureState( + bloodPressureModelObj: + BloodPressureModel(userRegistrationSheet: sheet))) ..add(BloodPressureInitialEvent()), child: BloodPressureScreen()); } @@ -27,6 +32,7 @@ class BloodPressureScreen extends StatefulWidget { class _BloodPressureScreenState extends State { @override Widget build(BuildContext context) { + final digitsOnly = FilteringTextInputFormatter.digitsOnly; mediaQueryData = MediaQuery.of(context); return SafeArea( child: Scaffold( @@ -73,10 +79,11 @@ class _BloodPressureScreenState extends State { SizedBox(height: 2.v), BlocSelector( - selector: (state) => state.valueController1, - builder: (context, valueController1) { + selector: (state) => state.upPressureController, + builder: (context, upPressureController) { return CustomTextFormField( - controller: valueController1, + inputFormatters: [digitsOnly], + controller: upPressureController, hintText: "90".tr); }) ])), @@ -90,10 +97,11 @@ class _BloodPressureScreenState extends State { SizedBox(height: 2.v), BlocSelector( - selector: (state) => state.valueController2, - builder: (context, valueController2) { + selector: (state) => state.downPressureController, + builder: (context, downPressureController) { return CustomTextFormField( - controller: valueController2, + inputFormatters: [digitsOnly], + controller: downPressureController, hintText: "90".tr); }) ])), @@ -118,14 +126,14 @@ class _BloodPressureScreenState extends State { imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize)), - hintText: "no".tr, + hintText: "Не выбрано".tr, items: bloodPressureModelObj?.dropdownItemList ?? [], onChanged: (value) { context .read() - .add(ChangeDropDownEvent(value: value)); + .add(ChangeHypoDownEvent(value: value)); }); })), SizedBox(height: 22.v), @@ -149,24 +157,37 @@ class _BloodPressureScreenState extends State { imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize)), - hintText: "no".tr, + hintText: "Не выбрано".tr, items: bloodPressureModelObj?.dropdownItemList ?? [], onChanged: (value) { - context - .read() - .add(ChangeDropDownEvent(value: value)); + context.read().add( + ChangeHyperDropDownEvent(value: value)); }); })), Spacer(), - NextStepButton( - text: "continue".tr.toUpperCase(), - margin: EdgeInsets.symmetric(horizontal: 4.h), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - navigateToSports(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: () { + UserRegistrationSheet sheet = state + .bloodPressureModelObj!.userRegistrationSheet; + sheet.bloodPressureUp = + int.tryParse(state.upPressureController!.text)!; + sheet.bloodPressureDown = + int.tryParse(state.downPressureController!.text)!; + Navigator.pushNamed( + context, + AppRoutes.favoriteSportsScreen, + arguments: sheet, + ); + }); + }), SizedBox(height: 17.v), Text("skip".tr, style: theme.textTheme.bodyLarge) ])))); diff --git a/lib/presentation/blood_pressure_screen/models/blood_pressure_model.dart b/lib/presentation/blood_pressure_screen/models/blood_pressure_model.dart index b3049c3a..c002b0a9 100644 --- a/lib/presentation/blood_pressure_screen/models/blood_pressure_model.dart +++ b/lib/presentation/blood_pressure_screen/models/blood_pressure_model.dart @@ -2,20 +2,25 @@ import 'package:equatable/equatable.dart'; import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart'; +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; /// This class defines the variables used in the [blood_pressure_screen], /// and is typically used to hold data that is passed between different parts of the application. class BloodPressureModel extends Equatable { - BloodPressureModel({this.dropdownItemList = const []}); + UserRegistrationSheet userRegistrationSheet; + BloodPressureModel( + {required this.userRegistrationSheet, this.dropdownItemList = const []}); List dropdownItemList; BloodPressureModel copyWith({List? dropdownItemList}) { return BloodPressureModel( + userRegistrationSheet: + userRegistrationSheet ?? this.userRegistrationSheet, dropdownItemList: dropdownItemList ?? this.dropdownItemList, ); } @override - List get props => [dropdownItemList]; + List get props => [dropdownItemList, userRegistrationSheet]; } diff --git a/lib/presentation/favorite_foods_screen/bloc/favorite_foods_bloc.dart b/lib/presentation/favorite_foods_screen/bloc/favorite_foods_bloc.dart index 95c740fe..3fcb2c5b 100644 --- a/lib/presentation/favorite_foods_screen/bloc/favorite_foods_bloc.dart +++ b/lib/presentation/favorite_foods_screen/bloc/favorite_foods_bloc.dart @@ -16,7 +16,7 @@ class FavoriteFoodsBloc extends Bloc { Emitter emit, ) async { emit(state.copyWith( - enterinformationController: TextEditingController(), - enterinformationController1: TextEditingController())); + favoriteFoodsController: TextEditingController(), + unfavoriteFoodsController: TextEditingController())); } } diff --git a/lib/presentation/favorite_foods_screen/bloc/favorite_foods_state.dart b/lib/presentation/favorite_foods_screen/bloc/favorite_foods_state.dart index fd14b209..aa4fc3b8 100644 --- a/lib/presentation/favorite_foods_screen/bloc/favorite_foods_state.dart +++ b/lib/presentation/favorite_foods_screen/bloc/favorite_foods_state.dart @@ -5,33 +5,33 @@ part of 'favorite_foods_bloc.dart'; /// Represents the state of FavoriteFoods in the application. class FavoriteFoodsState extends Equatable { FavoriteFoodsState({ - this.enterinformationController, - this.enterinformationController1, + this.favoriteFoodsController, + this.unfavoriteFoodsController, this.favoriteFoodsModelObj, }); - TextEditingController? enterinformationController; + TextEditingController? favoriteFoodsController; - TextEditingController? enterinformationController1; + TextEditingController? unfavoriteFoodsController; FavoriteFoodsModel? favoriteFoodsModelObj; @override List get props => [ - enterinformationController, - enterinformationController1, + favoriteFoodsController, + unfavoriteFoodsController, favoriteFoodsModelObj, ]; FavoriteFoodsState copyWith({ - TextEditingController? enterinformationController, - TextEditingController? enterinformationController1, + TextEditingController? favoriteFoodsController, + TextEditingController? unfavoriteFoodsController, FavoriteFoodsModel? favoriteFoodsModelObj, }) { return FavoriteFoodsState( - enterinformationController: - enterinformationController ?? this.enterinformationController, - enterinformationController1: - enterinformationController1 ?? this.enterinformationController1, + favoriteFoodsController: + favoriteFoodsController ?? this.favoriteFoodsController, + unfavoriteFoodsController: + unfavoriteFoodsController ?? this.unfavoriteFoodsController, favoriteFoodsModelObj: favoriteFoodsModelObj ?? this.favoriteFoodsModelObj, ); diff --git a/lib/presentation/favorite_foods_screen/favorite_foods_screen.dart b/lib/presentation/favorite_foods_screen/favorite_foods_screen.dart index 034b5763..625d221d 100644 --- a/lib/presentation/favorite_foods_screen/favorite_foods_screen.dart +++ b/lib/presentation/favorite_foods_screen/favorite_foods_screen.dart @@ -13,9 +13,12 @@ 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; return BlocProvider( - create: (context) => FavoriteFoodsBloc( - FavoriteFoodsState(favoriteFoodsModelObj: FavoriteFoodsModel())) + create: (context) => FavoriteFoodsBloc(FavoriteFoodsState( + favoriteFoodsModelObj: + FavoriteFoodsModel(userRegistrationSheet: sheet))) ..add(FavoriteFoodsInitialEvent()), child: FavoriteFoodsScreen()); } @@ -62,16 +65,31 @@ class _FavoriteFoodsScreenState extends State { textAlign: TextAlign.center, style: theme.textTheme.headlineSmall)), SizedBox(height: 23.v), - _buildTextFormField(context), + _buildTextFormFieldFav(context), SizedBox(height: 22.v), - _buildTextFormField1(context), + _buildTextFormFieldUnfav(context), SizedBox(height: 27.v), - NextStepButton( - text: "continue".tr.toUpperCase(), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - navigateToAdditionalInformationScreen(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: () { + UserRegistrationSheet sheet = state + .favoriteFoodsModelObj!.userRegistrationSheet; + sheet.favoriteFoods = + state.favoriteFoodsController!.text; + sheet.unfavoriteFoods = + state.unfavoriteFoodsController!.text; + Navigator.pushNamed( + context, + AppRoutes.additionalInformationScreen, + arguments: sheet, + ); + }); + }), SizedBox(height: 17.v), Text("skip".tr, style: theme.textTheme.bodyLarge) ])))); @@ -92,16 +110,16 @@ class _FavoriteFoodsScreenState extends State { } /// Section Widget - Widget _buildTextFormField(BuildContext context) { + Widget _buildTextFormFieldFav(BuildContext context) { return Column(children: [ Text("favorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), SizedBox(height: 2.v), BlocSelector( - selector: (state) => state.enterinformationController, - builder: (context, enterinformationController) { + selector: (state) => state.favoriteFoodsController, + builder: (context, favoriteFoodsController) { return CustomTextFormField( - controller: enterinformationController, + controller: favoriteFoodsController, hintText: "enter_information".tr, maxLines: 7); }) @@ -109,16 +127,16 @@ class _FavoriteFoodsScreenState extends State { } /// Section Widget - Widget _buildTextFormField1(BuildContext context) { + Widget _buildTextFormFieldUnfav(BuildContext context) { return Column(children: [ Text("unfavorite_foods".tr, style: CustomTextStyles.titleMediumSegoeUI), SizedBox(height: 2.v), BlocSelector( - selector: (state) => state.enterinformationController1, - builder: (context, enterinformationController1) { + selector: (state) => state.unfavoriteFoodsController, + builder: (context, unfavoriteFoodsController) { return CustomTextFormField( - controller: enterinformationController1, + controller: unfavoriteFoodsController, hintText: "enter_information".tr, textInputAction: TextInputAction.done, maxLines: 7); diff --git a/lib/presentation/favorite_foods_screen/models/favorite_foods_model.dart b/lib/presentation/favorite_foods_screen/models/favorite_foods_model.dart index 935c6d29..2084cade 100644 --- a/lib/presentation/favorite_foods_screen/models/favorite_foods_model.dart +++ b/lib/presentation/favorite_foods_screen/models/favorite_foods_model.dart @@ -1,16 +1,21 @@ // ignore_for_file: must_be_immutable import 'package:equatable/equatable.dart'; +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; /// This class defines the variables used in the [favorite_foods_screen], /// and is typically used to hold data that is passed between different parts of the application. class FavoriteFoodsModel extends Equatable { - FavoriteFoodsModel(); + UserRegistrationSheet userRegistrationSheet; + FavoriteFoodsModel({required this.userRegistrationSheet}); FavoriteFoodsModel copyWith() { - return FavoriteFoodsModel(); + return FavoriteFoodsModel( + userRegistrationSheet: + userRegistrationSheet ?? this.userRegistrationSheet, + ); } @override - List get props => []; + List get props => [userRegistrationSheet]; } diff --git a/lib/presentation/favorite_sports_screen/favorite_sports_screen.dart b/lib/presentation/favorite_sports_screen/favorite_sports_screen.dart index eb047457..2d531bea 100644 --- a/lib/presentation/favorite_sports_screen/favorite_sports_screen.dart +++ b/lib/presentation/favorite_sports_screen/favorite_sports_screen.dart @@ -13,9 +13,12 @@ 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; return BlocProvider( - create: (context) => FavoriteSportsBloc( - FavoriteSportsState(favoriteSportsModelObj: FavoriteSportsModel())) + create: (context) => FavoriteSportsBloc(FavoriteSportsState( + favoriteSportsModelObj: + FavoriteSportsModel(userRegistrationSheet: sheet))) ..add(FavoriteSportsInitialEvent()), child: FavoriteSportsScreen()); } @@ -61,12 +64,26 @@ class _FavoriteSportsScreenState extends State { Spacer(flex: 32), _buildTextFormFieldSection(context), Spacer(flex: 67), - NextStepButton( - text: "continue".tr.toUpperCase(), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - navigateToFoods(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: () { + UserRegistrationSheet sheet = state + .favoriteSportsModelObj! + .userRegistrationSheet; + sheet.aboutSportHobbies = + state.enterinformationController!.text; + Navigator.pushNamed( + context, + AppRoutes.favoriteFoodsScreen, + arguments: sheet, + ); + }); + }), SizedBox(height: 17.v), Text("skip".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 4.v) @@ -108,11 +125,4 @@ class _FavoriteSportsScreenState extends State { onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); } - - /// Navigates to the favoriteFoodsScreen when the action is triggered. - navigateToFoods(BuildContext context) { - NavigatorService.pushNamed( - AppRoutes.favoriteFoodsScreen, - ); - } } diff --git a/lib/presentation/favorite_sports_screen/models/favorite_sports_model.dart b/lib/presentation/favorite_sports_screen/models/favorite_sports_model.dart index 418fd75d..11a1e288 100644 --- a/lib/presentation/favorite_sports_screen/models/favorite_sports_model.dart +++ b/lib/presentation/favorite_sports_screen/models/favorite_sports_model.dart @@ -1,16 +1,21 @@ // ignore_for_file: must_be_immutable import 'package:equatable/equatable.dart'; +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; /// This class defines the variables used in the [favorite_sports_screen], /// and is typically used to hold data that is passed between different parts of the application. class FavoriteSportsModel extends Equatable { - FavoriteSportsModel(); + UserRegistrationSheet userRegistrationSheet; + FavoriteSportsModel({required this.userRegistrationSheet}); FavoriteSportsModel copyWith() { - return FavoriteSportsModel(); + return FavoriteSportsModel( + userRegistrationSheet: + userRegistrationSheet ?? this.userRegistrationSheet, + ); } @override - List get props => []; + List get props => [userRegistrationSheet]; } diff --git a/lib/presentation/height_screen/height_screen.dart b/lib/presentation/height_screen/height_screen.dart index e258e465..17a5a9ab 100644 --- a/lib/presentation/height_screen/height_screen.dart +++ b/lib/presentation/height_screen/height_screen.dart @@ -98,7 +98,7 @@ class _HeightScreenState extends State { state.heightModelObj!.userRegistrationSheet; Navigator.pushNamed( context, - AppRoutes.heightScreen, + AppRoutes.allergiesScreen, arguments: sheet, ); }); diff --git a/lib/presentation/medicine_intake_screen/medicine_intake_screen.dart b/lib/presentation/medicine_intake_screen/medicine_intake_screen.dart index 9382e8d1..5b8fdb95 100644 --- a/lib/presentation/medicine_intake_screen/medicine_intake_screen.dart +++ b/lib/presentation/medicine_intake_screen/medicine_intake_screen.dart @@ -6,15 +6,19 @@ import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart'; import 'package:eatvio_app/widgets/next_step_button.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/material.dart'; class MedicineIntakeScreen extends StatefulWidget { const MedicineIntakeScreen({Key? key}) : super(key: key); static Widget builder(BuildContext context) { + final sheet = + ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet; return BlocProvider( - create: (context) => MedicineIntakeBloc( - MedicineIntakeState(medicineIntakeModelObj: MedicineIntakeModel())) + create: (context) => MedicineIntakeBloc(MedicineIntakeState( + medicineIntakeModelObj: + MedicineIntakeModel(userRegistrationSheet: sheet))) ..add(MedicineIntakeInitialEvent()), child: MedicineIntakeScreen()); } @@ -63,12 +67,25 @@ class _MedicineIntakeScreenState extends State { SizedBox(height: 86.v), _buildTextFormField(context), Spacer(), - NextStepButton( - text: "continue".tr.toUpperCase(), - buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - navigateToPressure(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: () { + UserRegistrationSheet sheet = state + .medicineIntakeModelObj!.userRegistrationSheet; + sheet.aboutTakingPils = + state.enterInformationController!.text; + Navigator.pushNamed( + context, + AppRoutes.bloodPressureScreen, + arguments: sheet, + ); + }); + }), SizedBox(height: 17.v), Text("skip".tr, style: theme.textTheme.bodyLarge) ])))); @@ -111,11 +128,4 @@ class _MedicineIntakeScreenState extends State { onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); } - - /// Navigates to the bloodPressureScreen when the action is triggered. - navigateToPressure(BuildContext context) { - NavigatorService.pushNamed( - AppRoutes.bloodPressureScreen, - ); - } } diff --git a/lib/presentation/medicine_intake_screen/models/medicine_intake_model.dart b/lib/presentation/medicine_intake_screen/models/medicine_intake_model.dart index 5a095de4..9828f2d8 100644 --- a/lib/presentation/medicine_intake_screen/models/medicine_intake_model.dart +++ b/lib/presentation/medicine_intake_screen/models/medicine_intake_model.dart @@ -1,16 +1,21 @@ // ignore_for_file: must_be_immutable import 'package:equatable/equatable.dart'; +import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; /// This class defines the variables used in the [medicine_intake_screen], /// and is typically used to hold data that is passed between different parts of the application. class MedicineIntakeModel extends Equatable { - MedicineIntakeModel(); + UserRegistrationSheet userRegistrationSheet; + MedicineIntakeModel({required this.userRegistrationSheet}); MedicineIntakeModel copyWith() { - return MedicineIntakeModel(); + return MedicineIntakeModel( + userRegistrationSheet: + userRegistrationSheet ?? this.userRegistrationSheet, + ); } @override - List get props => []; + List get props => [userRegistrationSheet]; }