diff --git a/flutter_01.log b/flutter_01.log new file mode 100644 index 0000000..f7f3c20 --- /dev/null +++ b/flutter_01.log @@ -0,0 +1,97 @@ +Flutter crash report. +Please report a bug at https://github.com/flutter/flutter/issues. + +## command + +flutter analyze + +## exception + +PathNotFoundException: PathNotFoundException: Cannot open file, path = '/home/alex/snap/flutter/common/flutter/version' (OS Error: No such file or directory, errno = 2) + +``` +#0 _File.throwIfError (dart:io/file_impl.dart:675:7) +#1 _File.openSync (dart:io/file_impl.dart:490:5) +#2 _File.readAsBytesSync (dart:io/file_impl.dart:574:18) +#3 _File.readAsStringSync (dart:io/file_impl.dart:624:18) +#4 ForwardingFile.readAsStringSync (package:file/src/forwarding/forwarding_file.dart:99:16) +#5 ErrorHandlingFile.readAsStringSync. (package:flutter_tools/src/base/error_handling_io.dart:217:22) +#6 _runSync (package:flutter_tools/src/base/error_handling_io.dart:587:14) +#7 ErrorHandlingFile.readAsStringSync (package:flutter_tools/src/base/error_handling_io.dart:216:12) +#8 _DefaultPub.get (package:flutter_tools/src/dart/pub.dart:302:58) +#9 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1724:17) + +#10 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1394:27) + +#11 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) + +#12 CommandRunner.runCommand (package:args/command_runner.dart:212:13) + +#13 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:372:9) + +#14 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) + +#15 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:308:5) + +#16 run.. (package:flutter_tools/runner.dart:130:9) + +#17 AppContext.run. (package:flutter_tools/src/base/context.dart:153:19) + +#18 main (package:flutter_tools/executable.dart:93:3) + +``` + +## flutter doctor + +``` +[!] Flutter (Channel [user-branch], 0.0.0-unknown, on Ubuntu 24.04 LTS 6.8.0-38-generic, locale ru_RU.UTF-8) + ! Flutter version 0.0.0-unknown on channel [user-branch] at /home/alex/snap/flutter/common/flutter + Currently on an unknown channel. Run `flutter channel` to switch to an official channel. + If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. + Cannot resolve current version, possibly due to local changes. + Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. + ! Upstream repository unknown source is not a standard remote. + Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error. + • Framework revision (), 1970-01-01 03:00:00.000 + • Engine revision edd8546116 + • Dart version 3.4.3 + • DevTools version 2.34.3 + • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. + +[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) + • Android SDK at /home/alex/Android/Sdk + • Platform android-35, build-tools 35.0.0 + • Java binary at: /snap/android-studio/161/jbr/bin/java + • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) + • All Android licenses accepted. + +[✓] Chrome - develop for the web + • Chrome at google-chrome + +[✓] Linux toolchain - develop for Linux desktop + • clang version 10.0.0-4ubuntu1 + • cmake version 3.16.3 + • ninja version 1.10.0 + • pkg-config version 0.29.1 + +[✓] Android Studio (version 2024.1) + • Android Studio at /snap/android-studio/161 + • Flutter plugin version 80.0.2 + • Dart plugin can be installed from: + 🔨 https://plugins.jetbrains.com/plugin/6351-dart + • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105) + +[✓] VS Code (version 1.91.1) + • VS Code at /usr/share/code + • Flutter extension version 3.92.0 + +[✓] Connected device (3 available) + • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 15 (API 35) (emulator) + • Linux (desktop) • linux • linux-x64 • Ubuntu 24.04 LTS 6.8.0-38-generic + • Chrome (web) • chrome • web-javascript • Google Chrome 126.0.6478.126 + +[✓] Network resources + • All expected network resources are available. + +! Doctor found issues in 1 category. +``` diff --git a/lib/features/registration/presentation/pages/registration_screen.dart b/lib/features/registration/presentation/pages/registration_screen.dart index 534ea11..3f3da55 100644 --- a/lib/features/registration/presentation/pages/registration_screen.dart +++ b/lib/features/registration/presentation/pages/registration_screen.dart @@ -176,16 +176,16 @@ class _RegistrationScreenState extends State { NameScreen(sheet: state.sheet), GenderScreen(sheet: state.sheet), DateOfBirthScreen(sheet: state.sheet), - CityOfLivingScreen(), - BodyCircumferencesScreen(), - WeightScreen(), - HeightScreen(), - BloodPressureScreen(), - AllergiesScreen(), - MedicineIntakeScreen(), - FavoriteSportsScreen(), - FavoriteFoodsScreen(), - AdditionalInformationScreen(), + CityOfLivingScreen(sheet: state.sheet), // todo refactor + BodyCircumferencesScreen(sheet: state.sheet), + WeightScreen(sheet: state.sheet), + HeightScreen(sheet: state.sheet), + BloodPressureScreen(sheet: state.sheet), + AllergiesScreen(sheet: state.sheet), + MedicineIntakeScreen(sheet: state.sheet), + FavoriteSportsScreen(sheet: state.sheet), + FavoriteFoodsScreen(sheet: state.sheet), + AdditionalInformationScreen(sheet: state.sheet), ], ), ), @@ -234,6 +234,32 @@ class _RegistrationScreenState extends State { 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; + } + case 7: + List errors = validateCircumferencesFields(state.sheet.chestCircumference, state.sheet.waistCircumference, state.sheet.hipCircumference); + if (errors.isEmpty) { + return true; + } else { + String errorMessage = ''; + + for (var error in errors) { + errorMessage += error + '\n\n'; + } + showDialog( context: context, builder: (context) => AlertDialog( @@ -254,6 +280,24 @@ class _RegistrationScreenState extends State { } } + List validateCircumferencesFields( + String chestCircumference, + String waistCircumference, + String hipCircumference, + ) { + List errors = []; + + if (chestCircumference.isEmpty | waistCircumference.isEmpty | hipCircumference.isEmpty) { + errors.add('circumference_empty'.tr); + } + + if (![chestCircumference, waistCircumference, hipCircumference].every((circumference) => int.tryParse(circumference) != null)) { + errors.add('circumference_is_not_a_number'.tr); + } + + return errors; + } + List validateCredentialsFields(String email, String name, String password, String passwordConfirmation) { List 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 c12af1f..32fbd61 100644 --- a/lib/presentation/registration/additional_information_screen/additional_information_screen.dart +++ b/lib/presentation/registration/additional_information_screen/additional_information_screen.dart @@ -1,7 +1,6 @@ import 'package:go_router/go_router.dart'; import 'bloc/additional_information_bloc.dart'; -import 'models/additional_information_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; @@ -11,18 +10,16 @@ import 'dart:convert'; import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; -class AdditionalInformationScreen extends StatelessWidget { - const AdditionalInformationScreen({Key? key}) : super(key: key); +class AdditionalInformationScreen extends StatefulWidget { + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => - AdditionalInformationBloc(AdditionalInformationState(additionalInformationModelObj: AdditionalInformationModel(userRegistrationSheet: sheet))) - ..add(AdditionalInformationInitialEvent()), - child: AdditionalInformationScreen(), - ); - } + const AdditionalInformationScreen({super.key, required this.sheet}); + @override + State createState() => _AdditionalInformationScreenState(); +} + +class _AdditionalInformationScreenState extends State { @override Widget build(BuildContext context) { return SingleChildScrollView( diff --git a/lib/presentation/registration/allergies_screen/allergies_screen.dart b/lib/presentation/registration/allergies_screen/allergies_screen.dart index 7a2ac1c..56702d9 100644 --- a/lib/presentation/registration/allergies_screen/allergies_screen.dart +++ b/lib/presentation/registration/allergies_screen/allergies_screen.dart @@ -1,6 +1,7 @@ import 'package:go_router/go_router.dart'; import 'bloc/allergies_bloc.dart'; +// ignore: unused_import import 'models/allergies_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; @@ -8,14 +9,9 @@ import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; class AllergiesScreen extends StatefulWidget { - const AllergiesScreen({Key? key}) : super(key: key); + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => AllergiesBloc(AllergiesState(allergiesModelObj: AllergiesModel(userRegistrationSheet: sheet)))..add(AllergiesInitialEvent()), - child: AllergiesScreen(), - ); - } + const AllergiesScreen({super.key, required this.sheet}); @override State createState() => _AllergiesScreenState(); @@ -27,33 +23,33 @@ class _AllergiesScreenState extends State { return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80), child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("allergies_presence".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 22.v), - _buildTextFormField(context), - // BlocBuilder( - // builder: (context, state) { - // return NextStepButton( - // text: "continue".tr.toUpperCase(), - // margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), - // buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - // onPressed: onTapContinue(state, context), - // ); - // }, - // ), - // BlocBuilder( - // builder: (context, state) { - // return GestureDetector( - // onTap: onTapSkip(state, context), - // child: Text("skip".tr, style: theme.textTheme.bodyLarge), - // ); - // }, - // ), - ], - ), + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column( + children: [ + Text("allergies_presence".tr, style: theme.textTheme.headlineSmall), + SizedBox(height: 22.v), + _buildTextFormField(context), + // BlocBuilder( + // builder: (context, state) { + // return NextStepButton( + // text: "continue".tr.toUpperCase(), + // margin: EdgeInsets.only(left: 16.h, right: 16.h, bottom: 50.v), + // buttonStyle: CustomButtonStyles.outlinePrimaryTL15, + // onPressed: onTapContinue(state, context), + // ); + // }, + // ), + // BlocBuilder( + // builder: (context, state) { + // return GestureDetector( + // onTap: onTapSkip(state, context), + // child: Text("skip".tr, style: theme.textTheme.bodyLarge), + // ); + // }, + // ), + ], + ), ), ); } 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 d8efedd..d5c2468 100644 --- a/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart +++ b/lib/presentation/registration/blood_pressure_screen/blood_pressure_screen.dart @@ -11,15 +11,9 @@ import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_m import 'package:flutter/material.dart'; class BloodPressureScreen extends StatefulWidget { - const BloodPressureScreen({Key? key}) : super(key: key); + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => - BloodPressureBloc(BloodPressureState(bloodPressureModelObj: BloodPressureModel(userRegistrationSheet: sheet)))..add(BloodPressureInitialEvent()), - child: BloodPressureScreen(), - ); - } + const BloodPressureScreen({super.key, required this.sheet}); @override State createState() => _BloodPressureScreenState(); 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 60733e3..60576c8 100644 --- a/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart +++ b/lib/presentation/registration/body_circumferences_screen/body_circumferences_screen.dart @@ -1,23 +1,15 @@ -import 'package:go_router/go_router.dart'; +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; -import 'bloc/body_circumferences_bloc.dart'; import 'package:flutter/services.dart'; -import 'models/body_circumferences_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/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; class BodyCircumferencesScreen extends StatefulWidget { - const BodyCircumferencesScreen({Key? key}) : super(key: key); + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => BodyCircumferencesBloc(BodyCircumferencesState(bodyCircumferencesModelObj: BodyCircumferencesModel(userRegistrationSheet: sheet))) - ..add(BodyCircumferencesInitialEvent()), - child: BodyCircumferencesScreen(), - ); - } + const BodyCircumferencesScreen({super.key, required this.sheet}); @override State createState() => _BodyCircumferencesScreenState(); @@ -25,139 +17,72 @@ class BodyCircumferencesScreen extends StatefulWidget { class _BodyCircumferencesScreenState extends State { final digitsOnly = FilteringTextInputFormatter.digitsOnly; + final chestCircumferenceController = TextEditingController(); + final waistCircumferenceController = TextEditingController(); + final hipCircumferenceController = TextEditingController(); + + @override + void initState() { + super.initState(); + chestCircumferenceController.text = widget.sheet.chestCircumference; + waistCircumferenceController.text = widget.sheet.waistCircumference; + hipCircumferenceController.text = widget.sheet.hipCircumference; + } @override Widget build(BuildContext context) { return SingleChildScrollView( padding: EdgeInsets.only(bottom: 80), child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("initial_measurements".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 16.v), - Column( - children: [ - Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.chestCircumferenceController, - builder: (context, chestCircumferenceController) { - return CustomTextFormField(inputFormatters: [digitsOnly], controller: chestCircumferenceController, hintText: "90".tr); - }, - ), - ], - ), - SizedBox(height: 19.v), - Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 5.v), - BlocSelector( - selector: (state) => state.waistCircumferenceController, - builder: (context, waistCircumferenceController) { - return CustomTextFormField(inputFormatters: [digitsOnly], controller: waistCircumferenceController, hintText: "60".tr); - }, - ), - SizedBox(height: 21.v), - Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 3.v), - BlocSelector( - selector: (state) => state.hipCircumferenceController, - builder: (context, hipCircumferenceController) { - return CustomTextFormField( - inputFormatters: [digitsOnly], - controller: hipCircumferenceController, - hintText: "90".tr, - textInputAction: TextInputAction.done, - ); - }, - ), - // 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), - // ); - // }, - // ), - ], - ), + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column( + children: [ + Text("initial_measurements".tr, style: theme.textTheme.headlineSmall), + SizedBox(height: 16.v), + Column( + children: [ + Text("chest_circumference".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 3.v), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: chestCircumferenceController, + hintText: "90".tr, + onChanged: (value) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(chestCircumference: value)); + }, + ), + ], + ), + SizedBox(height: 19.v), + Text("waist_circumference".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 5.v), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: waistCircumferenceController, + hintText: "60".tr, + onChanged: (value) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(waistCircumference: value)); + }, + ), + SizedBox(height: 21.v), + Text("hip_circumference".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 3.v), + CustomTextFormField( + inputFormatters: [digitsOnly], + controller: hipCircumferenceController, + hintText: "90".tr, + textInputAction: TextInputAction.done, + onChanged: (value) { + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hipCircumference: value)); + }, + ), + ], + ), ), ); } - - onTapContinue(BodyCircumferencesState state, BuildContext context) { - return () { - List errors = - 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; - GoRouter.of(context).goNamed('weightScreen', 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); - }; - } - - - Function onTapBack(BuildContext context) { - return () { - onTapArrowLeft(context); - }; - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - GoRouter.of(context).pop(); - } - - /// Navigates to the weightScreen when the action is triggered. - navigateToWeight(BuildContext context) => GoRouter.of(context).goNamed('weightScreen'); - - List validateFields( - String chestCircumference, - String waistCircumference, - String hipCircumference, - ) { - List errors = []; - - if (chestCircumference.isEmpty | waistCircumference.isEmpty | hipCircumference.isEmpty) { - errors.add('circumference_empty'.tr); - } - - if (![chestCircumference, waistCircumference, hipCircumference].every((circumference) => int.tryParse(circumference) != null)) { - errors.add('circumference_is_not_a_number'.tr); - } - - return errors; - } } 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 f5ee8a8..1e5f01b 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 @@ -1,3 +1,4 @@ +import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_cubit.dart'; import 'package:go_router/go_router.dart'; import 'bloc/city_of_living_bloc.dart'; @@ -8,108 +9,101 @@ 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 CityOfLivingScreen extends StatelessWidget { - const CityOfLivingScreen({Key? key}) : super(key: key); +class CityOfLivingScreen extends StatefulWidget { + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => - CityOfLivingBloc(CityOfLivingState(cityOfLivingModelObj: CityOfLivingModel(userRegistrationSheet: sheet)))..add(CityOfLivingInitialEvent()), - child: CityOfLivingScreen(), - ); - } + const CityOfLivingScreen({super.key, required this.sheet}); + @override + State createState() => _CityOfLivingScreenState(); +} + +class _CityOfLivingScreenState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( - padding: EdgeInsets.only(bottom: 80), - child: Container( - width: double.maxFinite, - padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), - child: Column( - children: [ - Text("place_of_living".tr, style: theme.textTheme.headlineSmall), - SizedBox(height: 39.v), - Text("country".tr, style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - BlocSelector( - selector: (state) => state.cityOfLivingModelObj, - builder: (context, cityOfLivingModelObj) { - return CustomDropDown( - icon: Container( - margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v), - decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), - child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), - ), - hintText: "Не выбрано".tr, - items: cityOfLivingModelObj?.dropdownItemList ?? [], - onChanged: onDropDownChange(context), - ); - }, - ), - SizedBox(height: 22.v), - Text("Населенный пункт", style: theme.textTheme.bodyLarge), - SizedBox(height: 2.v), - BlocBuilder( - builder: (context, state) { - return RawAutocomplete( - optionsBuilder: (TextEditingValue textEditingValue) => _options.where((String option) { - return option.toLowerCase().startsWith(textEditingValue.text.toLowerCase()); - }), - fieldViewBuilder: ( - BuildContext context, - TextEditingController textEditingController, - FocusNode focusNode, - VoidCallback onFieldSubmitted, - ) { - return CustomTextFormField( - controller: textEditingController, - focusNode: focusNode, - onFieldSubmitted: (String value) => onFieldSubmitted(), - ); - }, - optionsViewBuilder: ( - BuildContext context, - AutocompleteOnSelected onSelected, - Iterable options, - ) { - return Align( - alignment: Alignment.topLeft, - child: Material( - elevation: 4.0, - child: SizedBox( - height: 200.0, - child: ListView.builder( - padding: const EdgeInsets.all(8.0), - itemCount: options.length, - itemBuilder: (BuildContext context, int index) { - final String option = options.elementAt(index); - return GestureDetector( - onTap: () => onSelected(option), - child: ListTile( - title: Text(option), - ), - ); - }, + return BlocProvider( + create: (BuildContext context) => + CityOfLivingBloc(CityOfLivingState(cityOfLivingModelObj: CityOfLivingModel(userRegistrationSheet: widget.sheet)))..add(CityOfLivingInitialEvent()), + child: SingleChildScrollView( + padding: EdgeInsets.only(bottom: 80), + child: Container( + width: double.maxFinite, + padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v), + child: Column( + children: [ + Text("place_of_living".tr, style: theme.textTheme.headlineSmall), + SizedBox(height: 39.v), + Text("country".tr, style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + BlocSelector( + selector: (state) => state.cityOfLivingModelObj, + builder: (context, cityOfLivingModelObj) { + return CustomDropDown( + icon: Container( + margin: EdgeInsets.fromLTRB(30.h, 11.v, 17.h, 11.v), + decoration: BoxDecoration(borderRadius: BorderRadius.circular(1.h)), + child: CustomImageView(imagePath: ImageConstant.imgFavorite, height: 12.adaptSize, width: 12.adaptSize), + ), + hintText: "Не выбрано".tr, + items: cityOfLivingModelObj?.dropdownItemList ?? [], + onChanged: onDropDownChange(context), + ); + }, + ), + SizedBox(height: 22.v), + Text("Населенный пункт", style: theme.textTheme.bodyLarge), + SizedBox(height: 2.v), + BlocBuilder( + builder: (context, state) { + return RawAutocomplete( + optionsBuilder: (TextEditingValue textEditingValue) => _options.where((String option) { + return option.toLowerCase().startsWith(textEditingValue.text.toLowerCase()); + }), + fieldViewBuilder: ( + BuildContext context, + TextEditingController textEditingController, + FocusNode focusNode, + VoidCallback onFieldSubmitted, + ) { + return CustomTextFormField( + controller: textEditingController, + focusNode: focusNode, + onFieldSubmitted: (String value) => onFieldSubmitted(), + ); + }, + optionsViewBuilder: ( + BuildContext context, + AutocompleteOnSelected onSelected, + Iterable options, + ) { + return Align( + alignment: Alignment.topLeft, + child: Material( + elevation: 4.0, + child: SizedBox( + height: 200.0, + child: ListView.builder( + padding: const EdgeInsets.all(8.0), + itemCount: options.length, + itemBuilder: (BuildContext context, int index) { + final String option = options.elementAt(index); + return GestureDetector( + onTap: () => onSelected(option), + child: ListTile( + title: Text(option), + ), + ); + }, + ), ), ), - ), - ); - }, - ); - }, - ), - // 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), - // ); - // }, - // ), - ], + ); + }, + ); + }, + ), + ], + ), ), ), ); @@ -125,10 +119,11 @@ class CityOfLivingScreen extends StatelessWidget { onDropDownChange(BuildContext context) { return (value) { context.read().add(ChangeDropDownEvent(value: value)); + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(country: value)); }; } - Function onTapBack(BuildContext context) { return () { onTapArrowLeft(context); @@ -141,8 +136,10 @@ class CityOfLivingScreen extends StatelessWidget { } } -selectProduct(AutocompleteOnSelected onSelected, String option, CityOfLivingState state) { +selectProduct(AutocompleteOnSelected onSelected, String option, CityOfLivingState state, BuildContext context) { state.cityController?.text = option; + final registrationCubit = context.read(); + registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(city: option)); return () { onSelected(option); }; 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 0db859d..b4f54d9 100644 --- a/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart +++ b/lib/presentation/registration/favorite_foods_screen/favorite_foods_screen.dart @@ -1,22 +1,15 @@ import 'package:go_router/go_router.dart'; import 'bloc/favorite_foods_bloc.dart'; -import 'models/favorite_foods_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/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; class FavoriteFoodsScreen extends StatefulWidget { - const FavoriteFoodsScreen({Key? key}) : super(key: key); + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => - FavoriteFoodsBloc(FavoriteFoodsState(favoriteFoodsModelObj: FavoriteFoodsModel(userRegistrationSheet: sheet)))..add(FavoriteFoodsInitialEvent()), - child: FavoriteFoodsScreen(), - ); - } + const FavoriteFoodsScreen({super.key, required this.sheet}); @override State createState() => _FavoriteFoodsScreenState(); 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 5d8be5d..fd3a42f 100644 --- a/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart +++ b/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart @@ -1,6 +1,7 @@ import 'package:go_router/go_router.dart'; import 'bloc/favorite_sports_bloc.dart'; +// ignore: unused_import import 'models/favorite_sports_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; @@ -8,15 +9,9 @@ import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/material.dart'; class FavoriteSportsScreen extends StatefulWidget { - const FavoriteSportsScreen({Key? key}) : super(key: key); + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => - FavoriteSportsBloc(FavoriteSportsState(favoriteSportsModelObj: FavoriteSportsModel(userRegistrationSheet: sheet)))..add(FavoriteSportsInitialEvent()), - child: FavoriteSportsScreen(), - ); - } + const FavoriteSportsScreen({super.key, required this.sheet}); @override State createState() => _FavoriteSportsScreenState(); diff --git a/lib/presentation/registration/height_screen/height_screen.dart b/lib/presentation/registration/height_screen/height_screen.dart index 1e0b88b..a41dad9 100644 --- a/lib/presentation/registration/height_screen/height_screen.dart +++ b/lib/presentation/registration/height_screen/height_screen.dart @@ -1,23 +1,22 @@ import 'package:go_router/go_router.dart'; import 'bloc/height_bloc.dart'; -import 'models/height_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/services.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:flutter/material.dart'; -class HeightScreen extends StatelessWidget { - const HeightScreen({Key? key}) : super(key: key); +class HeightScreen extends StatefulWidget { + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => HeightBloc(HeightState(heightModelObj: HeightModel(userRegistrationSheet: sheet)))..add(HeightInitialEvent()), - child: HeightScreen(), - ); - } + const HeightScreen({super.key, required this.sheet}); + @override + State createState() => _HeightScreenState(); +} + +class _HeightScreenState extends State { @override Widget build(BuildContext context) { return SingleChildScrollView( @@ -67,7 +66,6 @@ class HeightScreen extends StatelessWidget { }; } - Function onTapBack(BuildContext context) { return () { onTapArrowLeft(context); 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 4934d31..5ccc203 100644 --- a/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart +++ b/lib/presentation/registration/medicine_intake_screen/medicine_intake_screen.dart @@ -1,22 +1,15 @@ import 'package:go_router/go_router.dart'; import 'bloc/medicine_intake_bloc.dart'; -import 'models/medicine_intake_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart'; import 'package:flutter/material.dart'; class MedicineIntakeScreen extends StatefulWidget { - const MedicineIntakeScreen({Key? key}) : super(key: key); + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => - MedicineIntakeBloc(MedicineIntakeState(medicineIntakeModelObj: MedicineIntakeModel(userRegistrationSheet: sheet)))..add(MedicineIntakeInitialEvent()), - child: MedicineIntakeScreen(), - ); - } + const MedicineIntakeScreen({super.key, required this.sheet}); @override State createState() => _MedicineIntakeScreenState(); diff --git a/lib/presentation/registration/weight_screen/weight_screen.dart b/lib/presentation/registration/weight_screen/weight_screen.dart index 2fe886b..f65f0f3 100644 --- a/lib/presentation/registration/weight_screen/weight_screen.dart +++ b/lib/presentation/registration/weight_screen/weight_screen.dart @@ -1,7 +1,6 @@ import 'package:go_router/go_router.dart'; import 'bloc/weight_bloc.dart'; -import 'models/weight_model.dart'; import 'package:eatvio_app/core/app_export.dart'; import 'package:eatvio_app/widgets/custom_text_form_field.dart'; import 'package:flutter/services.dart'; @@ -9,14 +8,9 @@ import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_m import 'package:flutter/material.dart'; class WeightScreen extends StatelessWidget { - const WeightScreen({Key? key}) : super(key: key); + final UserRegistrationSheet sheet; - static Widget builder(BuildContext context, sheet) { - return BlocProvider( - create: (context) => WeightBloc(WeightState(weightModelObj: WeightModel(userRegistrationSheet: sheet)))..add(WeightInitialEvent()), - child: WeightScreen(), - ); - } + const WeightScreen({super.key, required this.sheet}); @override Widget build(BuildContext context) {