Added logic for body_circumferences and city_of_living

This commit is contained in:
2023-12-25 17:23:18 +03:00
parent d908f5f28c
commit aa1ab31a91
11 changed files with 147 additions and 91 deletions

View File

@@ -18,8 +18,8 @@ class BodyCircumferencesBloc
Emitter<BodyCircumferencesState> emit,
) async {
emit(state.copyWith(
valueController: TextEditingController(),
valueController1: TextEditingController(),
valueController2: TextEditingController()));
chestCircumferenceController: TextEditingController(),
waistCircumferenceController: TextEditingController(),
hipCircumferenceController: TextEditingController()));
}
}

View File

@@ -5,37 +5,40 @@ part of 'body_circumferences_bloc.dart';
/// Represents the state of BodyCircumferences in the application.
class BodyCircumferencesState extends Equatable {
BodyCircumferencesState({
this.valueController,
this.valueController1,
this.valueController2,
this.chestCircumferenceController,
this.waistCircumferenceController,
this.hipCircumferenceController,
this.bodyCircumferencesModelObj,
});
TextEditingController? valueController;
TextEditingController? chestCircumferenceController;
TextEditingController? valueController1;
TextEditingController? waistCircumferenceController;
TextEditingController? valueController2;
TextEditingController? hipCircumferenceController;
BodyCircumferencesModel? bodyCircumferencesModelObj;
@override
List<Object?> get props => [
valueController,
valueController1,
valueController2,
chestCircumferenceController,
waistCircumferenceController,
hipCircumferenceController,
bodyCircumferencesModelObj,
];
BodyCircumferencesState copyWith({
TextEditingController? valueController,
TextEditingController? valueController1,
TextEditingController? valueController2,
TextEditingController? chestCircumferenceController,
TextEditingController? waistCircumferenceController,
TextEditingController? hipCircumferenceController,
BodyCircumferencesModel? bodyCircumferencesModelObj,
}) {
return BodyCircumferencesState(
valueController: valueController ?? this.valueController,
valueController1: valueController1 ?? this.valueController1,
valueController2: valueController2 ?? this.valueController2,
chestCircumferenceController:
chestCircumferenceController ?? this.chestCircumferenceController,
waistCircumferenceController:
waistCircumferenceController ?? this.waistCircumferenceController,
hipCircumferenceController:
hipCircumferenceController ?? this.hipCircumferenceController,
bodyCircumferencesModelObj:
bodyCircumferencesModelObj ?? this.bodyCircumferencesModelObj,
);

View File

@@ -1,4 +1,5 @@
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/widgets/app_bar/appbar_leading_image.dart';
@@ -9,25 +10,23 @@ import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_m
import 'package:eatvio_app/widgets/custom_text_form_field.dart';
import 'package:flutter/material.dart';
class BodyCircumferencesScreen extends StatefulWidget {
class BodyCircumferencesScreen extends StatelessWidget {
const BodyCircumferencesScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final sheet =
ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
return BlocProvider<BodyCircumferencesBloc>(
create: (context) => BodyCircumferencesBloc(BodyCircumferencesState(
bodyCircumferencesModelObj: BodyCircumferencesModel()))
bodyCircumferencesModelObj:
BodyCircumferencesModel(userRegistrationSheet: sheet)))
..add(BodyCircumferencesInitialEvent()),
child: BodyCircumferencesScreen());
}
@override
State<BodyCircumferencesScreen> createState() =>
_BodyCircumferencesScreenState();
}
class _BodyCircumferencesScreenState extends State<BodyCircumferencesScreen> {
@override
Widget build(BuildContext context) {
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
mediaQueryData = MediaQuery.of(context);
return SafeArea(
child: Scaffold(
@@ -63,10 +62,12 @@ class _BodyCircumferencesScreenState extends State<BodyCircumferencesScreen> {
SizedBox(height: 3.v),
BlocSelector<BodyCircumferencesBloc,
BodyCircumferencesState, TextEditingController?>(
selector: (state) => state.valueController,
builder: (context, valueController) {
selector: (state) => state.chestCircumferenceController,
builder: (context, chestCircumferenceController) {
return CustomTextFormField(
controller: valueController, hintText: "90".tr);
inputFormatters: [digitsOnly],
controller: chestCircumferenceController,
hintText: "90".tr);
})
]),
SizedBox(height: 19.v),
@@ -75,10 +76,12 @@ class _BodyCircumferencesScreenState extends State<BodyCircumferencesScreen> {
SizedBox(height: 5.v),
BlocSelector<BodyCircumferencesBloc, BodyCircumferencesState,
TextEditingController?>(
selector: (state) => state.valueController1,
builder: (context, valueController1) {
selector: (state) => state.waistCircumferenceController,
builder: (context, waistCircumferenceController) {
return CustomTextFormField(
controller: valueController1, hintText: "60".tr);
inputFormatters: [digitsOnly],
controller: waistCircumferenceController,
hintText: "60".tr);
}),
SizedBox(height: 21.v),
Text("hip_circumference".tr,
@@ -86,20 +89,39 @@ class _BodyCircumferencesScreenState extends State<BodyCircumferencesScreen> {
SizedBox(height: 3.v),
BlocSelector<BodyCircumferencesBloc, BodyCircumferencesState,
TextEditingController?>(
selector: (state) => state.valueController2,
builder: (context, valueController2) {
selector: (state) => state.hipCircumferenceController,
builder: (context, hipCircumferenceController) {
return CustomTextFormField(
controller: valueController2,
inputFormatters: [digitsOnly],
controller: hipCircumferenceController,
hintText: "90".tr,
textInputAction: TextInputAction.done);
}),
Spacer(),
NextStepButton(
text: "continue".tr.toUpperCase(),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
navigateToWeight(context);
}),
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: () {
UserRegistrationSheet sheet = state
.bodyCircumferencesModelObj!
.userRegistrationSheet;
sheet.chestCircumference = int.tryParse(
state.chestCircumferenceController!.text)!;
sheet.waistCircumference = int.tryParse(
state.waistCircumferenceController!.text)!;
sheet.hipCircumference = int.tryParse(
state.hipCircumferenceController!.text)!;
Navigator.pushNamed(
context,
AppRoutes.weightScreen,
arguments: sheet,
);
});
}),
SizedBox(height: 17.v),
]))));
}

