Added height screen for registration & set adequate options and initial parameters for height/weight
This commit is contained in:
@@ -14,7 +14,7 @@ final Map<String, String> enUs = {
|
||||
|
||||
// weight Screen
|
||||
"weight_measurements": "Weight measurements", "your_weight": "Your weight:",
|
||||
"lbl_70": "70",
|
||||
"height_measurements": "Height measurements", "your_height": "Your height:",
|
||||
|
||||
// allergies Screen
|
||||
"allergies_presence": "Allergies presence",
|
||||
|
||||
@@ -13,7 +13,7 @@ final Map<String, String> ru = {
|
||||
|
||||
// weight Screen
|
||||
"weight_measurements": "Замер веса", "your_weight": "Ваш вес:",
|
||||
"lbl_70": "70",
|
||||
"height_measurements": "Замер роста", "your_height": "Ваш рост:",
|
||||
|
||||
// allergies Screen
|
||||
"allergies_presence": "Наличие аллергии",
|
||||
|
||||
@@ -109,7 +109,7 @@ class DateOfBirthScreen extends StatelessWidget {
|
||||
onTap: () {
|
||||
openDatePickerDialog(context);
|
||||
},
|
||||
child: Text("lbl_01_01_2000".tr,
|
||||
child: Text('ТУТ БУДЕТ ДАТА'.tr,
|
||||
style: theme.textTheme.titleMedium))),
|
||||
SizedBox(height: 6.v)
|
||||
]));
|
||||
|
||||
40
lib/presentation/height_screen/bloc/height_bloc.dart
Normal file
40
lib/presentation/height_screen/bloc/height_bloc.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/height_screen/models/height_model.dart';
|
||||
part 'height_event.dart';
|
||||
part 'height_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a Height according to the event that is dispatched to it.
|
||||
class HeightBloc extends Bloc<HeightEvent, HeightState> {
|
||||
HeightBloc(HeightState initialState) : super(initialState) {
|
||||
on<HeightInitialEvent>(_onInitialize);
|
||||
on<ChangeDropDownEvent>(_changeDropDown);
|
||||
}
|
||||
|
||||
_onInitialize(
|
||||
HeightInitialEvent event,
|
||||
Emitter<HeightState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(
|
||||
heightModelObj: state.heightModelObj
|
||||
?.copyWith(dropdownItemList: fillDropdownItemList())));
|
||||
}
|
||||
|
||||
_changeDropDown(
|
||||
ChangeDropDownEvent event,
|
||||
Emitter<HeightState> emit,
|
||||
) {
|
||||
emit(state.copyWith(selectedDropDownValue: event.value));
|
||||
}
|
||||
|
||||
List<SelectionPopupModel> fillDropdownItemList() {
|
||||
List<SelectionPopupModel> selectionPopupModels = [];
|
||||
|
||||
for (int i = 140; i <= 220; i++) {
|
||||
selectionPopupModels
|
||||
.add(SelectionPopupModel(id: i - 34, title: i.toString()));
|
||||
}
|
||||
return selectionPopupModels;
|
||||
}
|
||||
}
|
||||
28
lib/presentation/height_screen/bloc/height_event.dart
Normal file
28
lib/presentation/height_screen/bloc/height_event.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'height_bloc.dart';
|
||||
|
||||
/// Abstract class for all events that can be dispatched from the
|
||||
///Height widget.
|
||||
///
|
||||
/// Events must be immutable and implement the [Equatable] interface.
|
||||
@immutable
|
||||
abstract class HeightEvent extends Equatable {}
|
||||
|
||||
/// Event that is dispatched when the Height widget is first created.
|
||||
class HeightInitialEvent extends HeightEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
///event for dropdown selection
|
||||
class ChangeDropDownEvent extends HeightEvent {
|
||||
ChangeDropDownEvent({required this.value});
|
||||
|
||||
SelectionPopupModel value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
value,
|
||||
];
|
||||
}
|
||||
31
lib/presentation/height_screen/bloc/height_state.dart
Normal file
31
lib/presentation/height_screen/bloc/height_state.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'height_bloc.dart';
|
||||
|
||||
/// Represents the state of Height in the application.
|
||||
class HeightState extends Equatable {
|
||||
HeightState({
|
||||
this.selectedDropDownValue,
|
||||
this.heightModelObj,
|
||||
});
|
||||
|
||||
SelectionPopupModel? selectedDropDownValue;
|
||||
|
||||
HeightModel? heightModelObj;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
selectedDropDownValue,
|
||||
heightModelObj,
|
||||
];
|
||||
HeightState copyWith({
|
||||
SelectionPopupModel? selectedDropDownValue,
|
||||
HeightModel? heightModelObj,
|
||||
}) {
|
||||
return HeightState(
|
||||
selectedDropDownValue:
|
||||
selectedDropDownValue ?? this.selectedDropDownValue,
|
||||
heightModelObj: heightModelObj ?? this.heightModelObj,
|
||||
);
|
||||
}
|
||||
}
|
||||
124
lib/presentation/height_screen/height_screen.dart
Normal file
124
lib/presentation/height_screen/height_screen.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'bloc/height_bloc.dart';
|
||||
import 'models/height_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
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/custom_outlined_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class HeightScreen extends StatelessWidget {
|
||||
const HeightScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<HeightBloc>(
|
||||
create: (context) =>
|
||||
HeightBloc(HeightState(heightModelObj: HeightModel()))
|
||||
..add(HeightInitialEvent()),
|
||||
child: HeightScreen());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: _buildAppBar(context),
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(children: [
|
||||
SizedBox(height: 7.v),
|
||||
Container(
|
||||
height: 16.v,
|
||||
width: 343.h,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary, width: 1.h)),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0.35,
|
||||
backgroundColor: theme.colorScheme.onPrimary,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
appTheme.blueA400)))),
|
||||
SizedBox(height: 39.v),
|
||||
_buildTwentySix(context),
|
||||
Spacer(),
|
||||
CustomOutlinedButton(
|
||||
text: "continue".tr.toUpperCase(),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: () {
|
||||
navigateToAllergies(context);
|
||||
}),
|
||||
SizedBox(height: 17.v),
|
||||
Text("skip".tr, style: theme.textTheme.bodyLarge)
|
||||
]))));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
PreferredSizeWidget _buildAppBar(BuildContext context) {
|
||||
return CustomAppBar(
|
||||
leadingWidth: 29.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: () {
|
||||
onTapArrowLeft(context);
|
||||
}),
|
||||
centerTitle: true,
|
||||
title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildTwentySixWidget(BuildContext context) {
|
||||
return Column(children: [
|
||||
Text("your_height".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 4.v),
|
||||
BlocSelector<HeightBloc, HeightState, HeightModel?>(
|
||||
selector: (state) => state.heightModelObj,
|
||||
builder: (context, heightModelObj) {
|
||||
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: "170",
|
||||
items: heightModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) {
|
||||
context
|
||||
.read<HeightBloc>()
|
||||
.add(ChangeDropDownEvent(value: value));
|
||||
});
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildTwentySix(BuildContext context) {
|
||||
return Column(children: [
|
||||
Text("height_measurements".tr, style: theme.textTheme.headlineSmall),
|
||||
SizedBox(height: 174.v),
|
||||
_buildTwentySixWidget(context)
|
||||
]);
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
|
||||
/// Navigates to the allergiesScreen when the action is triggered.
|
||||
navigateToAllergies(BuildContext context) {
|
||||
NavigatorService.pushNamed(
|
||||
AppRoutes.allergiesScreen,
|
||||
);
|
||||
}
|
||||
}
|
||||
21
lib/presentation/height_screen/models/height_model.dart
Normal file
21
lib/presentation/height_screen/models/height_model.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_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 []}) {}
|
||||
|
||||
List<SelectionPopupModel> dropdownItemList;
|
||||
|
||||
HeightModel copyWith({List<SelectionPopupModel>? dropdownItemList}) {
|
||||
return HeightModel(
|
||||
dropdownItemList: dropdownItemList ?? this.dropdownItemList,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [dropdownItemList];
|
||||
}
|
||||
@@ -29,10 +29,12 @@ class WeightBloc extends Bloc<WeightEvent, WeightState> {
|
||||
}
|
||||
|
||||
List<SelectionPopupModel> fillDropdownItemList() {
|
||||
return [
|
||||
SelectionPopupModel(id: 1, title: "Item One", isSelected: true),
|
||||
SelectionPopupModel(id: 2, title: "Item Two"),
|
||||
SelectionPopupModel(id: 3, title: "Item Three")
|
||||
];
|
||||
List<SelectionPopupModel> selectionPopupModels = [];
|
||||
|
||||
for (int i = 35; i <= 200; i++) {
|
||||
selectionPopupModels
|
||||
.add(SelectionPopupModel(id: i - 34, title: i.toString()));
|
||||
}
|
||||
return selectionPopupModels;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class WeightScreen extends StatelessWidget {
|
||||
text: "continue".tr.toUpperCase(),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: () {
|
||||
navigateToAllergies(context);
|
||||
navigateToHeight(context);
|
||||
}),
|
||||
SizedBox(height: 17.v),
|
||||
Text("skip".tr, style: theme.textTheme.bodyLarge)
|
||||
@@ -90,7 +90,7 @@ class WeightScreen extends StatelessWidget {
|
||||
imagePath: ImageConstant.imgFavorite,
|
||||
height: 12.adaptSize,
|
||||
width: 12.adaptSize)),
|
||||
hintText: "lbl_70".tr,
|
||||
hintText: "70",
|
||||
items: weightModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) {
|
||||
context
|
||||
@@ -116,9 +116,9 @@ class WeightScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// Navigates to the allergiesScreen when the action is triggered.
|
||||
navigateToAllergies(BuildContext context) {
|
||||
navigateToHeight(BuildContext context) {
|
||||
NavigatorService.pushNamed(
|
||||
AppRoutes.allergiesScreen,
|
||||
AppRoutes.heightScreen,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,12 @@ import 'package:eatvio_app/presentation/favorite_foods_screen/favorite_foods_scr
|
||||
import 'package:eatvio_app/presentation/schedule_screen/schedule_screen.dart';
|
||||
import 'package:eatvio_app/presentation/additional_information_screen/additional_information_screen.dart';
|
||||
import 'package:eatvio_app/presentation/language_select_screen/language_select_screen.dart';
|
||||
import 'package:eatvio_app/presentation/height_screen/height_screen.dart';
|
||||
import 'package:eatvio_app/presentation/app_navigation_screen/app_navigation_screen.dart';
|
||||
|
||||
class AppRoutes {
|
||||
// REGISTRATION
|
||||
|
||||
static const String dateOfBirthScreen = '/date_of_birth_screen';
|
||||
|
||||
static const String cityOfLivingScreen = '/city_of_living_screen';
|
||||
@@ -24,6 +27,8 @@ class AppRoutes {
|
||||
|
||||
static const String weightScreen = '/weight_screen';
|
||||
|
||||
static const String heightScreen = '/height_screen';
|
||||
|
||||
static const String allergiesScreen = '/allergies_screen';
|
||||
|
||||
static const String medicineIntakeScreen = '/medicine_intake_screen';
|
||||
@@ -54,6 +59,7 @@ class AppRoutes {
|
||||
cityOfLivingScreen: CityOfLivingScreen.builder,
|
||||
bodyCircumferencesScreen: BodyCircumferencesScreen.builder,
|
||||
weightScreen: WeightScreen.builder,
|
||||
heightScreen: HeightScreen.builder,
|
||||
allergiesScreen: AllergiesScreen.builder,
|
||||
medicineIntakeScreen: MedicineIntakeScreen.builder,
|
||||
splashScreen: SplashScreen.builder,
|
||||
|
||||
Reference in New Issue
Block a user