refactor(diary): Another efatoring

This commit is contained in:
2024-03-05 15:26:35 +03:00
parent 59db676f7a
commit 2723861b04
3 changed files with 102 additions and 68 deletions

View File

@@ -71,31 +71,12 @@ class _FavoriteSportsScreenState extends State<FavoriteSportsScreen> {
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<FavoriteSportsBloc, FavoriteSportsState>(
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<FavoriteSportsScreen> {
]))));
}
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),

View File

@@ -63,10 +63,7 @@ class _GenderScreenState extends State<GenderScreen> {
title: Text('Мужской'),
value: 'male',
groupValue: state.selectedRadioValue,
onChanged: (value) {
BlocProvider.of<GenderBloc>(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<GenderScreen> {
title: Text('Женский'),
value: 'female',
groupValue: state.selectedRadioValue,
onChanged: (value) {
BlocProvider.of<GenderBloc>(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<GenderScreen> {
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<GenderBloc>(context)
.add(GenderSelectEvent(value: 'male'));
};
}
onFemale(BuildContext context) {
return (value) {
BlocProvider.of<GenderBloc>(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();

View File

@@ -77,11 +77,7 @@ class _HeightScreenState extends State<HeightScreen> {
width: 12.adaptSize)),
hintText: "170",
items: heightModelObj?.dropdownItemList ?? [],
onChanged: (value) {
context
.read<HeightBloc>()
.add(ChangeDropDownEvent(value: value));
});
onChanged: newMethod(context));
})
])
]),
@@ -93,33 +89,46 @@ class _HeightScreenState extends State<HeightScreen> {
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<HeightBloc>().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();