View File

@@ -1,16 +1,21 @@
// ignore_for_file: must_be_immutable
import 'package:equatable/equatable.dart';
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
/// This class defines the variables used in the [body_circumferences_screen],
/// and is typically used to hold data that is passed between different parts of the application.
class BodyCircumferencesModel extends Equatable {
BodyCircumferencesModel() {}
UserRegistrationSheet userRegistrationSheet;
BodyCircumferencesModel({required this.userRegistrationSheet}) {}
BodyCircumferencesModel copyWith() {
return BodyCircumferencesModel();
return BodyCircumferencesModel(
userRegistrationSheet:
userRegistrationSheet ?? this.userRegistrationSheet,
);
}
@override
List<Object?> get props => [];
List<Object?> get props => [userRegistrationSheet];
}

View File

@@ -28,6 +28,8 @@ class CityOfLivingBloc extends Bloc<CityOfLivingEvent, CityOfLivingState> {
Emitter<CityOfLivingState> emit,
) {
emit(state.copyWith(selectedDropDownValue: event.value));
state.cityOfLivingModelObj?.userRegistrationSheet.country =
event.value.title;
}
_changeDropDown1(
@@ -35,6 +37,7 @@ class CityOfLivingBloc extends Bloc<CityOfLivingEvent, CityOfLivingState> {
Emitter<CityOfLivingState> emit,
) {
emit(state.copyWith(selectedDropDownValue1: event.value));
state.cityOfLivingModelObj?.userRegistrationSheet.city = event.value.title;
}
List<SelectionPopupModel> fillDropdownItemList() {

View File

@@ -13,9 +13,12 @@ class CityOfLivingScreen extends StatelessWidget {
const CityOfLivingScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final sheet =
ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
return BlocProvider<CityOfLivingBloc>(
create: (context) => CityOfLivingBloc(
CityOfLivingState(cityOfLivingModelObj: CityOfLivingModel()))
create: (context) => CityOfLivingBloc(CityOfLivingState(
cityOfLivingModelObj:
CityOfLivingModel(userRegistrationSheet: sheet)))
..add(CityOfLivingInitialEvent()),
child: CityOfLivingScreen());
}
@@ -47,7 +50,8 @@ class CityOfLivingScreen extends StatelessWidget {
valueColor: AlwaysStoppedAnimation<Color>(
appTheme.blueA400)))),
SizedBox(height: 39.v),
Text("Moscow".tr, style: theme.textTheme.headlineSmall),
Text("place_of_living".tr,
style: theme.textTheme.headlineSmall),
Spacer(flex: 34),
Text("country".tr, style: theme.textTheme.bodyLarge),
SizedBox(height: 2.v),
@@ -65,7 +69,7 @@ class CityOfLivingScreen extends StatelessWidget {
imagePath: ImageConstant.imgFavorite,
height: 12.adaptSize,
width: 12.adaptSize)),
hintText: "Russia".tr,
hintText: "Не выбрано".tr,
items: cityOfLivingModelObj?.dropdownItemList ?? [],
onChanged: (value) {
context
@@ -90,7 +94,7 @@ class CityOfLivingScreen extends StatelessWidget {
imagePath: ImageConstant.imgFavorite,
height: 12.adaptSize,
width: 12.adaptSize)),
hintText: "Moscow".tr,
hintText: "Не выбрано".tr,
items:
cityOfLivingModelObj?.dropdownItemList1 ?? [],
onChanged: (value) {
@@ -100,12 +104,23 @@ class CityOfLivingScreen extends StatelessWidget {
});
}),
Spacer(flex: 65),
NextStepButton(
text: "continue".tr.toUpperCase(),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
navigateToCircumferences(context);
}),
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: () {
UserRegistrationSheet sheet =
state.cityOfLivingModelObj!.userRegistrationSheet;
Navigator.pushNamed(
context,
AppRoutes.bodyCircumferencesScreen,
arguments: sheet,
);
});
}),
SizedBox(height: 17.v),
]))));
}
@@ -128,11 +143,4 @@ class CityOfLivingScreen extends StatelessWidget {
onTapArrowLeft(BuildContext context) {
NavigatorService.goBack();
}
/// Navigates to the bodyCircumferencesScreen when the action is triggered.
navigateToCircumferences(BuildContext context) {
NavigatorService.pushNamed(
AppRoutes.bodyCircumferencesScreen,
);
}
}

