From 5d7467db5141f8111ccf741f2b48e7915a5245fd Mon Sep 17 00:00:00 2001 From: maxxkim Date: Tue, 5 Mar 2024 14:44:04 +0300 Subject: [PATCH] refactor(diary): Revenge of the Refactoring --- .../weight_screen/weight_screen.dart | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/presentation/registration/weight_screen/weight_screen.dart b/lib/presentation/registration/weight_screen/weight_screen.dart index ab936350..64cec0a3 100644 --- a/lib/presentation/registration/weight_screen/weight_screen.dart +++ b/lib/presentation/registration/weight_screen/weight_screen.dart @@ -77,11 +77,7 @@ class _WeightScreenState extends State { width: 12.adaptSize)), hintText: "Не выбрано", items: weightModelObj?.dropdownItemList ?? [], - onChanged: (value) { - context - .read() - .add(ChangeDropDownEvent(value: value)); - }); + onChanged: _onDropDownChanged); }) ]) ]), @@ -93,29 +89,19 @@ class _WeightScreenState extends State { 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, - ); - }); + onPressed: onTapNext(context, state)); }), ])))); } /// 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: onTapArrowLeft(context)), centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } @@ -125,10 +111,23 @@ class _WeightScreenState extends State { NavigatorService.goBack(); } + onTapNext(BuildContext context, state) { + UserRegistrationSheet sheet = state.weightModelObj!.userRegistrationSheet; + Navigator.pushNamed( + context, + AppRoutes.heightScreen, + arguments: sheet, + ); + } + /// Navigates to the allergiesScreen when the action is triggered. navigateToHeight(BuildContext context) { NavigatorService.pushNamed( AppRoutes.heightScreen, ); } + + void _onDropDownChanged(value) { + context.read().add(ChangeDropDownEvent(value: value)); + } }