feature(registration): refactor i 4

This commit is contained in:
mso7nueh
2024-07-15 11:19:29 +03:00
parent 4780caf389
commit 8cf2388b18
12 changed files with 365 additions and 342 deletions

97
flutter_01.log Normal file
View File

@@ -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.<anonymous closure> (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)
<asynchronous suspension>
#10 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1394:27)
<asynchronous suspension>
#11 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#12 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#13 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:372:9)
<asynchronous suspension>
#14 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#15 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:308:5)
<asynchronous suspension>
#16 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
<asynchronous suspension>
#17 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#18 main (package:flutter_tools/executable.dart:93:3)
<asynchronous suspension>
```
## 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.
```

View File

@@ -176,16 +176,16 @@ class _RegistrationScreenState extends State<RegistrationScreen> {
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<RegistrationScreen> {
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<String> 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<RegistrationScreen> {
}
}
List<String> validateCircumferencesFields(
String chestCircumference,
String waistCircumference,
String hipCircumference,
) {
List<String> 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<String> validateCredentialsFields(String email, String name, String password, String passwordConfirmation) {
List<String> errors = [];

View File

@@ -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<AdditionalInformationBloc>(
create: (context) =>
AdditionalInformationBloc(AdditionalInformationState(additionalInformationModelObj: AdditionalInformationModel(userRegistrationSheet: sheet)))
..add(AdditionalInformationInitialEvent()),
child: AdditionalInformationScreen(),
);
}
const AdditionalInformationScreen({super.key, required this.sheet});
@override
State<AdditionalInformationScreen> createState() => _AdditionalInformationScreenState();
}
class _AdditionalInformationScreenState extends State<AdditionalInformationScreen> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(

View File

@@ -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<AllergiesBloc>(
create: (context) => AllergiesBloc(AllergiesState(allergiesModelObj: AllergiesModel(userRegistrationSheet: sheet)))..add(AllergiesInitialEvent()),
child: AllergiesScreen(),
);
}
const AllergiesScreen({super.key, required this.sheet});
@override
State<AllergiesScreen> createState() => _AllergiesScreenState();
@@ -27,33 +23,33 @@ class _AllergiesScreenState extends State<AllergiesScreen> {
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<AllergiesBloc, AllergiesState>(
// 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<AllergiesBloc, AllergiesState>(
// 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<AllergiesBloc, AllergiesState>(
// 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<AllergiesBloc, AllergiesState>(
// builder: (context, state) {
// return GestureDetector(
// onTap: onTapSkip(state, context),
// child: Text("skip".tr, style: theme.textTheme.bodyLarge),
// );
// },
// ),
],
),
),
);
}

View File

@@ -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<BloodPressureBloc>(
create: (context) =>
BloodPressureBloc(BloodPressureState(bloodPressureModelObj: BloodPressureModel(userRegistrationSheet: sheet)))..add(BloodPressureInitialEvent()),
child: BloodPressureScreen(),
);
}
const BloodPressureScreen({super.key, required this.sheet});
@override
State<BloodPressureScreen> createState() => _BloodPressureScreenState();

View File

