refactor(diary): Refactoring forever

This commit is contained in:
2024-03-05 15:14:19 +03:00
parent 5d7467db51
commit 1c3fc731f7

View File

@@ -82,58 +82,19 @@ class NameScreen extends StatelessWidget {
margin: EdgeInsets.only(
left: 16.h, right: 16.h, bottom: 50.v),
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
onPressed: () {
List<String> errors = validateFields(
state.firstNameController!.text,
state.lastNameController!.text);
if (errors.isEmpty) {
UserRegistrationSheet sheet =
state.nameModelObj!.userRegistrationSheet;
sheet.firstName = state.firstNameController!.text;
sheet.lastName = state.lastNameController!.text;
Navigator.pushNamed(
context,
AppRoutes.genderScreen,
arguments: sheet,
);
} else {
String errorMessage = '';
for (var error in errors) {
errorMessage += error + '\n\n';
}
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Ошибка'),
content: Text(errorMessage),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('OK'),
),
],
),
);
}
});
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));
}
@@ -143,6 +104,45 @@ class NameScreen extends StatelessWidget {
NavigatorService.goBack();
}
_onTapNext(BuildContext context, state) {
List<String> errors = validateFields(
state.firstNameController!.text, state.lastNameController!.text);
if (errors.isEmpty) {
UserRegistrationSheet sheet = state.nameModelObj!.userRegistrationSheet;
sheet.firstName = state.firstNameController!.text;
sheet.lastName = state.lastNameController!.text;
Navigator.pushNamed(
context,
AppRoutes.genderScreen,
arguments: sheet,
);
} else {
String errorMessage = '';
for (var error in errors) {
errorMessage += error + '\n\n';
}
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Ошибка'),
content: Text(errorMessage),
actions: [
TextButton(
onPressed: onTapOk(context),
child: Text('OK'),
),
],
),
);
}
}
onTapOk(BuildContext context) {
Navigator.pop(context);
}
List<String> validateFields(
String firstName,
String lastName,