View File

@@ -2,11 +2,14 @@
import 'package:equatable/equatable.dart';
import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart';
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
/// This class defines the variables used in the [city_of_living_screen],
/// and is typically used to hold data that is passed between different parts of the application.
class CityOfLivingModel extends Equatable {
UserRegistrationSheet userRegistrationSheet;
CityOfLivingModel({
required this.userRegistrationSheet,
this.dropdownItemList = const [],
this.dropdownItemList1 = const [],
}) {}
@@ -20,11 +23,14 @@ class CityOfLivingModel extends Equatable {
List<SelectionPopupModel>? dropdownItemList1,
}) {
return CityOfLivingModel(
userRegistrationSheet:
userRegistrationSheet ?? this.userRegistrationSheet,
dropdownItemList: dropdownItemList ?? this.dropdownItemList,
dropdownItemList1: dropdownItemList1 ?? this.dropdownItemList1,
);
}
@override
List<Object?> get props => [dropdownItemList, dropdownItemList1];
List<Object?> get props =>
[dropdownItemList, dropdownItemList1, userRegistrationSheet];
}

View File

@@ -12,9 +12,12 @@ class DateOfBirthScreen extends StatefulWidget {
const DateOfBirthScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final sheet =
ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
return BlocProvider<DateOfBirthBloc>(
create: (context) => DateOfBirthBloc(
DateOfBirthState(dateOfBirthModelObj: DateOfBirthModel()))
create: (context) => DateOfBirthBloc(DateOfBirthState(
dateOfBirthModelObj:
DateOfBirthModel(userRegistrationSheet: sheet)))
..add(DateOfBirthInitialEvent()),
child: DateOfBirthScreen());
}
@@ -59,12 +62,24 @@ class _DateOfBirthScreenState extends State<DateOfBirthScreen> {
Spacer(flex: 39),
_buildDateInput(context),
Spacer(flex: 60),
NextStepButton(
text: "continue".tr.toUpperCase(),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
navigateToCity(context);
}),
BlocBuilder<DateOfBirthBloc, DateOfBirthState>(
builder: (context, state) {
return NextStepButton(
text: "continue".tr.toUpperCase(),
margin: EdgeInsets.only(
left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
UserRegistrationSheet sheet = state
.dateOfBirthModelObj!.userRegistrationSheet;
sheet.birthdate = selectedDate;
Navigator.pushNamed(
context,
AppRoutes.cityOfLivingScreen,
arguments: sheet,
);
});
}),
SizedBox(height: 17.v),
]))));
});
@@ -124,7 +139,6 @@ class _DateOfBirthScreenState extends State<DateOfBirthScreen> {
///
/// This function returns a `Future` that completes with `void`.
Future<void> openDatePickerDialog(BuildContext context) async {
var initialState = BlocProvider.of<DateOfBirthBloc>(context).state;
DateTime? dateTime = await showDatePicker(
context: context,
initialDate: DateTime.now(),
@@ -137,11 +151,4 @@ class _DateOfBirthScreenState extends State<DateOfBirthScreen> {
});
}
}
/// Navigates to the cityOfLivingScreen when the action is triggered.
navigateToCity(BuildContext context) {
NavigatorService.pushNamed(
AppRoutes.cityOfLivingScreen,
);
}
}

