forked from eatvio/eatvio_app
test(registration): All tests passed! SMOKE TESTING FINISHED
This commit is contained in:
@@ -34,7 +34,7 @@ class NameScreen extends StatelessWidget {
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(children: [
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 7.v),
|
||||
Container(
|
||||
height: 16.v,
|
||||
@@ -75,7 +75,6 @@ class NameScreen extends StatelessWidget {
|
||||
);
|
||||
}),
|
||||
SizedBox(height: 21.v),
|
||||
Spacer(),
|
||||
BlocBuilder<NameBloc, NameState>(builder: (context, state) {
|
||||
return NextStepButton(
|
||||
text: "continue".tr.toUpperCase(),
|
||||
@@ -104,65 +103,66 @@ 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 = '';
|
||||
_onTapNext(BuildContext context, NameState state) {
|
||||
if (state.firstNameController != null && state.lastNameController != null) {
|
||||
List<String> errors = validateFields(
|
||||
state.firstNameController!.text, state.lastNameController!.text);
|
||||
|
||||
for (var error in errors) {
|
||||
errorMessage += error + '\n\n';
|
||||
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('Error'),
|
||||
content: Text(errorMessage),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => onTapOk(context),
|
||||
child: Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Ошибка'),
|
||||
content: Text(errorMessage),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: onTapOk(context),
|
||||
child: Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onTapOk(BuildContext context) {
|
||||
void onTapOk(BuildContext context) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
List<String> validateFields(
|
||||
String firstName,
|
||||
String lastName,
|
||||
) {
|
||||
List<String> validateFields(String firstName, String lastName) {
|
||||
List<String> errors = [];
|
||||
|
||||
if (firstName.isEmpty) {
|
||||
errors.add('first_name_empty'.tr);
|
||||
errors.add('First name cannot be empty');
|
||||
}
|
||||
|
||||
if (firstName.length < 1) {
|
||||
errors.add('first_name_short'.tr);
|
||||
errors.add('First name is too short');
|
||||
}
|
||||
|
||||
if (lastName.isEmpty) {
|
||||
errors.add('last_name_empty'.tr);
|
||||
errors.add('Last name cannot be empty');
|
||||
}
|
||||
|
||||
if (lastName.length < 1) {
|
||||
errors.add('last_name_short'.tr);
|
||||
errors.add('Last name is too short');
|
||||
}
|
||||
|
||||
return errors;
|
||||
|
||||
@@ -36,7 +36,7 @@ class _WeightScreenState extends State<WeightScreen> {
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(children: [
|
||||
child: ListView(children: [
|
||||
SizedBox(height: 7.v),
|
||||
Container(
|
||||
height: 16.v,
|
||||
@@ -81,7 +81,6 @@ class _WeightScreenState extends State<WeightScreen> {
|
||||
})
|
||||
])
|
||||
]),
|
||||
Spacer(),
|
||||
BlocBuilder<WeightBloc, WeightState>(
|
||||
builder: (context, state) {
|
||||
return NextStepButton(
|
||||
@@ -111,20 +110,15 @@ class _WeightScreenState extends State<WeightScreen> {
|
||||
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,
|
||||
);
|
||||
onTapNext(BuildContext context, WeightState state) {
|
||||
return () {
|
||||
UserRegistrationSheet sheet = state.weightModelObj!.userRegistrationSheet;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.heightScreen,
|
||||
arguments: sheet,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
void _onDropDownChanged(value) {
|
||||
|
||||
Reference in New Issue
Block a user