From 3cdab9e1bb5567486eec0c296f00beba4ab653f2 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Sun, 14 Jul 2024 16:30:10 +0300 Subject: [PATCH] feature(registration): refactor --- lib/app_router.dart | 118 --- .../user_registration_model.dart | 146 ++-- .../user_registration_model.freezed.dart | 811 ++++++++++++++++++ .../user_registration_model.g.dart | 73 ++ .../registration_cubit.dart | 4 +- .../registration_state.dart | 8 +- .../registration_state.freezed.dart | 272 ++---- .../pages/registration_screen.dart | 113 ++- .../additional_information_screen.dart | 2 +- .../allergies_screen/allergies_screen.dart | 2 +- .../bloc/blood_pressure_bloc.dart | 8 +- .../blood_pressure_screen.dart | 4 +- .../body_circumferences_screen.dart | 8 +- .../bloc/city_of_living_bloc.dart | 2 +- .../city_of_living_screen.dart | 1 - .../credentials_screen.dart | 173 ++-- .../date_of_birth_screen.dart | 2 +- .../favorite_foods_screen.dart | 4 +- .../favorite_sports_screen.dart | 2 +- .../gender_screen/bloc/gender_bloc.dart | 2 +- .../gender_screen/gender_screen.dart | 2 +- .../height_screen/height_screen.dart | 2 +- .../bloc/language_select_bloc.dart | 2 +- .../language_select_screen.dart | 100 +-- .../models/language_select_model.dart | 1 + .../medicine_intake_screen.dart | 2 +- .../registration/name_screen/name_screen.dart | 2 +- .../weight_screen/weight_screen.dart | 2 +- lib/widgets/app_bar/appbar_title_image.dart | 31 +- lib/widgets/custom_drop_down.dart | 1 - lib/widgets/custom_text_form_field.dart | 3 +- 31 files changed, 1214 insertions(+), 689 deletions(-) create mode 100644 lib/data/models/userRegistrationModel/user_registration_model.freezed.dart create mode 100644 lib/data/models/userRegistrationModel/user_registration_model.g.dart diff --git a/lib/app_router.dart b/lib/app_router.dart index 5ca4a54..8f16666 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -16,21 +16,6 @@ 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/medicine_intake_screen/medicine_intake_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/features/bottom_navigation_bar/presentation/widgets/bottom_navigation_bar_widget.dart'; import 'package:eatvio_app/features/chat/presentation/pages/photo_view_screen.dart'; import 'package:flutter/material.dart'; @@ -60,109 +45,6 @@ class AppRouter { name: 'registrationScreen', builder: (context, state) => const RegistrationScreen(), ), - GoRoute( - 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( - name: 'allergiesScreen', - path: 'allergiesScreen', - builder: (context, state) => AllergiesScreen.builder(context, state.extra), - routes: [ - GoRoute( - name: 'medicineIntakeScreen', - path: 'medicine-intake-screen', - builder: (context, state) => MedicineIntakeScreen.builder(context, state.extra), - routes: [ - GoRoute( - path: 'favorite-sports-screen', - name: 'favoriteSportsScreen', - builder: (context, state) => FavoriteSportsScreen.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), - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), ], ), ShellRoute( diff --git a/lib/data/models/userRegistrationModel/user_registration_model.dart b/lib/data/models/userRegistrationModel/user_registration_model.dart index baeb3a1..cae81cd 100644 --- a/lib/data/models/userRegistrationModel/user_registration_model.dart +++ b/lib/data/models/userRegistrationModel/user_registration_model.dart @@ -1,92 +1,60 @@ -class UserRegistrationSheet { - String name; - String firstName; - String lastName; - String email; - String password; - String passwordConfirmation; - String termsAccepted; - String birthdate; - String gender; - String country; - String city; - String lang; - String weight; - String height; - String chestCircumference; - String waistCircumference; - String hipCircumference; - String bloodPressureUp; - String bloodPressureDown; - String hasHypo = ''; - String hasHyper = ''; - String aboutAllergy = ''; - String aboutTakingPils = ''; - String aboutSportHobbies = ''; - String favoriteFoods = ''; - String unfavoriteFoods = ''; - String additionalInfo = ''; +import 'package:freezed_annotation/freezed_annotation.dart'; - UserRegistrationSheet({ - required this.name, - required this.firstName, - required this.lastName, - required this.email, - required this.password, - required this.passwordConfirmation, - required this.termsAccepted, - required this.birthdate, - required this.gender, - required this.country, - required this.city, - required this.lang, - required this.weight, - required this.height, - required this.chestCircumference, - required this.waistCircumference, - required this.hipCircumference, - required this.bloodPressureUp, - required this.bloodPressureDown, - required this.hasHypo, - required this.hasHyper, - required this.aboutAllergy, - required this.aboutTakingPils, - required this.aboutSportHobbies, - required this.favoriteFoods, - required this.unfavoriteFoods, - required this.additionalInfo, - }); +part 'user_registration_model.freezed.dart'; +part 'user_registration_model.g.dart'; - Map toJson() { - return { - 'name': name, - 'first_name': firstName, - 'last_name': lastName, - 'email': email, - 'password': password, - 'password_confirmation': passwordConfirmation, - 'terms': termsAccepted, - 'birthdate': birthdate.toString(), - 'gender': gender, - 'country': country, - 'city': city, - 'lang': lang, - 'weight': weight, - 'height': height, - 'chest_circumference': chestCircumference, - 'waist_circumference': waistCircumference, - 'hip_circumference': hipCircumference, - 'blood_pressure_up': bloodPressureUp, - 'blood_pressure_down': bloodPressureDown, - 'has_hypo': hasHypo, - 'has_hyper': hasHyper, - 'about_alergy': aboutAllergy, - 'about_taking_pils': aboutTakingPils, - 'about_sport_hobbies': aboutSportHobbies, - 'favorite_foods': favoriteFoods, - 'unfavorite_foods': unfavoriteFoods, - 'additional_info': additionalInfo, - 'activity_coefficient': '1.2', - }; - } +@freezed +class UserRegistrationSheet with _$UserRegistrationSheet { + const factory UserRegistrationSheet({ + required String name, + @JsonKey(name: 'first_name') + required String firstName, + @JsonKey(name: 'last') + required String lastName, + required String email, + required String password, + @JsonKey(name: 'password_confirmation') + required String passwordConfirmation, + @Default('accepted') + @JsonKey(name: 'terms') + String termsAccepted, + required String birthdate, + required String gender, + required String country, + required String city, + required String lang, + required String weight, + required String height, + @JsonKey(name: 'chest_circumference') + required String chestCircumference, + @JsonKey(name: 'waist_circumference') + required String waistCircumference, + @JsonKey(name: 'hip_circumference') + required String hipCircumference, + @JsonKey(name: 'blood_pressure_up') + required String bloodPressureUp, + @JsonKey(name: 'blood_pressure_down') + required String bloodPressureDown, + @JsonKey(name: 'has_hypo') + required String hasHypo, + @JsonKey(name: 'has_hyper') + required String hasHyper, + @JsonKey(name: 'about_alergy') + required String aboutAllergy, + @JsonKey(name: 'about_taking_pils') + required String aboutTakingPils, + @JsonKey(name: 'about_sport_hobbies') + required String aboutSportHobbies, + @JsonKey(name: 'favorite_foods') + required String favoriteFoods, + @JsonKey(name: 'unfavorite_foods') + required String unfavoriteFoods, + @JsonKey(name: 'additional_info') + required String additionalInfo, + @Default('1.2') + @JsonKey(name: 'activity_coefficient') + String activityCoefficient, + }) = _UserRegistrationSheet; + + factory UserRegistrationSheet.fromJson(Map json) => _$UserRegistrationSheetFromJson(json); } diff --git a/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart b/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart new file mode 100644 index 0000000..9d00a7d --- /dev/null +++ b/lib/data/models/userRegistrationModel/user_registration_model.freezed.dart @@ -0,0 +1,811 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'user_registration_model.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +UserRegistrationSheet _$UserRegistrationSheetFromJson( + Map json) { + return _UserRegistrationSheet.fromJson(json); +} + +/// @nodoc +mixin _$UserRegistrationSheet { + String get name => throw _privateConstructorUsedError; + @JsonKey(name: 'first_name') + String get firstName => throw _privateConstructorUsedError; + @JsonKey(name: 'last') + String get lastName => throw _privateConstructorUsedError; + String get email => throw _privateConstructorUsedError; + String get password => throw _privateConstructorUsedError; + @JsonKey(name: 'password_confirmation') + String get passwordConfirmation => throw _privateConstructorUsedError; + @JsonKey(name: 'terms') + String get termsAccepted => throw _privateConstructorUsedError; + String get birthdate => throw _privateConstructorUsedError; + String get gender => throw _privateConstructorUsedError; + String get country => throw _privateConstructorUsedError; + String get city => throw _privateConstructorUsedError; + String get lang => throw _privateConstructorUsedError; + String get weight => throw _privateConstructorUsedError; + String get height => throw _privateConstructorUsedError; + @JsonKey(name: 'chest_circumference') + String get chestCircumference => throw _privateConstructorUsedError; + @JsonKey(name: 'waist_circumference') + String get waistCircumference => throw _privateConstructorUsedError; + @JsonKey(name: 'hip_circumference') + String get hipCircumference => throw _privateConstructorUsedError; + @JsonKey(name: 'blood_pressure_up') + String get bloodPressureUp => throw _privateConstructorUsedError; + @JsonKey(name: 'blood_pressure_down') + String get bloodPressureDown => throw _privateConstructorUsedError; + @JsonKey(name: 'has_hypo') + String get hasHypo => throw _privateConstructorUsedError; + @JsonKey(name: 'has_hyper') + String get hasHyper => throw _privateConstructorUsedError; + @JsonKey(name: 'about_alergy') + String get aboutAllergy => throw _privateConstructorUsedError; + @JsonKey(name: 'about_taking_pils') + String get aboutTakingPils => throw _privateConstructorUsedError; + @JsonKey(name: 'about_sport_hobbies') + String get aboutSportHobbies => throw _privateConstructorUsedError; + @JsonKey(name: 'favorite_foods') + String get favoriteFoods => throw _privateConstructorUsedError; + @JsonKey(name: 'unfavorite_foods') + String get unfavoriteFoods => throw _privateConstructorUsedError; + @JsonKey(name: 'additional_info') + String get additionalInfo => throw _privateConstructorUsedError; + @JsonKey(name: 'activity_coefficient') + String get activityCoefficient => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $UserRegistrationSheetCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $UserRegistrationSheetCopyWith<$Res> { + factory $UserRegistrationSheetCopyWith(UserRegistrationSheet value, + $Res Function(UserRegistrationSheet) then) = + _$UserRegistrationSheetCopyWithImpl<$Res, UserRegistrationSheet>; + @useResult + $Res call( + {String name, + @JsonKey(name: 'first_name') String firstName, + @JsonKey(name: 'last') String lastName, + String email, + String password, + @JsonKey(name: 'password_confirmation') String passwordConfirmation, + @JsonKey(name: 'terms') String termsAccepted, + String birthdate, + String gender, + String country, + String city, + String lang, + String weight, + String height, + @JsonKey(name: 'chest_circumference') String chestCircumference, + @JsonKey(name: 'waist_circumference') String waistCircumference, + @JsonKey(name: 'hip_circumference') String hipCircumference, + @JsonKey(name: 'blood_pressure_up') String bloodPressureUp, + @JsonKey(name: 'blood_pressure_down') String bloodPressureDown, + @JsonKey(name: 'has_hypo') String hasHypo, + @JsonKey(name: 'has_hyper') String hasHyper, + @JsonKey(name: 'about_alergy') String aboutAllergy, + @JsonKey(name: 'about_taking_pils') String aboutTakingPils, + @JsonKey(name: 'about_sport_hobbies') String aboutSportHobbies, + @JsonKey(name: 'favorite_foods') String favoriteFoods, + @JsonKey(name: 'unfavorite_foods') String unfavoriteFoods, + @JsonKey(name: 'additional_info') String additionalInfo, + @JsonKey(name: 'activity_coefficient') String activityCoefficient}); +} + +/// @nodoc +class _$UserRegistrationSheetCopyWithImpl<$Res, + $Val extends UserRegistrationSheet> + implements $UserRegistrationSheetCopyWith<$Res> { + _$UserRegistrationSheetCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? firstName = null, + Object? lastName = null, + Object? email = null, + Object? password = null, + Object? passwordConfirmation = null, + Object? termsAccepted = null, + Object? birthdate = null, + Object? gender = null, + Object? country = null, + Object? city = null, + Object? lang = null, + Object? weight = null, + Object? height = null, + Object? chestCircumference = null, + Object? waistCircumference = null, + Object? hipCircumference = null, + Object? bloodPressureUp = null, + Object? bloodPressureDown = null, + Object? hasHypo = null, + Object? hasHyper = null, + Object? aboutAllergy = null, + Object? aboutTakingPils = null, + Object? aboutSportHobbies = null, + Object? favoriteFoods = null, + Object? unfavoriteFoods = null, + Object? additionalInfo = null, + Object? activityCoefficient = null, + }) { + return _then(_value.copyWith( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + firstName: null == firstName + ? _value.firstName + : firstName // ignore: cast_nullable_to_non_nullable + as String, + lastName: null == lastName + ? _value.lastName + : lastName // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + password: null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + passwordConfirmation: null == passwordConfirmation + ? _value.passwordConfirmation + : passwordConfirmation // ignore: cast_nullable_to_non_nullable + as String, + termsAccepted: null == termsAccepted + ? _value.termsAccepted + : termsAccepted // ignore: cast_nullable_to_non_nullable + as String, + birthdate: null == birthdate + ? _value.birthdate + : birthdate // ignore: cast_nullable_to_non_nullable + as String, + gender: null == gender + ? _value.gender + : gender // ignore: cast_nullable_to_non_nullable + as String, + country: null == country + ? _value.country + : country // ignore: cast_nullable_to_non_nullable + as String, + city: null == city + ? _value.city + : city // ignore: cast_nullable_to_non_nullable + as String, + lang: null == lang + ? _value.lang + : lang // ignore: cast_nullable_to_non_nullable + as String, + weight: null == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as String, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as String, + chestCircumference: null == chestCircumference + ? _value.chestCircumference + : chestCircumference // ignore: cast_nullable_to_non_nullable + as String, + waistCircumference: null == waistCircumference + ? _value.waistCircumference + : waistCircumference // ignore: cast_nullable_to_non_nullable + as String, + hipCircumference: null == hipCircumference + ? _value.hipCircumference + : hipCircumference // ignore: cast_nullable_to_non_nullable + as String, + bloodPressureUp: null == bloodPressureUp + ? _value.bloodPressureUp + : bloodPressureUp // ignore: cast_nullable_to_non_nullable + as String, + bloodPressureDown: null == bloodPressureDown + ? _value.bloodPressureDown + : bloodPressureDown // ignore: cast_nullable_to_non_nullable + as String, + hasHypo: null == hasHypo + ? _value.hasHypo + : hasHypo // ignore: cast_nullable_to_non_nullable + as String, + hasHyper: null == hasHyper + ? _value.hasHyper + : hasHyper // ignore: cast_nullable_to_non_nullable + as String, + aboutAllergy: null == aboutAllergy + ? _value.aboutAllergy + : aboutAllergy // ignore: cast_nullable_to_non_nullable + as String, + aboutTakingPils: null == aboutTakingPils + ? _value.aboutTakingPils + : aboutTakingPils // ignore: cast_nullable_to_non_nullable + as String, + aboutSportHobbies: null == aboutSportHobbies + ? _value.aboutSportHobbies + : aboutSportHobbies // ignore: cast_nullable_to_non_nullable + as String, + favoriteFoods: null == favoriteFoods + ? _value.favoriteFoods + : favoriteFoods // ignore: cast_nullable_to_non_nullable + as String, + unfavoriteFoods: null == unfavoriteFoods + ? _value.unfavoriteFoods + : unfavoriteFoods // ignore: cast_nullable_to_non_nullable + as String, + additionalInfo: null == additionalInfo + ? _value.additionalInfo + : additionalInfo // ignore: cast_nullable_to_non_nullable + as String, + activityCoefficient: null == activityCoefficient + ? _value.activityCoefficient + : activityCoefficient // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$UserRegistrationSheetImplCopyWith<$Res> + implements $UserRegistrationSheetCopyWith<$Res> { + factory _$$UserRegistrationSheetImplCopyWith( + _$UserRegistrationSheetImpl value, + $Res Function(_$UserRegistrationSheetImpl) then) = + __$$UserRegistrationSheetImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String name, + @JsonKey(name: 'first_name') String firstName, + @JsonKey(name: 'last') String lastName, + String email, + String password, + @JsonKey(name: 'password_confirmation') String passwordConfirmation, + @JsonKey(name: 'terms') String termsAccepted, + String birthdate, + String gender, + String country, + String city, + String lang, + String weight, + String height, + @JsonKey(name: 'chest_circumference') String chestCircumference, + @JsonKey(name: 'waist_circumference') String waistCircumference, + @JsonKey(name: 'hip_circumference') String hipCircumference, + @JsonKey(name: 'blood_pressure_up') String bloodPressureUp, + @JsonKey(name: 'blood_pressure_down') String bloodPressureDown, + @JsonKey(name: 'has_hypo') String hasHypo, + @JsonKey(name: 'has_hyper') String hasHyper, + @JsonKey(name: 'about_alergy') String aboutAllergy, + @JsonKey(name: 'about_taking_pils') String aboutTakingPils, + @JsonKey(name: 'about_sport_hobbies') String aboutSportHobbies, + @JsonKey(name: 'favorite_foods') String favoriteFoods, + @JsonKey(name: 'unfavorite_foods') String unfavoriteFoods, + @JsonKey(name: 'additional_info') String additionalInfo, + @JsonKey(name: 'activity_coefficient') String activityCoefficient}); +} + +/// @nodoc +class __$$UserRegistrationSheetImplCopyWithImpl<$Res> + extends _$UserRegistrationSheetCopyWithImpl<$Res, + _$UserRegistrationSheetImpl> + implements _$$UserRegistrationSheetImplCopyWith<$Res> { + __$$UserRegistrationSheetImplCopyWithImpl(_$UserRegistrationSheetImpl _value, + $Res Function(_$UserRegistrationSheetImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? firstName = null, + Object? lastName = null, + Object? email = null, + Object? password = null, + Object? passwordConfirmation = null, + Object? termsAccepted = null, + Object? birthdate = null, + Object? gender = null, + Object? country = null, + Object? city = null, + Object? lang = null, + Object? weight = null, + Object? height = null, + Object? chestCircumference = null, + Object? waistCircumference = null, + Object? hipCircumference = null, + Object? bloodPressureUp = null, + Object? bloodPressureDown = null, + Object? hasHypo = null, + Object? hasHyper = null, + Object? aboutAllergy = null, + Object? aboutTakingPils = null, + Object? aboutSportHobbies = null, + Object? favoriteFoods = null, + Object? unfavoriteFoods = null, + Object? additionalInfo = null, + Object? activityCoefficient = null, + }) { + return _then(_$UserRegistrationSheetImpl( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + firstName: null == firstName + ? _value.firstName + : firstName // ignore: cast_nullable_to_non_nullable + as String, + lastName: null == lastName + ? _value.lastName + : lastName // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + password: null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + passwordConfirmation: null == passwordConfirmation + ? _value.passwordConfirmation + : passwordConfirmation // ignore: cast_nullable_to_non_nullable + as String, + termsAccepted: null == termsAccepted + ? _value.termsAccepted + : termsAccepted // ignore: cast_nullable_to_non_nullable + as String, + birthdate: null == birthdate + ? _value.birthdate + : birthdate // ignore: cast_nullable_to_non_nullable + as String, + gender: null == gender + ? _value.gender + : gender // ignore: cast_nullable_to_non_nullable + as String, + country: null == country + ? _value.country + : country // ignore: cast_nullable_to_non_nullable + as String, + city: null == city + ? _value.city + : city // ignore: cast_nullable_to_non_nullable + as String, + lang: null == lang + ? _value.lang + : lang // ignore: cast_nullable_to_non_nullable + as String, + weight: null == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as String, + height: null == height + ? _value.height + : height // ignore: cast_nullable_to_non_nullable + as String, + chestCircumference: null == chestCircumference + ? _value.chestCircumference + : chestCircumference // ignore: cast_nullable_to_non_nullable + as String, + waistCircumference: null == waistCircumference + ? _value.waistCircumference + : waistCircumference // ignore: cast_nullable_to_non_nullable + as String, + hipCircumference: null == hipCircumference + ? _value.hipCircumference + : hipCircumference // ignore: cast_nullable_to_non_nullable + as String, + bloodPressureUp: null == bloodPressureUp + ? _value.bloodPressureUp + : bloodPressureUp // ignore: cast_nullable_to_non_nullable + as String, + bloodPressureDown: null == bloodPressureDown + ? _value.bloodPressureDown + : bloodPressureDown // ignore: cast_nullable_to_non_nullable + as String, + hasHypo: null == hasHypo + ? _value.hasHypo + : hasHypo // ignore: cast_nullable_to_non_nullable + as String, + hasHyper: null == hasHyper + ? _value.hasHyper + : hasHyper // ignore: cast_nullable_to_non_nullable + as String, + aboutAllergy: null == aboutAllergy + ? _value.aboutAllergy + : aboutAllergy // ignore: cast_nullable_to_non_nullable + as String, + aboutTakingPils: null == aboutTakingPils + ? _value.aboutTakingPils + : aboutTakingPils // ignore: cast_nullable_to_non_nullable + as String, + aboutSportHobbies: null == aboutSportHobbies + ? _value.aboutSportHobbies + : aboutSportHobbies // ignore: cast_nullable_to_non_nullable + as String, + favoriteFoods: null == favoriteFoods + ? _value.favoriteFoods + : favoriteFoods // ignore: cast_nullable_to_non_nullable + as String, + unfavoriteFoods: null == unfavoriteFoods + ? _value.unfavoriteFoods + : unfavoriteFoods // ignore: cast_nullable_to_non_nullable + as String, + additionalInfo: null == additionalInfo + ? _value.additionalInfo + : additionalInfo // ignore: cast_nullable_to_non_nullable + as String, + activityCoefficient: null == activityCoefficient + ? _value.activityCoefficient + : activityCoefficient // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$UserRegistrationSheetImpl implements _UserRegistrationSheet { + const _$UserRegistrationSheetImpl( + {required this.name, + @JsonKey(name: 'first_name') required this.firstName, + @JsonKey(name: 'last') required this.lastName, + required this.email, + required this.password, + @JsonKey(name: 'password_confirmation') + required this.passwordConfirmation, + @JsonKey(name: 'terms') this.termsAccepted = 'accepted', + required this.birthdate, + required this.gender, + required this.country, + required this.city, + required this.lang, + required this.weight, + required this.height, + @JsonKey(name: 'chest_circumference') required this.chestCircumference, + @JsonKey(name: 'waist_circumference') required this.waistCircumference, + @JsonKey(name: 'hip_circumference') required this.hipCircumference, + @JsonKey(name: 'blood_pressure_up') required this.bloodPressureUp, + @JsonKey(name: 'blood_pressure_down') required this.bloodPressureDown, + @JsonKey(name: 'has_hypo') required this.hasHypo, + @JsonKey(name: 'has_hyper') required this.hasHyper, + @JsonKey(name: 'about_alergy') required this.aboutAllergy, + @JsonKey(name: 'about_taking_pils') required this.aboutTakingPils, + @JsonKey(name: 'about_sport_hobbies') required this.aboutSportHobbies, + @JsonKey(name: 'favorite_foods') required this.favoriteFoods, + @JsonKey(name: 'unfavorite_foods') required this.unfavoriteFoods, + @JsonKey(name: 'additional_info') required this.additionalInfo, + @JsonKey(name: 'activity_coefficient') this.activityCoefficient = '1.2'}); + + factory _$UserRegistrationSheetImpl.fromJson(Map json) => + _$$UserRegistrationSheetImplFromJson(json); + + @override + final String name; + @override + @JsonKey(name: 'first_name') + final String firstName; + @override + @JsonKey(name: 'last') + final String lastName; + @override + final String email; + @override + final String password; + @override + @JsonKey(name: 'password_confirmation') + final String passwordConfirmation; + @override + @JsonKey(name: 'terms') + final String termsAccepted; + @override + final String birthdate; + @override + final String gender; + @override + final String country; + @override + final String city; + @override + final String lang; + @override + final String weight; + @override + final String height; + @override + @JsonKey(name: 'chest_circumference') + final String chestCircumference; + @override + @JsonKey(name: 'waist_circumference') + final String waistCircumference; + @override + @JsonKey(name: 'hip_circumference') + final String hipCircumference; + @override + @JsonKey(name: 'blood_pressure_up') + final String bloodPressureUp; + @override + @JsonKey(name: 'blood_pressure_down') + final String bloodPressureDown; + @override + @JsonKey(name: 'has_hypo') + final String hasHypo; + @override + @JsonKey(name: 'has_hyper') + final String hasHyper; + @override + @JsonKey(name: 'about_alergy') + final String aboutAllergy; + @override + @JsonKey(name: 'about_taking_pils') + final String aboutTakingPils; + @override + @JsonKey(name: 'about_sport_hobbies') + final String aboutSportHobbies; + @override + @JsonKey(name: 'favorite_foods') + final String favoriteFoods; + @override + @JsonKey(name: 'unfavorite_foods') + final String unfavoriteFoods; + @override + @JsonKey(name: 'additional_info') + final String additionalInfo; + @override + @JsonKey(name: 'activity_coefficient') + final String activityCoefficient; + + @override + String toString() { + return 'UserRegistrationSheet(name: $name, firstName: $firstName, lastName: $lastName, email: $email, password: $password, passwordConfirmation: $passwordConfirmation, termsAccepted: $termsAccepted, birthdate: $birthdate, gender: $gender, country: $country, city: $city, lang: $lang, weight: $weight, height: $height, chestCircumference: $chestCircumference, waistCircumference: $waistCircumference, hipCircumference: $hipCircumference, bloodPressureUp: $bloodPressureUp, bloodPressureDown: $bloodPressureDown, hasHypo: $hasHypo, hasHyper: $hasHyper, aboutAllergy: $aboutAllergy, aboutTakingPils: $aboutTakingPils, aboutSportHobbies: $aboutSportHobbies, favoriteFoods: $favoriteFoods, unfavoriteFoods: $unfavoriteFoods, additionalInfo: $additionalInfo, activityCoefficient: $activityCoefficient)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UserRegistrationSheetImpl && + (identical(other.name, name) || other.name == name) && + (identical(other.firstName, firstName) || + other.firstName == firstName) && + (identical(other.lastName, lastName) || + other.lastName == lastName) && + (identical(other.email, email) || other.email == email) && + (identical(other.password, password) || + other.password == password) && + (identical(other.passwordConfirmation, passwordConfirmation) || + other.passwordConfirmation == passwordConfirmation) && + (identical(other.termsAccepted, termsAccepted) || + other.termsAccepted == termsAccepted) && + (identical(other.birthdate, birthdate) || + other.birthdate == birthdate) && + (identical(other.gender, gender) || other.gender == gender) && + (identical(other.country, country) || other.country == country) && + (identical(other.city, city) || other.city == city) && + (identical(other.lang, lang) || other.lang == lang) && + (identical(other.weight, weight) || other.weight == weight) && + (identical(other.height, height) || other.height == height) && + (identical(other.chestCircumference, chestCircumference) || + other.chestCircumference == chestCircumference) && + (identical(other.waistCircumference, waistCircumference) || + other.waistCircumference == waistCircumference) && + (identical(other.hipCircumference, hipCircumference) || + other.hipCircumference == hipCircumference) && + (identical(other.bloodPressureUp, bloodPressureUp) || + other.bloodPressureUp == bloodPressureUp) && + (identical(other.bloodPressureDown, bloodPressureDown) || + other.bloodPressureDown == bloodPressureDown) && + (identical(other.hasHypo, hasHypo) || other.hasHypo == hasHypo) && + (identical(other.hasHyper, hasHyper) || + other.hasHyper == hasHyper) && + (identical(other.aboutAllergy, aboutAllergy) || + other.aboutAllergy == aboutAllergy) && + (identical(other.aboutTakingPils, aboutTakingPils) || + other.aboutTakingPils == aboutTakingPils) && + (identical(other.aboutSportHobbies, aboutSportHobbies) || + other.aboutSportHobbies == aboutSportHobbies) && + (identical(other.favoriteFoods, favoriteFoods) || + other.favoriteFoods == favoriteFoods) && + (identical(other.unfavoriteFoods, unfavoriteFoods) || + other.unfavoriteFoods == unfavoriteFoods) && + (identical(other.additionalInfo, additionalInfo) || + other.additionalInfo == additionalInfo) && + (identical(other.activityCoefficient, activityCoefficient) || + other.activityCoefficient == activityCoefficient)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hashAll([ + runtimeType, + name, + firstName, + lastName, + email, + password, + passwordConfirmation, + termsAccepted, + birthdate, + gender, + country, + city, + lang, + weight, + height, + chestCircumference, + waistCircumference, + hipCircumference, + bloodPressureUp, + bloodPressureDown, + hasHypo, + hasHyper, + aboutAllergy, + aboutTakingPils, + aboutSportHobbies, + favoriteFoods, + unfavoriteFoods, + additionalInfo, + activityCoefficient + ]); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> + get copyWith => __$$UserRegistrationSheetImplCopyWithImpl< + _$UserRegistrationSheetImpl>(this, _$identity); + + @override + Map toJson() { + return _$$UserRegistrationSheetImplToJson( + this, + ); + } +} + +abstract class _UserRegistrationSheet implements UserRegistrationSheet { + const factory _UserRegistrationSheet( + {required final String name, + @JsonKey(name: 'first_name') required final String firstName, + @JsonKey(name: 'last') required final String lastName, + required final String email, + required final String password, + @JsonKey(name: 'password_confirmation') + required final String passwordConfirmation, + @JsonKey(name: 'terms') final String termsAccepted, + required final String birthdate, + required final String gender, + required final String country, + required final String city, + required final String lang, + required final String weight, + required final String height, + @JsonKey(name: 'chest_circumference') + required final String chestCircumference, + @JsonKey(name: 'waist_circumference') + required final String waistCircumference, + @JsonKey(name: 'hip_circumference') + required final String hipCircumference, + @JsonKey(name: 'blood_pressure_up') required final String bloodPressureUp, + @JsonKey(name: 'blood_pressure_down') + required final String bloodPressureDown, + @JsonKey(name: 'has_hypo') required final String hasHypo, + @JsonKey(name: 'has_hyper') required final String hasHyper, + @JsonKey(name: 'about_alergy') required final String aboutAllergy, + @JsonKey(name: 'about_taking_pils') required final String aboutTakingPils, + @JsonKey(name: 'about_sport_hobbies') + required final String aboutSportHobbies, + @JsonKey(name: 'favorite_foods') required final String favoriteFoods, + @JsonKey(name: 'unfavorite_foods') required final String unfavoriteFoods, + @JsonKey(name: 'additional_info') required final String additionalInfo, + @JsonKey(name: 'activity_coefficient') + final String activityCoefficient}) = _$UserRegistrationSheetImpl; + + factory _UserRegistrationSheet.fromJson(Map json) = + _$UserRegistrationSheetImpl.fromJson; + + @override + String get name; + @override + @JsonKey(name: 'first_name') + String get firstName; + @override + @JsonKey(name: 'last') + String get lastName; + @override + String get email; + @override + String get password; + @override + @JsonKey(name: 'password_confirmation') + String get passwordConfirmation; + @override + @JsonKey(name: 'terms') + String get termsAccepted; + @override + String get birthdate; + @override + String get gender; + @override + String get country; + @override + String get city; + @override + String get lang; + @override + String get weight; + @override + String get height; + @override + @JsonKey(name: 'chest_circumference') + String get chestCircumference; + @override + @JsonKey(name: 'waist_circumference') + String get waistCircumference; + @override + @JsonKey(name: 'hip_circumference') + String get hipCircumference; + @override + @JsonKey(name: 'blood_pressure_up') + String get bloodPressureUp; + @override + @JsonKey(name: 'blood_pressure_down') + String get bloodPressureDown; + @override + @JsonKey(name: 'has_hypo') + String get hasHypo; + @override + @JsonKey(name: 'has_hyper') + String get hasHyper; + @override + @JsonKey(name: 'about_alergy') + String get aboutAllergy; + @override + @JsonKey(name: 'about_taking_pils') + String get aboutTakingPils; + @override + @JsonKey(name: 'about_sport_hobbies') + String get aboutSportHobbies; + @override + @JsonKey(name: 'favorite_foods') + String get favoriteFoods; + @override + @JsonKey(name: 'unfavorite_foods') + String get unfavoriteFoods; + @override + @JsonKey(name: 'additional_info') + String get additionalInfo; + @override + @JsonKey(name: 'activity_coefficient') + String get activityCoefficient; + @override + @JsonKey(ignore: true) + _$$UserRegistrationSheetImplCopyWith<_$UserRegistrationSheetImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/data/models/userRegistrationModel/user_registration_model.g.dart b/lib/data/models/userRegistrationModel/user_registration_model.g.dart new file mode 100644 index 0000000..8eafe71 --- /dev/null +++ b/lib/data/models/userRegistrationModel/user_registration_model.g.dart @@ -0,0 +1,73 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'user_registration_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$UserRegistrationSheetImpl _$$UserRegistrationSheetImplFromJson( + Map json) => + _$UserRegistrationSheetImpl( + name: json['name'] as String, + firstName: json['first_name'] as String, + lastName: json['last'] as String, + email: json['email'] as String, + password: json['password'] as String, + passwordConfirmation: json['password_confirmation'] as String, + termsAccepted: json['terms'] as String? ?? 'accepted', + birthdate: json['birthdate'] as String, + gender: json['gender'] as String, + country: json['country'] as String, + city: json['city'] as String, + lang: json['lang'] as String, + weight: json['weight'] as String, + height: json['height'] as String, + chestCircumference: json['chest_circumference'] as String, + waistCircumference: json['waist_circumference'] as String, + hipCircumference: json['hip_circumference'] as String, + bloodPressureUp: json['blood_pressure_up'] as String, + bloodPressureDown: json['blood_pressure_down'] as String, + hasHypo: json['has_hypo'] as String, + hasHyper: json['has_hyper'] as String, + aboutAllergy: json['about_alergy'] as String, + aboutTakingPils: json['about_taking_pils'] as String, + aboutSportHobbies: json['about_sport_hobbies'] as String, + favoriteFoods: json['favorite_foods'] as String, + unfavoriteFoods: json['unfavorite_foods'] as String, + additionalInfo: json['additional_info'] as String, + activityCoefficient: json['activity_coefficient'] as String? ?? '1.2', + ); + +Map _$$UserRegistrationSheetImplToJson( + _$UserRegistrationSheetImpl instance) => + { + 'name': instance.name, + 'first_name': instance.firstName, + 'last': instance.lastName, + 'email': instance.email, + 'password': instance.password, + 'password_confirmation': instance.passwordConfirmation, + 'terms': instance.termsAccepted, + 'birthdate': instance.birthdate, + 'gender': instance.gender, + 'country': instance.country, + 'city': instance.city, + 'lang': instance.lang, + 'weight': instance.weight, + 'height': instance.height, + 'chest_circumference': instance.chestCircumference, + 'waist_circumference': instance.waistCircumference, + 'hip_circumference': instance.hipCircumference, + 'blood_pressure_up': instance.bloodPressureUp, + 'blood_pressure_down': instance.bloodPressureDown, + 'has_hypo': instance.hasHypo, + 'has_hyper': instance.hasHyper, + 'about_alergy': instance.aboutAllergy, + 'about_taking_pils': instance.aboutTakingPils, + 'about_sport_hobbies': instance.aboutSportHobbies, + 'favorite_foods': instance.favoriteFoods, + 'unfavorite_foods': instance.unfavoriteFoods, + 'additional_info': instance.additionalInfo, + 'activity_coefficient': instance.activityCoefficient, + }; 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 bf421e7..5e59454 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart @@ -4,7 +4,7 @@ import 'package:eatvio_app/features/registration/presentation/bloc/registration_ import 'package:eatvio_app/presentation/registration/language_select_screen/models/language_select_model.dart'; class RegistrationCubit extends Cubit { - RegistrationCubit() : super(RegistrationState.loaded(sheet: LanguageSelectModel().userRegistrationSheet)); + RegistrationCubit() : super(RegistrationState(sheet: LanguageSelectModel().userRegistrationSheet)); - updateSheet(UserRegistrationSheet sheet) => emit(RegistrationState.loaded(sheet: sheet)); + updateSheet(UserRegistrationSheet sheet) => emit(RegistrationState(sheet: sheet)); } diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart index b6ea767..d1e2090 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.dart @@ -4,10 +4,8 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'registration_state.freezed.dart'; @freezed -abstract class RegistrationState with _$RegistrationState { - const factory RegistrationState() = _RegistrationState; - - const factory RegistrationState.loaded({ +class RegistrationState with _$RegistrationState { + const factory RegistrationState({ required UserRegistrationSheet sheet, - }) = RegistrationStateLoaded; + }) = _RegistrationState; } diff --git a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart index 01b2382..dcb4923 100644 --- a/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart +++ b/lib/features/registration/presentation/bloc/registration_cubit/registration_state.freezed.dart @@ -16,43 +16,10 @@ final _privateConstructorUsedError = UnsupportedError( /// @nodoc mixin _$RegistrationState { - @optionalTypeArgs - TResult when( - TResult Function() $default, { - required TResult Function(UserRegistrationSheet sheet) loaded, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function()? $default, { - TResult? Function(UserRegistrationSheet sheet)? loaded, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen( - TResult Function()? $default, { - TResult Function(UserRegistrationSheet sheet)? loaded, - required TResult orElse(), - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map( - TResult Function(_RegistrationState value) $default, { - required TResult Function(RegistrationStateLoaded value) loaded, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_RegistrationState value)? $default, { - TResult? Function(RegistrationStateLoaded value)? loaded, - }) => - throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap( - TResult Function(_RegistrationState value)? $default, { - TResult Function(RegistrationStateLoaded value)? loaded, - required TResult orElse(), - }) => + UserRegistrationSheet get sheet => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $RegistrationStateCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -61,6 +28,10 @@ abstract class $RegistrationStateCopyWith<$Res> { factory $RegistrationStateCopyWith( RegistrationState value, $Res Function(RegistrationState) then) = _$RegistrationStateCopyWithImpl<$Res, RegistrationState>; + @useResult + $Res call({UserRegistrationSheet sheet}); + + $UserRegistrationSheetCopyWith<$Res> get sheet; } /// @nodoc @@ -72,13 +43,41 @@ class _$RegistrationStateCopyWithImpl<$Res, $Val extends RegistrationState> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? sheet = null, + }) { + return _then(_value.copyWith( + sheet: null == sheet + ? _value.sheet + : sheet // ignore: cast_nullable_to_non_nullable + as UserRegistrationSheet, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $UserRegistrationSheetCopyWith<$Res> get sheet { + return $UserRegistrationSheetCopyWith<$Res>(_value.sheet, (value) { + return _then(_value.copyWith(sheet: value) as $Val); + }); + } } /// @nodoc -abstract class _$$RegistrationStateImplCopyWith<$Res> { +abstract class _$$RegistrationStateImplCopyWith<$Res> + implements $RegistrationStateCopyWith<$Res> { factory _$$RegistrationStateImplCopyWith(_$RegistrationStateImpl value, $Res Function(_$RegistrationStateImpl) then) = __$$RegistrationStateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({UserRegistrationSheet sheet}); + + @override + $UserRegistrationSheetCopyWith<$Res> get sheet; } /// @nodoc @@ -88,119 +87,13 @@ class __$$RegistrationStateImplCopyWithImpl<$Res> __$$RegistrationStateImplCopyWithImpl(_$RegistrationStateImpl _value, $Res Function(_$RegistrationStateImpl) _then) : super(_value, _then); -} - -/// @nodoc - -class _$RegistrationStateImpl implements _RegistrationState { - const _$RegistrationStateImpl(); - - @override - String toString() { - return 'RegistrationState()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$RegistrationStateImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when( - TResult Function() $default, { - required TResult Function(UserRegistrationSheet sheet) loaded, - }) { - return $default(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function()? $default, { - TResult? Function(UserRegistrationSheet sheet)? loaded, - }) { - return $default?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen( - TResult Function()? $default, { - TResult Function(UserRegistrationSheet sheet)? loaded, - required TResult orElse(), - }) { - if ($default != null) { - return $default(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map( - TResult Function(_RegistrationState value) $default, { - required TResult Function(RegistrationStateLoaded value) loaded, - }) { - return $default(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_RegistrationState value)? $default, { - TResult? Function(RegistrationStateLoaded value)? loaded, - }) { - return $default?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap( - TResult Function(_RegistrationState value)? $default, { - TResult Function(RegistrationStateLoaded value)? loaded, - required TResult orElse(), - }) { - if ($default != null) { - return $default(this); - } - return orElse(); - } -} - -abstract class _RegistrationState implements RegistrationState { - const factory _RegistrationState() = _$RegistrationStateImpl; -} - -/// @nodoc -abstract class _$$RegistrationStateLoadedImplCopyWith<$Res> { - factory _$$RegistrationStateLoadedImplCopyWith( - _$RegistrationStateLoadedImpl value, - $Res Function(_$RegistrationStateLoadedImpl) then) = - __$$RegistrationStateLoadedImplCopyWithImpl<$Res>; - @useResult - $Res call({UserRegistrationSheet sheet}); -} - -/// @nodoc -class __$$RegistrationStateLoadedImplCopyWithImpl<$Res> - extends _$RegistrationStateCopyWithImpl<$Res, _$RegistrationStateLoadedImpl> - implements _$$RegistrationStateLoadedImplCopyWith<$Res> { - __$$RegistrationStateLoadedImplCopyWithImpl( - _$RegistrationStateLoadedImpl _value, - $Res Function(_$RegistrationStateLoadedImpl) _then) - : super(_value, _then); @pragma('vm:prefer-inline') @override $Res call({ Object? sheet = null, }) { - return _then(_$RegistrationStateLoadedImpl( + return _then(_$RegistrationStateImpl( sheet: null == sheet ? _value.sheet : sheet // ignore: cast_nullable_to_non_nullable @@ -211,22 +104,22 @@ class __$$RegistrationStateLoadedImplCopyWithImpl<$Res> /// @nodoc -class _$RegistrationStateLoadedImpl implements RegistrationStateLoaded { - const _$RegistrationStateLoadedImpl({required this.sheet}); +class _$RegistrationStateImpl implements _RegistrationState { + const _$RegistrationStateImpl({required this.sheet}); @override final UserRegistrationSheet sheet; @override String toString() { - return 'RegistrationState.loaded(sheet: $sheet)'; + return 'RegistrationState(sheet: $sheet)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$RegistrationStateLoadedImpl && + other is _$RegistrationStateImpl && (identical(other.sheet, sheet) || other.sheet == sheet)); } @@ -236,80 +129,19 @@ class _$RegistrationStateLoadedImpl implements RegistrationStateLoaded { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$RegistrationStateLoadedImplCopyWith<_$RegistrationStateLoadedImpl> - get copyWith => __$$RegistrationStateLoadedImplCopyWithImpl< - _$RegistrationStateLoadedImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when( - TResult Function() $default, { - required TResult Function(UserRegistrationSheet sheet) loaded, - }) { - return loaded(sheet); - } - - @override - @optionalTypeArgs - TResult? whenOrNull( - TResult? Function()? $default, { - TResult? Function(UserRegistrationSheet sheet)? loaded, - }) { - return loaded?.call(sheet); - } - - @override - @optionalTypeArgs - TResult maybeWhen( - TResult Function()? $default, { - TResult Function(UserRegistrationSheet sheet)? loaded, - required TResult orElse(), - }) { - if (loaded != null) { - return loaded(sheet); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map( - TResult Function(_RegistrationState value) $default, { - required TResult Function(RegistrationStateLoaded value) loaded, - }) { - return loaded(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull( - TResult? Function(_RegistrationState value)? $default, { - TResult? Function(RegistrationStateLoaded value)? loaded, - }) { - return loaded?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap( - TResult Function(_RegistrationState value)? $default, { - TResult Function(RegistrationStateLoaded value)? loaded, - required TResult orElse(), - }) { - if (loaded != null) { - return loaded(this); - } - return orElse(); - } + _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => + __$$RegistrationStateImplCopyWithImpl<_$RegistrationStateImpl>( + this, _$identity); } -abstract class RegistrationStateLoaded implements RegistrationState { - const factory RegistrationStateLoaded( - {required final UserRegistrationSheet sheet}) = - _$RegistrationStateLoadedImpl; +abstract class _RegistrationState implements RegistrationState { + const factory _RegistrationState( + {required final UserRegistrationSheet sheet}) = _$RegistrationStateImpl; + @override UserRegistrationSheet get sheet; + @override @JsonKey(ignore: true) - _$$RegistrationStateLoadedImplCopyWith<_$RegistrationStateLoadedImpl> - get copyWith => throw _privateConstructorUsedError; + _$$RegistrationStateImplCopyWith<_$RegistrationStateImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index d181e3c..3ee6d0c 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -20,6 +20,7 @@ import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; +import 'package:validators/validators.dart'; class RegistrationScreen extends StatefulWidget { const RegistrationScreen({super.key}); @@ -64,7 +65,6 @@ class _RegistrationScreenState extends State { create: (BuildContext context) => RegistrationCubit(), child: BlocBuilder( builder: (BuildContext context, RegistrationState state) { - (state as RegistrationStateLoaded); return PopScope( canPop: false, onPopInvoked: (_) => _showPopDialog(), @@ -112,12 +112,14 @@ class _RegistrationScreenState extends State { ), backgroundColor: appTheme.blueA400, onPressed: () { - setState(() { - pageController.nextPage( - duration: const Duration(milliseconds: 350), - curve: Curves.easeInOut, - ); - }); + if (canGoNext(state)) { + setState(() { + pageController.nextPage( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + ); + }); + } }, label: Text( 'Продолжить', @@ -169,21 +171,21 @@ class _RegistrationScreenState extends State { }); }, children: [ - LanguageSelectScreen.builder(context), - CredentialsScreen.builder(context, state.sheet), - NameScreen.builder(context, state.sheet), - GenderScreen.builder(context, state.sheet), - DateOfBirthScreen.builder(context, state.sheet), - CityOfLivingScreen.builder(context, state.sheet), - BodyCircumferencesScreen.builder(context, state.sheet), - WeightScreen.builder(context, state.sheet), - HeightScreen.builder(context, state.sheet), - BloodPressureScreen.builder(context, state.sheet), - AllergiesScreen.builder(context, state.sheet), - MedicineIntakeScreen.builder(context, state.sheet), - FavoriteSportsScreen.builder(context, state.sheet), - FavoriteFoodsScreen.builder(context, state.sheet), - AdditionalInformationScreen.builder(context, state.sheet), + LanguageSelectScreen(sheet: context.read().state.sheet), + CredentialsScreen(sheet: context.read().state.sheet), + NameScreen(), + GenderScreen(), + DateOfBirthScreen(), + CityOfLivingScreen(), + BodyCircumferencesScreen(), + WeightScreen(), + HeightScreen(), + BloodPressureScreen(), + AllergiesScreen(), + MedicineIntakeScreen(), + FavoriteSportsScreen(), + FavoriteFoodsScreen(), + AdditionalInformationScreen(), ], ), ), @@ -192,4 +194,71 @@ class _RegistrationScreenState extends State { ), ); } + + bool canGoNext(state) { + switch (step) { + case 2: + List errors = validateFields(state.sheet.email, state.sheet.name, state.sheet.password, state.sheet.passwordConfirmation); + if (errors.isEmpty) { + return true; + } 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: () => Navigator.pop(context), + child: Text('OK'), + ), + ], + ), + ); + return false; + } + default: + return true; + } + } + + List validateFields(String email, String name, String password, String passwordConfirmation) { + List errors = []; + + if (!isEmail(email)) { + errors.add('email_invalid'.tr); + } + + if (email.isEmpty) { + errors.add('email_empty'.tr); + } + + if (name.length < 6) { + errors.add('name_short'.tr); + } + + if (name.isEmpty) { + errors.add('name_empty'.tr); + } + + if (password.isEmpty) { + errors.add('name_empty'.tr); + } + + if (password.length < 6) { + errors.add('password_short'.tr); + } + + if (password != passwordConfirmation) { + errors.add('password_confirmation_mismatch'.tr); + } + + return errors; + } } 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 b39743e..c12af1f 100644 --- a/lib/presentation/registration/additional_information_screen/additional_information_screen.dart +++ b/lib/presentation/registration/additional_information_screen/additional_information_screen.dart @@ -52,7 +52,7 @@ class AdditionalInformationScreen extends StatelessWidget { onTapFinish(AdditionalInformationState state, BuildContext context) { return () async { UserRegistrationSheet sheet = state.additionalInformationModelObj!.userRegistrationSheet; - sheet.additionalInfo = state.editTextController!.text; + // sheet.additionalInfo = state.editTextController!.text; final response = await http.post( Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'), diff --git a/lib/presentation/registration/allergies_screen/allergies_screen.dart b/lib/presentation/registration/allergies_screen/allergies_screen.dart index 51c5e6a..7a2ac1c 100644 --- a/lib/presentation/registration/allergies_screen/allergies_screen.dart +++ b/lib/presentation/registration/allergies_screen/allergies_screen.dart @@ -68,7 +68,7 @@ class _AllergiesScreenState extends State { onTapContinue(AllergiesState state, BuildContext context) { return () { UserRegistrationSheet sheet = state.allergiesModelObj!.userRegistrationSheet; - sheet.aboutAllergy = state.enterInformationController!.text; + // sheet.aboutAllergy = state.enterInformationController!.text; GoRouter.of(context).goNamed('medicineIntakeScreen', extra: sheet); }; } 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 4741654..2fda1b5 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 @@ -18,9 +18,9 @@ class BloodPressureBloc extends Bloc { Emitter emit, ) { if (event.value.id == 1) { - state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = '1'; + // state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = '1'; } else { - state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = '0'; + // state.bloodPressureModelObj!.userRegistrationSheet.hasHyper = '0'; } emit(state.copyWith(selectedHyperValue: event.value)); } @@ -30,9 +30,9 @@ class BloodPressureBloc extends Bloc { Emitter emit, ) { if (event.value.id == 1) { - state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = '1'; + // state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = '1'; } else { - state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = '0'; + // state.bloodPressureModelObj!.userRegistrationSheet.hasHypo = '0'; } emit(state.copyWith(selectedHypoValue: event.value)); } 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 1ad3636..d8efedd 100644 --- a/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart +++ b/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart @@ -159,8 +159,8 @@ class _BloodPressureScreenState extends State { 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; + // sheet.bloodPressureUp = state.upPressureController!.text; + // sheet.bloodPressureDown = state.downPressureController!.text; AppRouter.navigatorKey.currentContext?.goNamed('allergiesScreen', extra: sheet); } else { String errorMessage = ''; 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 d9f0861..60733e3 100644 --- a/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart +++ b/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart @@ -36,7 +36,7 @@ class _BodyCircumferencesScreenState extends State { child: Column( children: [ Text("initial_measurements".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 93.v), + SizedBox(height: 16.v), Column( children: [ Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), @@ -94,9 +94,9 @@ class _BodyCircumferencesScreenState extends State { validateFields(state.chestCircumferenceController!.text, state.waistCircumferenceController!.text, state.hipCircumferenceController!.text); if (errors.isEmpty) { UserRegistrationSheet sheet = state.bodyCircumferencesModelObj!.userRegistrationSheet; - sheet.chestCircumference = state.chestCircumferenceController!.text; - sheet.waistCircumference = state.waistCircumferenceController!.text; - sheet.hipCircumference = state.hipCircumferenceController!.text; + // sheet.chestCircumference = state.chestCircumferenceController!.text; + // sheet.waistCircumference = state.waistCircumferenceController!.text; + // sheet.hipCircumference = state.hipCircumferenceController!.text; GoRouter.of(context).goNamed('weightScreen', extra: sheet); } else { String errorMessage = ''; diff --git a/lib/presentation/registration/city_of_living_screen/bloc/city_of_living_bloc.dart b/lib/presentation/registration/city_of_living_screen/bloc/city_of_living_bloc.dart index 71864db..e642961 100644 --- a/lib/presentation/registration/city_of_living_screen/bloc/city_of_living_bloc.dart +++ b/lib/presentation/registration/city_of_living_screen/bloc/city_of_living_bloc.dart @@ -27,7 +27,7 @@ class CityOfLivingBloc extends Bloc { Emitter emit, ) { emit(state.copyWith(selectedDropDownValue: event.value)); - state.cityOfLivingModelObj?.userRegistrationSheet.country = + // state.cityOfLivingModelObj?.userRegistrationSheet.country = event.value.title; } 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 0d35f1f..f5ee8a8 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 @@ -28,7 +28,6 @@ class CityOfLivingScreen extends StatelessWidget { padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), child: Column( children: [ - SizedBox(height: 39.v), Text("place_of_living".tr, style: theme.textTheme.headlineSmall), SizedBox(height: 39.v), Text("country".tr, style: theme.textTheme.bodyLarge), diff --git a/lib/presentation/registration/credentials_screen/credentials_screen.dart b/lib/presentation/registration/credentials_screen/credentials_screen.dart index d9e15d3..ec7809c 100644 --- a/lib/presentation/registration/credentials_screen/credentials_screen.dart +++ b/lib/presentation/registration/credentials_screen/credentials_screen.dart @@ -1,23 +1,34 @@ -import 'package:go_router/go_router.dart'; - -import 'bloc/credentials_bloc.dart'; -import 'models/credentials_model.dart'; -import 'package:eatvio_app/core/app_export.dart'; -import 'package:validators/validators.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/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; -class CredentialsScreen extends StatelessWidget { - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => CredentialsBloc( - CredentialsState( - credentialsModelObj: CredentialsModel(userRegistrationSheet: sheet), - ), - )..add(CredentialsInitialEvent()), - child: CredentialsScreen(), - ); +class CredentialsScreen extends StatefulWidget { + final UserRegistrationSheet sheet; + + const CredentialsScreen({super.key, required this.sheet}); + + @override + State createState() => _CredentialsScreenState(); +} + +class _CredentialsScreenState extends State { + final emailController = TextEditingController(); + + final nameController = TextEditingController(); + + final passwordController = TextEditingController(); + + final passwordConfirmationController = TextEditingController(); + + @override + void initState() { + super.initState(); + emailController.text = widget.sheet.email; + nameController.text = widget.sheet.name; + passwordController.text = widget.sheet.password; + passwordConfirmationController.text = widget.sheet.passwordConfirmation; } @override @@ -34,131 +45,51 @@ class CredentialsScreen extends StatelessWidget { SizedBox(height: 16.v), Text("email".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.emailController, - builder: (context, emailController) { - return CustomTextFormField(controller: emailController, textInputAction: TextInputAction.done); + CustomTextFormField( + controller: emailController, + textInputAction: TextInputAction.done, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(email: newValue)); }, ), SizedBox(height: 22.v), Text("username".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.nameController, - builder: (context, nameController) { - return CustomTextFormField(controller: nameController, textInputAction: TextInputAction.done); + CustomTextFormField( + controller: nameController, + textInputAction: TextInputAction.done, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(name: newValue)); }, ), SizedBox(height: 19.v), Text("password".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 5.v), - BlocSelector( - selector: (state) => state.passwordController, - builder: (context, passwordController) { - return CustomTextFormField( - obscureText: true, - controller: passwordController, - ); + CustomTextFormField( + obscureText: true, + controller: passwordController, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(password: newValue)); }, ), SizedBox(height: 21.v), Text("password_confirmation".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.passwordConfirmationController, - builder: (context, passwordConfirmationController) { - return CustomTextFormField(obscureText: true, controller: passwordConfirmationController, textInputAction: TextInputAction.done); + CustomTextFormField( + obscureText: true, + controller: passwordConfirmationController, + textInputAction: TextInputAction.done, + onChanged: (newValue) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(passwordConfirmation: newValue)); }, ), - // 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(CredentialsState state, BuildContext context) { - return () { - List errors = - validateFields(state.emailController!.text, state.nameController!.text, state.passwordController!.text, state.passwordConfirmationController!.text); - if (errors.isEmpty) { - 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', 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); - }; - } - - - List validateFields(String email, String name, String password, String passwordConfirmation) { - List errors = []; - - if (!isEmail(email)) { - errors.add('email_invalid'.tr); - } - - if (email.isEmpty) { - errors.add('email_empty'.tr); - } - - if (name.length < 6) { - errors.add('name_short'.tr); - } - - if (name.isEmpty) { - errors.add('name_empty'.tr); - } - - if (password.isEmpty) { - errors.add('name_empty'.tr); - } - - if (password.length < 6) { - errors.add('password_short'.tr); - } - - if (password != passwordConfirmation) { - errors.add('password_confirmation_mismatch'.tr); - } - - return errors; - } } 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 432a5be..0952a66 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 @@ -65,7 +65,7 @@ class _DateOfBirthScreenState extends State { onTapContinue(DateOfBirthState state, BuildContext context) { return () { UserRegistrationSheet sheet = state.dateOfBirthModelObj!.userRegistrationSheet; - sheet.birthdate = selectedDate.toString(); + // sheet.birthdate = selectedDate.toString(); GoRouter.of(context).goNamed('cityOfLivingScreen', extra: sheet); }; } 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 a1015d7..0db859d 100644 --- a/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart +++ b/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart @@ -81,8 +81,8 @@ class _FavoriteFoodsScreenState extends State { onTapContinue(FavoriteFoodsState state, BuildContext context) { return () { UserRegistrationSheet sheet = state.favoriteFoodsModelObj!.userRegistrationSheet; - sheet.favoriteFoods = state.favoriteFoodsController!.text; - sheet.unfavoriteFoods = state.unfavoriteFoodsController!.text; + // sheet.favoriteFoods = state.favoriteFoodsController!.text; + // sheet.unfavoriteFoods = state.unfavoriteFoodsController!.text; GoRouter.of(context).goNamed('additionalInformationScreen', extra: sheet); }; } 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 5a8f3f3..5d8be5d 100644 --- a/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart +++ b/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart @@ -70,7 +70,7 @@ class _FavoriteSportsScreenState extends State { onTapContinue(FavoriteSportsState state, BuildContext context) { return () { UserRegistrationSheet sheet = state.favoriteSportsModelObj!.userRegistrationSheet; - sheet.aboutSportHobbies = state.enterinformationController!.text; + // sheet.aboutSportHobbies = state.enterinformationController!.text; GoRouter.of(context).goNamed('favoriteFoodsScreen', extra: sheet); }; } diff --git a/lib/presentation/registration/gender_screen/bloc/gender_bloc.dart b/lib/presentation/registration/gender_screen/bloc/gender_bloc.dart index 5f614c2..fe30581 100644 --- a/lib/presentation/registration/gender_screen/bloc/gender_bloc.dart +++ b/lib/presentation/registration/gender_screen/bloc/gender_bloc.dart @@ -24,6 +24,6 @@ class GenderBloc extends Bloc { Emitter emit, ) { emit(state.copyWith(selectedRadioValue: event.value)); - state.genderModelObj?.userRegistrationSheet.gender = event.value; + // state.genderModelObj?.userRegistrationSheet.gender = event.value; } } diff --git a/lib/presentation/registration/gender_screen/gender_screen.dart b/lib/presentation/registration/gender_screen/gender_screen.dart index 72f8f5c..5ffa6be 100644 --- a/lib/presentation/registration/gender_screen/gender_screen.dart +++ b/lib/presentation/registration/gender_screen/gender_screen.dart @@ -80,7 +80,7 @@ class _GenderScreenState extends State { onTapNext(GenderState state, BuildContext context) { return () { UserRegistrationSheet sheet = state.genderModelObj!.userRegistrationSheet; - sheet.gender = state.selectedRadioValue!; + // sheet.gender = state.selectedRadioValue!; GoRouter.of(context).goNamed('dateOfBirthScreen', extra: sheet); }; } diff --git a/lib/presentation/registration/height_screen/height_screen.dart b/lib/presentation/registration/height_screen/height_screen.dart index 66e2762..1e0b88b 100644 --- a/lib/presentation/registration/height_screen/height_screen.dart +++ b/lib/presentation/registration/height_screen/height_screen.dart @@ -31,7 +31,7 @@ class HeightScreen extends StatelessWidget { "height_measurements".tr, style: theme.textTheme.headlineSmall, ), - SizedBox(height: 174.v), + SizedBox(height: 16.v), Column( children: [ Text( diff --git a/lib/presentation/registration/language_select_screen/bloc/language_select_bloc.dart b/lib/presentation/registration/language_select_screen/bloc/language_select_bloc.dart index c77ba3a..7604717 100644 --- a/lib/presentation/registration/language_select_screen/bloc/language_select_bloc.dart +++ b/lib/presentation/registration/language_select_screen/bloc/language_select_bloc.dart @@ -24,7 +24,7 @@ class LanguageSelectBloc extends Bloc _changeDropDown(ChangeDropDownEvent event, Emitter emit) { emit(state.copyWith(selectedDropDownValue: event.value)); - state.languageSelectModelObj?.userRegistrationSheet.lang = event.value.title; + // state.languageSelectModelObj?.userRegistrationSheet.lang = event.value.title; } List fillDropdownItemList() { diff --git a/lib/presentation/registration/language_select_screen/language_select_screen.dart b/lib/presentation/registration/language_select_screen/language_select_screen.dart index f2ac257..1a0dc41 100644 --- a/lib/presentation/registration/language_select_screen/language_select_screen.dart +++ b/lib/presentation/registration/language_select_screen/language_select_screen.dart @@ -1,21 +1,29 @@ -import 'bloc/language_select_bloc.dart'; -import 'models/language_select_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_drop_down.dart'; import 'package:flutter/material.dart'; -class LanguageSelectScreen extends StatelessWidget { - const LanguageSelectScreen({Key? key}) : super(key: key); +class LanguageSelectScreen extends StatefulWidget { + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context) { - return BlocProvider( - create: (context) => LanguageSelectBloc( - LanguageSelectState( - languageSelectModelObj: LanguageSelectModel(), - ), - )..add(LanguageSelectInitialEvent()), - child: LanguageSelectScreen(), - ); + const LanguageSelectScreen({required this.sheet, super.key}); + + @override + State createState() => _LanguageSelectScreenState(); +} + +class _LanguageSelectScreenState extends State { + final List dropdownItemList = [ + SelectionPopupModel(id: 1, title: "Русский", isSelected: true), + ]; + + late SelectionPopupModel value; + + @override + void initState() { + super.initState(); + value = SelectionPopupModel(title: widget.sheet.lang); } @override @@ -36,56 +44,28 @@ class LanguageSelectScreen extends StatelessWidget { ), ), const SizedBox(height: 32), - BlocSelector( - selector: (state) => state.languageSelectModelObj, - builder: ( - context, - languageSelectModelObj, - ) { - return CustomDropDown( - icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(1.h), - ), - child: CustomImageView( - imagePath: ImageConstant.imgFavorite, - height: 12.adaptSize, - width: 12.adaptSize, - ), - ), - hintText: "Не выбрано".tr, - items: languageSelectModelObj?.dropdownItemList ?? [], - onChanged: (value) => _onDropDownChanged(context, value), - ); - }, + 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: dropdownItemList, + onChanged: (SelectionPopupModel newValue) => setState(() { + value = newValue; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(lang: value.title)); + }), ), - // bottomNavigationBar: BlocBuilder( - // builder: (context, state) { - // return NextStepButton( - // text: "continue".tr.toUpperCase(), - // margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - // buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - // onPressed: _saveAndPush(state, context), - // ); - // }, - // ), ], ), ); } - - // void Function()? _saveAndPush(LanguageSelectState state, BuildContext context) { - // return () { - // UserRegistrationSheet sheet = state.languageSelectModelObj!.userRegistrationSheet; - // GoRouter.of(context).goNamed( - // 'credentialsScreen', - // extra: sheet, - // ); - // }; - // } - - void _onDropDownChanged(BuildContext context, value) { - context.read().add(ChangeDropDownEvent(value: value)); - } } diff --git a/lib/presentation/registration/language_select_screen/models/language_select_model.dart b/lib/presentation/registration/language_select_screen/models/language_select_model.dart index 465a8ac..c337c55 100644 --- a/lib/presentation/registration/language_select_screen/models/language_select_model.dart +++ b/lib/presentation/registration/language_select_screen/models/language_select_model.dart @@ -8,6 +8,7 @@ import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model /// and is typically used to hold data that is passed between different parts of the application. class LanguageSelectModel extends Equatable { LanguageSelectModel({this.dropdownItemList = const []}); + UserRegistrationSheet userRegistrationSheet = UserRegistrationSheet( name: '', firstName: '', 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 2edc4d6..4934d31 100644 --- a/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart +++ b/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart @@ -82,7 +82,7 @@ class _MedicineIntakeScreenState extends State { onTapNext(MedicineIntakeState state, BuildContext context) { return () { UserRegistrationSheet sheet = state.medicineIntakeModelObj!.userRegistrationSheet; - sheet.aboutTakingPils = state.enterInformationController!.text; + // sheet.aboutTakingPils = state.enterInformationController!.text; GoRouter.of(context).goNamed( 'favoriteSportsScreen', extra: sheet, diff --git a/lib/presentation/registration/name_screen/name_screen.dart b/lib/presentation/registration/name_screen/name_screen.dart index be74170..8721d1f 100644 --- a/lib/presentation/registration/name_screen/name_screen.dart +++ b/lib/presentation/registration/name_screen/name_screen.dart @@ -29,7 +29,7 @@ class NameScreen extends StatelessWidget { child: Column( children: [ Text("what_is_your_name".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 93.v), + SizedBox(height: 16.v), Text("first_name".tr, style: theme.textTheme.bodyLarge), SizedBox(height: 3.v), BlocSelector( diff --git a/lib/presentation/registration/weight_screen/weight_screen.dart b/lib/presentation/registration/weight_screen/weight_screen.dart index 9f0ab8e..2fe886b 100644 --- a/lib/presentation/registration/weight_screen/weight_screen.dart +++ b/lib/presentation/registration/weight_screen/weight_screen.dart @@ -31,7 +31,7 @@ class WeightScreen extends StatelessWidget { "weight_measurements".tr, style: theme.textTheme.headlineSmall, ), - SizedBox(height: 174.v), + SizedBox(height: 16.v), Column( children: [ Text( diff --git a/lib/widgets/app_bar/appbar_title_image.dart b/lib/widgets/app_bar/appbar_title_image.dart index 6242412..429ab4d 100644 --- a/lib/widgets/app_bar/appbar_title_image.dart +++ b/lib/widgets/app_bar/appbar_title_image.dart @@ -3,35 +3,16 @@ import 'package:flutter/material.dart'; // ignore: must_be_immutable class AppbarTitleImage extends StatelessWidget { - AppbarTitleImage({ - Key? key, - this.imagePath, - this.margin, - this.onTap, - }) : super( - key: key, - ); + const AppbarTitleImage({required this.imagePath, super.key}); - String? imagePath; - - EdgeInsetsGeometry? margin; - - Function? onTap; + final String? imagePath; @override Widget build(BuildContext context) { - return InkWell( - onTap: onTapCall, - child: Padding( - padding: margin ?? EdgeInsets.zero, - child: CustomImageView( - imagePath: imagePath, - height: 48, - fit: BoxFit.contain, - ), - ), + return CustomImageView( + imagePath: imagePath, + height: 48, + fit: BoxFit.contain, ); } - - void onTapCall() {} } diff --git a/lib/widgets/custom_drop_down.dart b/lib/widgets/custom_drop_down.dart index 759efc1..09fdbba 100644 --- a/lib/widgets/custom_drop_down.dart +++ b/lib/widgets/custom_drop_down.dart @@ -92,7 +92,6 @@ class CustomDropDown extends StatelessWidget { value: item, child: Text( item.title, - overflow: TextOverflow.fade, style: hintStyle ?? Theme.of(context).textTheme.titleMedium, ), ); diff --git a/lib/widgets/custom_text_form_field.dart b/lib/widgets/custom_text_form_field.dart index e70b2b5..3d061e9 100644 --- a/lib/widgets/custom_text_form_field.dart +++ b/lib/widgets/custom_text_form_field.dart @@ -62,7 +62,7 @@ class CustomTextFormField extends StatelessWidget { final String? initialValue; final Function(String)? onFieldSubmitted; final void Function(String?)? onSaved; - final void Function(String?)? onChanged; + final void Function(String)? onChanged; @override Widget build(BuildContext context) { @@ -128,6 +128,7 @@ class CustomTextFormField extends StatelessWidget { : SizedBox( width: width ?? double.maxFinite, child: TextFormField( + onChanged: onChanged, controller: controller, focusNode: focusNode ?? null, autofocus: autofocus!,