@@ -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<BodyCircumferencesBloc>(
create: (context) => BodyCircumferencesBloc(BodyCircumferencesState(bodyCircumferencesModelObj: BodyCircumferencesModel(userRegistrationSheet: sheet)))
..add(BodyCircumferencesInitialEvent()),
child: BodyCircumferencesScreen(),
);
}
const BodyCircumferencesScreen({super.key, required this.sheet});
@override
State<BodyCircumferencesScreen> createState() => _BodyCircumferencesScreenState();
@@ -25,139 +17,72 @@ class BodyCircumferencesScreen extends StatefulWidget {
class _BodyCircumferencesScreenState extends State<BodyCircumferencesScreen> {
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<BodyCircumferencesBloc, BodyCircumferencesState, TextEditingController?>(
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<BodyCircumferencesBloc, BodyCircumferencesState, TextEditingController?>(
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<BodyCircumferencesBloc, BodyCircumferencesState, TextEditingController?>(
selector: (state) => state.hipCircumferenceController,
builder: (context, hipCircumferenceController) {
return CustomTextFormField(
inputFormatters: [digitsOnly],
controller: hipCircumferenceController,
hintText: "90".tr,
textInputAction: TextInputAction.done,
);
},
),
// BlocBuilder<BodyCircumferencesBloc, BodyCircumferencesState>(
// 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>();
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>();
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>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(hipCircumference: value));
},
),
],
),
),
);
}
onTapContinue(BodyCircumferencesState state, BuildContext context) {
return () {
List<String> 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<String> validateFields(
String chestCircumference,
String waistCircumference,
String hipCircumference,
) {
List<String> 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;
}
}

View File

@@ -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<CityOfLivingBloc>(
create: (context) =>
CityOfLivingBloc(CityOfLivingState(cityOfLivingModelObj: CityOfLivingModel(userRegistrationSheet: sheet)))..add(CityOfLivingInitialEvent()),
child: CityOfLivingScreen(),
);
}
const CityOfLivingScreen({super.key, required this.sheet});
@override
State<CityOfLivingScreen> createState() => _CityOfLivingScreenState();
}
class _CityOfLivingScreenState extends State<CityOfLivingScreen> {
@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<CityOfLivingBloc, CityOfLivingState, CityOfLivingModel?>(
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<CityOfLivingBloc, CityOfLivingState>(
builder: (context, state) {
return RawAutocomplete<String>(
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<String> onSelected,
Iterable<String> 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<CityOfLivingBloc>(
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<CityOfLivingBloc, CityOfLivingState, CityOfLivingModel?>(
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<CityOfLivingBloc, CityOfLivingState>(
builder: (context, state) {
return RawAutocomplete<String>(
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<String> onSelected,
Iterable<String> 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<CityOfLivingBloc, CityOfLivingState>(
// 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<CityOfLivingBloc>().add(ChangeDropDownEvent(value: value));
final registrationCubit = context.read<RegistrationCubit>();
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<String> onSelected, String option, CityOfLivingState state) {
selectProduct(AutocompleteOnSelected<String> onSelected, String option, CityOfLivingState state, BuildContext context) {
state.cityController?.text = option;
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(city: option));
return () {
onSelected(option);
};

View File

@@ -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<FavoriteFoodsBloc>(
create: (context) =>
FavoriteFoodsBloc(FavoriteFoodsState(favoriteFoodsModelObj: FavoriteFoodsModel(userRegistrationSheet: sheet)))..add(FavoriteFoodsInitialEvent()),
child: FavoriteFoodsScreen(),
);
}
const FavoriteFoodsScreen({super.key, required this.sheet});
@override
State<FavoriteFoodsScreen> createState() => _FavoriteFoodsScreenState();

View File

@@ -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<FavoriteSportsBloc>(
create: (context) =>
FavoriteSportsBloc(FavoriteSportsState(favoriteSportsModelObj: FavoriteSportsModel(userRegistrationSheet: sheet)))..add(FavoriteSportsInitialEvent()),
child: FavoriteSportsScreen(),
);
}
const FavoriteSportsScreen({super.key, required this.sheet});
@override
State<FavoriteSportsScreen> createState() => _FavoriteSportsScreenState();

View File

@@ -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<HeightBloc>(
create: (context) => HeightBloc(HeightState(heightModelObj: HeightModel(userRegistrationSheet: sheet)))..add(HeightInitialEvent()),
child: HeightScreen(),
);
}
const HeightScreen({super.key, required this.sheet});
@override
State<HeightScreen> createState() => _HeightScreenState();
}
class _HeightScreenState extends State<HeightScreen> {
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
@@ -67,7 +66,6 @@ class HeightScreen extends StatelessWidget {
};
}
Function onTapBack(BuildContext context) {
return () {
onTapArrowLeft(context);

View File

@@ -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<MedicineIntakeBloc>(
create: (context) =>
MedicineIntakeBloc(MedicineIntakeState(medicineIntakeModelObj: MedicineIntakeModel(userRegistrationSheet: sheet)))..add(MedicineIntakeInitialEvent()),
child: MedicineIntakeScreen(),
);
}
const MedicineIntakeScreen({super.key, required this.sheet});
@override
State<MedicineIntakeScreen> createState() => _MedicineIntakeScreenState();

View File

@@ -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<WeightBloc>(
create: (context) => WeightBloc(WeightState(weightModelObj: WeightModel(userRegistrationSheet: sheet)))..add(WeightInitialEvent()),
child: WeightScreen(),
);
}
const WeightScreen({super.key, required this.sheet});
@override
Widget build(BuildContext context) {