diff --git a/lib/presentation/registration/additional_information_screen/additional_information_screen.dart b/lib/presentation/registration/additional_information_screen/additional_information_screen.dart index 2e2201f..345af29 100644 --- a/lib/presentation/registration/additional_information_screen/additional_information_screen.dart +++ b/lib/presentation/registration/additional_information_screen/additional_information_screen.dart @@ -66,29 +66,32 @@ class AdditionalInformationScreen extends StatelessWidget { margin: EdgeInsets.only( left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () async { - UserRegistrationSheet sheet = state - .additionalInformationModelObj! - .userRegistrationSheet; - sheet.additionalInfo = state.editTextController!.text; - final response = await http.post( - Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'), - headers: {'Content-Type': 'application/json'}, - body: json.encode(sheet), - ); - var res = await jsonDecode(response.body); - final box = await Hive.openBox('token'); - final token = res['token']; - box.put('token', token); - Navigator.pushNamed( - context, - AppRoutes.myProfile, - ); - }); + onPressed: onTapFinish(state, context)); }), ])))); } + onTapFinish(AdditionalInformationState state, BuildContext context) { + return () async { + UserRegistrationSheet sheet = + state.additionalInformationModelObj!.userRegistrationSheet; + sheet.additionalInfo = state.editTextController!.text; + final response = await http.post( + Uri.parse(dotenv.env['SERVER_ROOT']! + '/register'), + headers: {'Content-Type': 'application/json'}, + body: json.encode(sheet), + ); + var res = await jsonDecode(response.body); + final box = await Hive.openBox('token'); + final token = res['token']; + box.put('token', token); + Navigator.pushNamed( + context, + AppRoutes.myProfile, + ); + }; + } + /// Section Widget _buildAppBar(BuildContext context) { return CustomAppBar( @@ -96,15 +99,19 @@ class AdditionalInformationScreen extends StatelessWidget { leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 18.h, top: 15.v, bottom: 15.v), - onTap: () { - onTapArrowLeft(context); - }), + onTap: onTapBack(context)), centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } + onTapBack(BuildContext context) { + return () { + onTapArrowLeft(context); + }; + } + /// Section Widget - Widget _buildTextFormField(BuildContext context) { + _buildTextFormField(BuildContext context) { return SizedBox( height: 257.v, width: 343.h, @@ -147,12 +154,14 @@ class AdditionalInformationScreen extends StatelessWidget { title: const Text('Регистрация завершена!'), content: const Text('1'), actions: [ - TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: const Text('Ok')) + TextButton(onPressed: onTapOk(context), child: const Text('Ok')) ], )); } + + onTapOk(BuildContext context) { + return () { + Navigator.pop(context); + }; + } } diff --git a/lib/presentation/registration/allergies_screen/allergies_screen.dart b/lib/presentation/registration/allergies_screen/allergies_screen.dart index 358b6ae..9f4c6b0 100644 --- a/lib/presentation/registration/allergies_screen/allergies_screen.dart +++ b/lib/presentation/registration/allergies_screen/allergies_screen.dart @@ -67,36 +67,43 @@ class _AllergiesScreenState extends State { margin: EdgeInsets.only( left: 16.h, right: 16.h, bottom: 50.v), buttonStyle: CustomButtonStyles.outlinePrimaryTL15, - onPressed: () { - UserRegistrationSheet sheet = - state.allergiesModelObj!.userRegistrationSheet; - sheet.aboutAllergy = - state.enterInformationController!.text; - Navigator.pushNamed( - context, - AppRoutes.medicineIntakeScreen, - arguments: sheet, - ); - }); + onPressed: onTapContinue(state, context)); }), BlocBuilder( builder: (context, state) { return GestureDetector( - onTap: () { - UserRegistrationSheet sheet = - state.allergiesModelObj!.userRegistrationSheet; - Navigator.pushNamed( - context, - AppRoutes.medicineIntakeScreen, - arguments: sheet, - ); - }, + onTap: onTapSkip(state, context), child: Text("skip".tr, style: theme.textTheme.bodyLarge), ); }), ])))); } + onTapSkip(AllergiesState state, BuildContext context) { + return () { + UserRegistrationSheet sheet = + state.allergiesModelObj!.userRegistrationSheet; + Navigator.pushNamed( + context, + AppRoutes.medicineIntakeScreen, + arguments: sheet, + ); + }; + } + + onTapContinue(AllergiesState state, BuildContext context) { + return () { + UserRegistrationSheet sheet = + state.allergiesModelObj!.userRegistrationSheet; + sheet.aboutAllergy = state.enterInformationController!.text; + Navigator.pushNamed( + context, + AppRoutes.medicineIntakeScreen, + arguments: sheet, + ); + }; + } + /// Section Widget _buildAppBar(BuildContext context) { return CustomAppBar( @@ -104,15 +111,19 @@ class _AllergiesScreenState extends State { leading: AppbarLeadingImage( imagePath: ImageConstant.imgArrowLeft, margin: EdgeInsets.only(left: 18.h, top: 15.v, bottom: 15.v), - onTap: () { - onTapArrowLeft(context); - }), + onTap: onTapBack(context)), centerTitle: true, title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio)); } + onTapBack(BuildContext context) { + return () { + onTapArrowLeft(context); + }; + } + /// Section Widget - Widget _buildTextFormField(BuildContext context) { + _buildTextFormField(BuildContext context) { return Column(children: [ Text("fill_in_information".tr, style: CustomTextStyles.titleMediumSegoeUI), diff --git a/lib/presentation/registration/app_navigation_screen/app_navigation_screen.dart b/lib/presentation/registration/app_navigation_screen/app_navigation_screen.dart index 5dd89c2..ec34e36 100644 --- a/lib/presentation/registration/app_navigation_screen/app_navigation_screen.dart +++ b/lib/presentation/registration/app_navigation_screen/app_navigation_screen.dart @@ -151,7 +151,7 @@ class _AppNavigationScreenState extends State { } /// Section Widget - Widget _buildAppNavigation(BuildContext context) { + _buildAppNavigation(BuildContext context) { return Container( decoration: BoxDecoration( color: Color(0XFFFFFFFF), @@ -205,15 +205,13 @@ class _AppNavigationScreenState extends State { } /// Common widget - Widget _buildScreenTitle( + _buildScreenTitle( BuildContext context, { required String screenTitle, Function? onTapScreenTitle, }) { return GestureDetector( - onTap: () { - onTapScreenTitle!.call(); - }, + onTap: onTapScreenTitle!.call(), child: Container( decoration: BoxDecoration( color: Color(0XFFFFFFFF),