fixed issues

fatima
Fatimah Alshammari 4 years ago
parent 9bd0d238f2
commit 6e055b568e

@ -26,6 +26,7 @@ class CompleteProfilePage extends StatefulWidget {
} }
class _CompleteProfilePageState extends State<CompleteProfilePage> { class _CompleteProfilePageState extends State<CompleteProfilePage> {
bool isChecked = false;
String? firstName = "", lastName = "", email = "", password = "", confirmPassword = ""; String? firstName = "", lastName = "", email = "", password = "", confirmPassword = "";
@override @override
@ -51,6 +52,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
TxtField( TxtField(
hint: "First Name", hint: "First Name",
value: firstName,
onChanged: (v) { onChanged: (v) {
firstName = v; firstName = v;
}, },
@ -58,6 +60,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
12.height, 12.height,
TxtField( TxtField(
hint: "Surname", hint: "Surname",
value: lastName,
onChanged: (v) { onChanged: (v) {
lastName = v; lastName = v;
}, },
@ -65,6 +68,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
12.height, 12.height,
TxtField( TxtField(
hint: "Email", hint: "Email",
value: email,
onChanged: (v) { onChanged: (v) {
email = v; email = v;
}, },
@ -74,6 +78,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
hint: "Create Password", hint: "Create Password",
isPasswordEnabled: true, isPasswordEnabled: true,
maxLines: 1, maxLines: 1,
value: password,
onChanged: (v) { onChanged: (v) {
password = v; password = v;
}, },
@ -83,6 +88,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
hint: "Confirm Password", hint: "Confirm Password",
isPasswordEnabled: true, isPasswordEnabled: true,
maxLines: 1, maxLines: 1,
value: confirmPassword,
onChanged: (v) { onChanged: (v) {
confirmPassword = v; confirmPassword = v;
}, },
@ -92,7 +98,12 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
// hint: "Phone Number", // hint: "Phone Number",
// ), // ),
50.height, 50.height,
"By creating an account you agree to our Terms of Service and Privacy Policy".toText12(), Row(
children: [
buildCheckbox(),
"By creating an account you agree to our Terms of Service and\n Privacy Policy".toText12(),
],
),
16.height, 16.height,
ShowFillButton( ShowFillButton(
title: "Continue", title: "Continue",
@ -107,23 +118,56 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
), ),
), ),
); );
} }
Widget buildCheckbox() => Checkbox(
value: isChecked,
activeColor: Colors.blue,
onChanged: (value){
setState(() {
isChecked = value!;
});
},
);
Future<void> performCompleteProfile() async { Future<void> performCompleteProfile() async {
if (password == confirmPassword) { if (firstName != "") {
print(widget.user.data!.userId??"userId"); if (lastName != "") {
Utils.showLoading(context); if (validateStructure(password ?? "")) {
RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!); if (password == confirmPassword) {
Utils.hideLoading(context); if (isChecked) {
if (user.messageStatus == 1) { print(widget.user.data!.userId ?? "userId");
Utils.showToast( "Successfully Registered, Please login once"); Utils.showLoading(context);
pop(context); RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!);
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user); Utils.hideLoading(context);
if (user.messageStatus == 1) {
Utils.showToast("Successfully Registered, Please login once");
pop(context);
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
} else {
Utils.showToast(user.message ?? "");
}
}else{
Utils.showToast("Please accept terms");
}
} else {
Utils.showToast("Please enter same password");
}
} else { } else {
Utils.showToast(user.message ?? ""); Utils.showToast("Password Should contains Character, Number, Capital and small letters");
} }
} else { }else{
Utils.showToast("Please enter same password"); Utils.showToast("Surname is mandatory");
}
}else{
Utils.showToast("First name is mandatory");
} }
} }
bool validateStructure(String value){
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value);
}
} }

@ -82,6 +82,7 @@ class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
} }
Future<void> confirmPasswordOTP(BuildContext context) async { Future<void> confirmPasswordOTP(BuildContext context) async {
if(validateStructure(newPassword??"")){
Utils.showLoading(context); Utils.showLoading(context);
Response res = await UserApiClent().ForgetPassword(widget.userToken, newPassword); Response res = await UserApiClent().ForgetPassword(widget.userToken, newPassword);
Utils.hideLoading(context); Utils.hideLoading(context);
@ -92,6 +93,9 @@ class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
} else { } else {
Utils.showToast(data.message ?? ""); Utils.showToast(data.message ?? "");
} }
}else{
Utils.showToast("Password Should contains Character, Number, Capital and small letters");
}
} }
bool validation() { bool validation() {
@ -102,4 +106,10 @@ class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
} }
return isValid; return isValid;
} }
bool validateStructure(String value){
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value);
}
} }

Loading…
Cancel
Save