diff --git a/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart b/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart index 8374c74..cb23b28 100644 --- a/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart +++ b/lib/presentation/registration/favorite_sports_screen/favorite_sports_screen.dart @@ -71,31 +71,12 @@ class _FavoriteSportsScreenState extends State { margin: EdgeInsets.only( left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - UserRegistrationSheet sheet = state - .favoriteSportsModelObj! - .userRegistrationSheet; - sheet.aboutSportHobbies = - state.enterinformationController!.text; - Navigator.pushNamed( - context, - AppRoutes.favoriteFoodsScreen, - arguments: sheet, - ); - }); + onPressed: onTapContinue(state, context)); }), BlocBuilder( builder: (context, state) { return GestureDetector( - onTap: () { - UserRegistrationSheet sheet = state - .favoriteSportsModelObj!.userRegistrationSheet; - Navigator.pushNamed( - context, - AppRoutes.favoriteFoodsScreen, - arguments: sheet, - ); - }, + onTap: onTapSkip(state, context), child: Text("skip".tr, style: theme.textTheme.bodyLarge), ); @@ -103,21 +84,50 @@ class _FavoriteSportsScreenState extends State { ])))); } - PreferredSizeWidget _buildAppBar(BuildContext context) { + onTapSkip(FavoriteSportsState state, BuildContext context) { + return () { + UserRegistrationSheet sheet = + state.favoriteSportsModelObj!.userRegistrationSheet; + Navigator.pushNamed( + context, + AppRoutes.favoriteFoodsScreen, + arguments: sheet, + ); + }; + } + + onTapContinue(FavoriteSportsState state, BuildContext context) { + return () { + UserRegistrationSheet sheet = + state.favoriteSportsModelObj!.userRegistrationSheet; + sheet.aboutSportHobbies = state.enterinformationController!.text; + Navigator.pushNamed( + context, + AppRoutes.favoriteFoodsScreen, + arguments: sheet, + ); + }; + } + + _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); - }), + onTap: onTapBack(context)), centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } + Function onTapBack(BuildContext context) { + return () { + onTapArrowLeft(context); + }; + } + /// Section Widget - Widget _buildTextFormFieldSection(BuildContext context) { + _buildTextFormFieldSection(BuildContext context) { return Column(children: [ Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), diff --git a/lib/presentation/registration/gender_screen/gender_screen.dart b/lib/presentation/registration/gender_screen/gender_screen.dart index 34dcc85..1db99ac 100644 --- a/lib/presentation/registration/gender_screen/gender_screen.dart +++ b/lib/presentation/registration/gender_screen/gender_screen.dart @@ -63,10 +63,7 @@ class _GenderScreenState extends State { title: Text('Мужской'), value: 'male', groupValue: state.selectedRadioValue, - onChanged: (value) { - BlocProvider.of(context) - .add(GenderSelectEvent(value: 'male')); - }, + onChanged: onMale(context), secondary: Image.asset( 'assets/images/img_male.png', width: 40, @@ -77,10 +74,7 @@ class _GenderScreenState extends State { title: Text('Женский'), value: 'female', groupValue: state.selectedRadioValue, - onChanged: (value) { - BlocProvider.of(context) - .add(GenderSelectEvent(value: 'female')); - }, + onChanged: onFemale(context), secondary: Image.asset( 'assets/images/img_female.png', width: 40, @@ -95,37 +89,58 @@ class _GenderScreenState extends State { margin: EdgeInsets.only( left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - UserRegistrationSheet sheet = - state.genderModelObj!.userRegistrationSheet; - sheet.gender = state.selectedRadioValue!; - Navigator.pushNamed( - context, - AppRoutes.dateOfBirthScreen, - arguments: sheet, - ); - }); + onPressed: onTapNext(state, context)); }), ])))); }); } + onTapNext(GenderState state, BuildContext context) { + return () { + UserRegistrationSheet sheet = state.genderModelObj!.userRegistrationSheet; + sheet.gender = state.selectedRadioValue!; + Navigator.pushNamed( + context, + AppRoutes.dateOfBirthScreen, + arguments: sheet, + ); + }; + } + + onMale(BuildContext context) { + return (value) { + BlocProvider.of(context) + .add(GenderSelectEvent(value: 'male')); + }; + } + + onFemale(BuildContext context) { + return (value) { + BlocProvider.of(context) + .add(GenderSelectEvent(value: 'female')); + }; + } + /// Section Widget - PreferredSizeWidget _buildAppBar(BuildContext context) { + _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: () { - NavigatorService.pushNamed( - AppRoutes.dateOfBirthScreen, - ); - }), + onTap: onTapBack()), centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } + Function onTapBack() { + return () { + NavigatorService.pushNamed( + AppRoutes.dateOfBirthScreen, + ); + }; + } + /// Navigates to the previous screen. onTapArrowLeft(BuildContext context) { NavigatorService.goBack(); diff --git a/lib/presentation/registration/height_screen/height_screen.dart b/lib/presentation/registration/height_screen/height_screen.dart index 574bf48..9cb66c2 100644 --- a/lib/presentation/registration/height_screen/height_screen.dart +++ b/lib/presentation/registration/height_screen/height_screen.dart @@ -77,11 +77,7 @@ class _HeightScreenState extends State { width: 12.adaptSize)), hintText: "170", items: heightModelObj?.dropdownItemList ?? [], - onChanged: (value) { - context - .read() - .add(ChangeDropDownEvent(value: value)); - }); + onChanged: newMethod(context)); }) ]) ]), @@ -93,33 +89,46 @@ class _HeightScreenState extends State { 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.bloodPressureScreen, - arguments: sheet, - ); - }); + onPressed: onTapNext(state, context)); }), ])))); } + newMethod(BuildContext context) { + return (value) { + context.read().add(ChangeDropDownEvent(value: value)); + }; + } + + onTapNext(HeightState state, BuildContext context) { + return () { + UserRegistrationSheet sheet = state.heightModelObj!.userRegistrationSheet; + Navigator.pushNamed( + context, + AppRoutes.bloodPressureScreen, + arguments: sheet, + ); + }; + } + /// Section Widget - PreferredSizeWidget _buildAppBar(BuildContext context) { + _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); - }), + 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();