View File

@@ -1,16 +1,22 @@
// ignore_for_file: must_be_immutable
import 'package:equatable/equatable.dart';
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
/// This class defines the variables used in the [date_of_birth_screen],
/// and is typically used to hold data that is passed between different parts of the application.
class DateOfBirthModel extends Equatable {
DateOfBirthModel() {}
UserRegistrationSheet userRegistrationSheet;
DateOfBirthModel({required this.userRegistrationSheet}) {}
DateOfBirthModel copyWith() {
return DateOfBirthModel();
return DateOfBirthModel(
userRegistrationSheet:
userRegistrationSheet ?? this.userRegistrationSheet,
);
}
@override
List<Object?> get props => [];
List<Object?> get props => [userRegistrationSheet];
}

View File

@@ -25,14 +25,5 @@ class GenderBloc extends Bloc<GenderEvent, GenderState> {
) {
emit(state.copyWith(selectedRadioValue: event.value));
state.genderModelObj?.userRegistrationSheet.gender = event.value;
/*
print(state.genderModelObj?.userRegistrationSheet.lang);
print(state.genderModelObj?.userRegistrationSheet.email);
print(state.genderModelObj?.userRegistrationSheet.password);
print(state.genderModelObj?.userRegistrationSheet.passwordConfirmation);
print(state.genderModelObj?.userRegistrationSheet.firstName);
print(state.genderModelObj?.userRegistrationSheet.lastName);
print(state.genderModelObj?.userRegistrationSheet.gender);
*/
}
}

View File

@@ -1,5 +1,6 @@
import 'package:eatvio_app/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class CustomTextFormField extends StatelessWidget {
CustomTextFormField({
@@ -21,6 +22,7 @@ class CustomTextFormField extends StatelessWidget {
this.suffix,
this.suffixConstraints,
this.contentPadding,
this.inputFormatters,
this.borderDecoration,
this.fillColor,
this.filled = true,
@@ -44,6 +46,8 @@ class CustomTextFormField extends StatelessWidget {
final bool? obscureText;
final List<TextInputFormatter>? inputFormatters;
final TextInputAction? textInputAction;
final TextInputType? textInputType;
@@ -98,6 +102,7 @@ class CustomTextFormField extends StatelessWidget {
decoration: decoration,
validator: validator,
onSaved: onSaved,
inputFormatters: inputFormatters,
),
);
InputDecoration get decoration => InputDecoration(