Added logic for Height and Weight

This commit is contained in:
2023-12-25 18:02:29 +03:00
parent 6db94dc647
commit 3d3be84373
6 changed files with 64 additions and 30 deletions

View File

@@ -26,6 +26,8 @@ class HeightBloc extends Bloc<HeightEvent, HeightState> {
Emitter<HeightState> emit,
) {
emit(state.copyWith(selectedDropDownValue: event.value));
state.heightModelObj?.userRegistrationSheet.height =
int.tryParse(event.value.title)!;
}
List<SelectionPopupModel> fillDropdownItemList() {

View File

@@ -13,10 +13,12 @@ class HeightScreen extends StatefulWidget {
const HeightScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final sheet =
ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
return BlocProvider<HeightBloc>(
create: (context) =>
HeightBloc(HeightState(heightModelObj: HeightModel()))
..add(HeightInitialEvent()),
create: (context) => HeightBloc(HeightState(
heightModelObj: HeightModel(userRegistrationSheet: sheet)))
..add(HeightInitialEvent()),
child: HeightScreen());
}
@@ -84,12 +86,23 @@ class _HeightScreenState extends State<HeightScreen> {
])
]),
Spacer(),
NextStepButton(
text: "continue".tr.toUpperCase(),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
navigateToAllergies(context);
}),
BlocBuilder<HeightBloc, HeightState>(
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.heightModelObj!.userRegistrationSheet;
Navigator.pushNamed(
context,
AppRoutes.heightScreen,
arguments: sheet,
);
});
}),
SizedBox(height: 17.v),
]))));
}
@@ -112,11 +125,4 @@ class _HeightScreenState extends State<HeightScreen> {
onTapArrowLeft(BuildContext context) {
NavigatorService.goBack();
}
/// Navigates to the allergiesScreen when the action is triggered.
navigateToAllergies(BuildContext context) {
NavigatorService.pushNamed(
AppRoutes.allergiesScreen,
);
}
}

View File

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

View File

@@ -26,6 +26,8 @@ class WeightBloc extends Bloc<WeightEvent, WeightState> {
Emitter<WeightState> emit,
) {
emit(state.copyWith(selectedDropDownValue: event.value));
state.weightModelObj?.userRegistrationSheet.weight =
int.tryParse(event.value.title)!;
}
List<SelectionPopupModel> fillDropdownItemList() {

View File

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

View File

@@ -6,16 +6,19 @@ import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart';
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
import 'package:eatvio_app/widgets/custom_drop_down.dart';
import 'package:eatvio_app/widgets/next_step_button.dart';
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
import 'package:flutter/material.dart';
class WeightScreen extends StatefulWidget {
const WeightScreen({Key? key}) : super(key: key);
static Widget builder(BuildContext context) {
final sheet =
ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
return BlocProvider<WeightBloc>(
create: (context) =>
WeightBloc(WeightState(weightModelObj: WeightModel()))
..add(WeightInitialEvent()),
create: (context) => WeightBloc(WeightState(
weightModelObj: WeightModel(userRegistrationSheet: sheet)))
..add(WeightInitialEvent()),
child: WeightScreen());
}
@@ -72,7 +75,7 @@ class _WeightScreenState extends State<WeightScreen> {
imagePath: ImageConstant.imgFavorite,
height: 12.adaptSize,
width: 12.adaptSize)),
hintText: "70",
hintText: "Не выбрано",
items: weightModelObj?.dropdownItemList ?? [],
onChanged: (value) {
context
@@ -83,12 +86,23 @@ class _WeightScreenState extends State<WeightScreen> {
])
]),
Spacer(),
NextStepButton(
text: "continue".tr.toUpperCase(),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
navigateToHeight(context);
}),
BlocBuilder<WeightBloc, WeightState>(
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.weightModelObj!.userRegistrationSheet;
Navigator.pushNamed(
context,
AppRoutes.heightScreen,
arguments: sheet,
);
});
}),
SizedBox(height: 17.v),
]))));
}