diff --git a/lib/presentation/registration/height_screen/bloc/height_bloc.dart b/lib/presentation/registration/height_screen/bloc/height_bloc.dart index f9330fd6..70b8ba60 100644 --- a/lib/presentation/registration/height_screen/bloc/height_bloc.dart +++ b/lib/presentation/registration/height_screen/bloc/height_bloc.dart @@ -9,7 +9,6 @@ part 'height_state.dart'; class HeightBloc extends Bloc { HeightBloc(HeightState initialState) : super(initialState) { on(_onInitialize); - on(_changeDropDown); } _onInitialize( @@ -17,25 +16,7 @@ class HeightBloc extends Bloc { Emitter emit, ) async { emit(state.copyWith( - heightModelObj: state.heightModelObj - ?.copyWith(dropdownItemList: fillDropdownItemList()))); - } - - _changeDropDown( - ChangeDropDownEvent event, - Emitter emit, - ) { - emit(state.copyWith(selectedDropDownValue: event.value)); - state.heightModelObj?.userRegistrationSheet.height = event.value.title; - } - - List fillDropdownItemList() { - List selectionPopupModels = []; - - for (int i = 140; i <= 220; i++) { - selectionPopupModels - .add(SelectionPopupModel(id: i - 34, title: i.toString())); - } - return selectionPopupModels; + heightModelObj: state.heightModelObj?.copyWith(), + heightController: state.heightController)); } } diff --git a/lib/presentation/registration/height_screen/bloc/height_event.dart b/lib/presentation/registration/height_screen/bloc/height_event.dart index 80d209c4..1d65dd82 100644 --- a/lib/presentation/registration/height_screen/bloc/height_event.dart +++ b/lib/presentation/registration/height_screen/bloc/height_event.dart @@ -14,15 +14,3 @@ class HeightInitialEvent extends HeightEvent { @override List get props => []; } - -///event for dropdown selection -class ChangeDropDownEvent extends HeightEvent { - ChangeDropDownEvent({required this.value}); - - SelectionPopupModel value; - - @override - List get props => [ - value, - ]; -} diff --git a/lib/presentation/registration/height_screen/bloc/height_state.dart b/lib/presentation/registration/height_screen/bloc/height_state.dart index d0e3f45d..aa10592f 100644 --- a/lib/presentation/registration/height_screen/bloc/height_state.dart +++ b/lib/presentation/registration/height_screen/bloc/height_state.dart @@ -5,26 +5,25 @@ part of 'height_bloc.dart'; /// Represents the state of Height in the application. class HeightState extends Equatable { HeightState({ - this.selectedDropDownValue, + this.heightController, this.heightModelObj, }); - SelectionPopupModel? selectedDropDownValue; + TextEditingController? heightController; HeightModel? heightModelObj; @override List get props => [ - selectedDropDownValue, + heightController, heightModelObj, ]; HeightState copyWith({ - SelectionPopupModel? selectedDropDownValue, + TextEditingController? heightController, HeightModel? heightModelObj, }) { return HeightState( - selectedDropDownValue: - selectedDropDownValue ?? this.selectedDropDownValue, + heightController: heightController ?? this.heightController, heightModelObj: heightModelObj ?? this.heightModelObj, ); } diff --git a/lib/presentation/registration/height_screen/height_screen.dart b/lib/presentation/registration/height_screen/height_screen.dart index 9cb66c29..f5bafcb6 100644 --- a/lib/presentation/registration/height_screen/height_screen.dart +++ b/lib/presentation/registration/height_screen/height_screen.dart @@ -4,12 +4,13 @@ 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_text_form_field.dart'; +import 'package:flutter/services.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 HeightScreen extends StatefulWidget { +class HeightScreen extends StatelessWidget { const HeightScreen({Key? key}) : super(key: key); static Widget builder(BuildContext context) { @@ -22,82 +23,91 @@ class HeightScreen extends StatefulWidget { child: HeightScreen()); } - @override - State createState() => _HeightScreenState(); -} - -class _HeightScreenState extends State { @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.55, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400)))), - SizedBox(height: 39.v), - Column(children: [ - Text("height_measurements".tr, - style: theme.textTheme.headlineSmall), - SizedBox(height: 174.v), - Column(children: [ - Text("your_height".tr, style: theme.textTheme.bodyLarge), + 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.55, + backgroundColor: theme.colorScheme.onPrimary, + valueColor: AlwaysStoppedAnimation( + appTheme.blueA400, + ), + ), + ), + ), + SizedBox(height: 39.v), + Column( + children: [ + Text( + "height_measurements".tr, + style: theme.textTheme.headlineSmall, + ), + SizedBox(height: 174.v), + Column( + children: [ + Text( + "your_height".tr, + style: theme.textTheme.bodyLarge, + ), SizedBox(height: 4.v), - BlocSelector( - 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: newMethod(context)); - }) - ]) - ]), - Spacer(), - 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: onTapNext(state, context)); - }), - ])))); - } - - newMethod(BuildContext context) { - return (value) { - context.read().add(ChangeDropDownEvent(value: value)); - }; + BlocBuilder( + builder: (context, state) { + return CustomTextFormField( + width: 150.h, + textInputAction: TextInputAction.done, + controller: state.heightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + ); + }) + ], + ), + ], + ), + Spacer(), + 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: onTapNext(state, context), + ); + }, + ), + ], + ), + ), + ), + ); } onTapNext(HeightState state, BuildContext context) { diff --git a/lib/presentation/registration/weight_screen/bloc/weight_bloc.dart b/lib/presentation/registration/weight_screen/bloc/weight_bloc.dart index bf2cc1f9..69161cce 100644 --- a/lib/presentation/registration/weight_screen/bloc/weight_bloc.dart +++ b/lib/presentation/registration/weight_screen/bloc/weight_bloc.dart @@ -9,7 +9,6 @@ part 'weight_state.dart'; class WeightBloc extends Bloc { WeightBloc(WeightState initialState) : super(initialState) { on(_onInitialize); - on(_changeDropDown); } _onInitialize( @@ -17,25 +16,7 @@ class WeightBloc extends Bloc { Emitter emit, ) async { emit(state.copyWith( - weightModelObj: state.weightModelObj - ?.copyWith(dropdownItemList: fillDropdownItemList()))); - } - - _changeDropDown( - ChangeDropDownEvent event, - Emitter emit, - ) { - emit(state.copyWith(selectedDropDownValue: event.value)); - state.weightModelObj?.userRegistrationSheet.weight = event.value.title; - } - - List fillDropdownItemList() { - List selectionPopupModels = []; - - for (int i = 35; i <= 200; i++) { - selectionPopupModels - .add(SelectionPopupModel(id: i - 34, title: i.toString())); - } - return selectionPopupModels; + weightModelObj: state.weightModelObj?.copyWith(), + weightController: state.weightController)); } } diff --git a/lib/presentation/registration/weight_screen/bloc/weight_event.dart b/lib/presentation/registration/weight_screen/bloc/weight_event.dart index 93b69d22..1b554c5e 100644 --- a/lib/presentation/registration/weight_screen/bloc/weight_event.dart +++ b/lib/presentation/registration/weight_screen/bloc/weight_event.dart @@ -14,15 +14,3 @@ class WeightInitialEvent extends WeightEvent { @override List get props => []; } - -///event for dropdown selection -class ChangeDropDownEvent extends WeightEvent { - ChangeDropDownEvent({required this.value}); - - SelectionPopupModel value; - - @override - List get props => [ - value, - ]; -} diff --git a/lib/presentation/registration/weight_screen/bloc/weight_state.dart b/lib/presentation/registration/weight_screen/bloc/weight_state.dart index 06b9c2cf..5d782dfd 100644 --- a/lib/presentation/registration/weight_screen/bloc/weight_state.dart +++ b/lib/presentation/registration/weight_screen/bloc/weight_state.dart @@ -5,26 +5,25 @@ part of 'weight_bloc.dart'; /// Represents the state of Weight in the application. class WeightState extends Equatable { WeightState({ - this.selectedDropDownValue, + this.weightController, this.weightModelObj, }); - SelectionPopupModel? selectedDropDownValue; + TextEditingController? weightController; WeightModel? weightModelObj; @override List get props => [ - selectedDropDownValue, + weightController, weightModelObj, ]; WeightState copyWith({ - SelectionPopupModel? selectedDropDownValue, + TextEditingController? weightController, WeightModel? weightModelObj, }) { return WeightState( - selectedDropDownValue: - selectedDropDownValue ?? this.selectedDropDownValue, + weightController: weightController ?? this.weightController, weightModelObj: weightModelObj ?? this.weightModelObj, ); } diff --git a/lib/presentation/registration/weight_screen/weight_screen.dart b/lib/presentation/registration/weight_screen/weight_screen.dart index f26fe3de..c68ccb83 100644 --- a/lib/presentation/registration/weight_screen/weight_screen.dart +++ b/lib/presentation/registration/weight_screen/weight_screen.dart @@ -4,12 +4,13 @@ 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_text_form_field.dart'; +import 'package:flutter/services.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 { +class WeightScreen extends StatelessWidget { const WeightScreen({Key? key}) : super(key: key); static Widget builder(BuildContext context) { @@ -22,96 +23,94 @@ class WeightScreen extends StatefulWidget { child: WeightScreen()); } - @override - State createState() => _WeightScreenState(); -} - -class _WeightScreenState extends State { @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.48, - backgroundColor: theme.colorScheme.onPrimary, - valueColor: AlwaysStoppedAnimation( - appTheme.blueA400)))), - SizedBox(height: 39.v), - Column(children: [ - Text("weight_measurements".tr, - style: theme.textTheme.headlineSmall), - SizedBox(height: 174.v), - Column(children: [ - Text("your_weight".tr, style: theme.textTheme.bodyLarge), + 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.55, + backgroundColor: theme.colorScheme.onPrimary, + valueColor: AlwaysStoppedAnimation( + appTheme.blueA400, + ), + ), + ), + ), + SizedBox(height: 39.v), + Column( + children: [ + Text( + "weight_measurements".tr, + style: theme.textTheme.headlineSmall, + ), + SizedBox(height: 174.v), + Column( + children: [ + Text( + "your_weight".tr, + style: theme.textTheme.bodyLarge, + ), SizedBox(height: 4.v), - BlocSelector( - selector: (state) => state.weightModelObj, - builder: (context, weightModelObj) { - 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: "Не выбрано", - items: weightModelObj?.dropdownItemList ?? [], - onChanged: _onDropDownChanged); - }) - ]) - ]), - Spacer(), - 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: onTapNext(context, state)); - }), - ])))); + BlocBuilder( + builder: (context, state) { + return CustomTextFormField( + width: 150.h, + textInputAction: TextInputAction.done, + controller: state.weightController, + keyboardType: TextInputType.number, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + ], + ); + }) + ], + ), + ], + ), + Spacer(), + 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: onTapNext(state, context), + ); + }, + ), + ], + ), + ), + ), + ); } - /// Section Widget - _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)); - } - - /// Navigates to the previous screen. - onTapArrowLeft(BuildContext context) { - NavigatorService.goBack(); - } - - onTapNext(BuildContext context, WeightState state) { + onTapNext(WeightState state, BuildContext context) { return () { UserRegistrationSheet sheet = state.weightModelObj!.userRegistrationSheet; Navigator.pushNamed( @@ -122,7 +121,26 @@ class _WeightScreenState extends State { }; } - void _onDropDownChanged(value) { - context.read().add(ChangeDropDownEvent(value: value)); + /// Section Widget + _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: onTapBack(context)), + centerTitle: true, + title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); + } + + Function onTapBack(BuildContext context) { + return () { + onTapArrowLeft(context); + }; + } + + /// Navigates to the previous screen. + onTapArrowLeft(BuildContext context) { + NavigatorService.goBack(); } }