|
|
|
@ -18,6 +18,7 @@ import 'package:car_customer_app/extensions/string_extensions.dart';
|
|
|
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
|
|
|
import 'package:car_customer_app/widgets/txt_field.dart';
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_password_strength/flutter_password_strength.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class CompleteProfilePage extends StatefulWidget {
|
|
|
|
class CompleteProfilePage extends StatefulWidget {
|
|
|
|
RegisterUser user;
|
|
|
|
RegisterUser user;
|
|
|
|
@ -29,9 +30,15 @@ class CompleteProfilePage extends StatefulWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
String? firstName = "", lastName = "", email = "", password = "", confirmPassword = "";
|
|
|
|
String? firstName = "",
|
|
|
|
|
|
|
|
lastName = "",
|
|
|
|
|
|
|
|
email = "",
|
|
|
|
|
|
|
|
confirmPassword = "";
|
|
|
|
|
|
|
|
late String password = "";
|
|
|
|
bool isChecked = false;
|
|
|
|
bool isChecked = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double _strength = 0;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
// TODO: implement initState
|
|
|
|
@ -62,7 +69,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
12.height,
|
|
|
|
12.height,
|
|
|
|
TxtField(
|
|
|
|
TxtField(
|
|
|
|
hint:LocaleKeys.surname.tr(),
|
|
|
|
hint: LocaleKeys.surname.tr(),
|
|
|
|
value: lastName,
|
|
|
|
value: lastName,
|
|
|
|
onChanged: (v) {
|
|
|
|
onChanged: (v) {
|
|
|
|
lastName = v;
|
|
|
|
lastName = v;
|
|
|
|
@ -72,7 +79,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
TxtField(
|
|
|
|
TxtField(
|
|
|
|
hint: LocaleKeys.email.tr(),
|
|
|
|
hint: LocaleKeys.email.tr(),
|
|
|
|
value: email,
|
|
|
|
value: email,
|
|
|
|
// isButtonEnable: email!.length > 0 ? true : false,
|
|
|
|
// isButtonEnable: email!.length > 0 ? true : false,
|
|
|
|
buttonTitle: LocaleKeys.verify.tr(),
|
|
|
|
buttonTitle: LocaleKeys.verify.tr(),
|
|
|
|
onChanged: (v) {
|
|
|
|
onChanged: (v) {
|
|
|
|
email = v;
|
|
|
|
email = v;
|
|
|
|
@ -84,9 +91,29 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
isPasswordEnabled: true,
|
|
|
|
isPasswordEnabled: true,
|
|
|
|
maxLines: 1,
|
|
|
|
maxLines: 1,
|
|
|
|
value: password,
|
|
|
|
value: password,
|
|
|
|
onChanged: (v) {
|
|
|
|
onChanged: (value) => _checkPassword(value),
|
|
|
|
password = v;
|
|
|
|
// onChanged: (v) {
|
|
|
|
},
|
|
|
|
// password = v;
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
password!.isNotEmpty ? 12.height : 0.height,
|
|
|
|
|
|
|
|
// The strength indicator bar
|
|
|
|
|
|
|
|
password!.isNotEmpty ? LinearProgressIndicator(
|
|
|
|
|
|
|
|
value: _strength,
|
|
|
|
|
|
|
|
backgroundColor: Colors.grey[300],
|
|
|
|
|
|
|
|
color: _strength <= 1 / 4
|
|
|
|
|
|
|
|
? Colors.yellow
|
|
|
|
|
|
|
|
: _strength == 2 / 4
|
|
|
|
|
|
|
|
? Colors.orange
|
|
|
|
|
|
|
|
: _strength == 3 / 4
|
|
|
|
|
|
|
|
? Colors.deepOrange
|
|
|
|
|
|
|
|
: Colors.red,
|
|
|
|
|
|
|
|
minHeight: 4,
|
|
|
|
|
|
|
|
): Container(),
|
|
|
|
|
|
|
|
// The message about the strength of the entered password
|
|
|
|
|
|
|
|
Text(
|
|
|
|
|
|
|
|
_displayText,
|
|
|
|
|
|
|
|
style: const TextStyle(fontSize: 12),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
12.height,
|
|
|
|
12.height,
|
|
|
|
TxtField(
|
|
|
|
TxtField(
|
|
|
|
@ -125,7 +152,8 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget buildCheckbox() => Checkbox(
|
|
|
|
Widget buildCheckbox() =>
|
|
|
|
|
|
|
|
Checkbox(
|
|
|
|
value: isChecked,
|
|
|
|
value: isChecked,
|
|
|
|
activeColor: Colors.blue,
|
|
|
|
activeColor: Colors.blue,
|
|
|
|
onChanged: (value) {
|
|
|
|
onChanged: (value) {
|
|
|
|
@ -162,13 +190,13 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
Future<void> performCompleteProfile() async {
|
|
|
|
Future<void> performCompleteProfile() async {
|
|
|
|
if (validateStructure(password ?? "")) {
|
|
|
|
if (validateStructure(password ?? "")) {
|
|
|
|
if (password == confirmPassword) {
|
|
|
|
if (password == confirmPassword) {
|
|
|
|
print(widget.user.data!.userId ?? "userId");
|
|
|
|
print(widget.user.data!.userInfo!.userId ?? "userId");
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!);
|
|
|
|
RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userInfo!.userId ?? "", firstName!, lastName!, email!, password!);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
if (user.messageStatus == 1) {
|
|
|
|
Utils.showToast(LocaleKeys.successfullyRegistered.tr());
|
|
|
|
Utils.showToast(LocaleKeys.successfullyRegistered.tr());
|
|
|
|
//("Successfully Registered, Please login once");
|
|
|
|
//("Successfully Registered, Please login once");
|
|
|
|
pop(context);
|
|
|
|
pop(context);
|
|
|
|
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
|
|
|
|
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -176,11 +204,11 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(LocaleKeys.pleaseEnterSamePassword.tr());
|
|
|
|
Utils.showToast(LocaleKeys.pleaseEnterSamePassword.tr());
|
|
|
|
//("Please enter same password");
|
|
|
|
//("Please enter same password");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Utils.showToast(LocaleKeys.passwordShouldContains.tr());
|
|
|
|
Utils.showToast(LocaleKeys.passwordShouldContains.tr());
|
|
|
|
//("Password Should contains Character, Number, Capital and small letters");
|
|
|
|
//("Password Should contains Character, Number, Capital and small letters");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -190,6 +218,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
return regExp.hasMatch(value);
|
|
|
|
return regExp.hasMatch(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isEmail(String em) {
|
|
|
|
bool isEmail(String em) {
|
|
|
|
String p = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
|
|
|
String p = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
|
|
|
|
RegExp regExp = new RegExp(p);
|
|
|
|
RegExp regExp = new RegExp(p);
|
|
|
|
@ -200,27 +229,59 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
|
|
|
|
bool isValid = true;
|
|
|
|
bool isValid = true;
|
|
|
|
if (firstName!.isEmpty) {
|
|
|
|
if (firstName!.isEmpty) {
|
|
|
|
Utils.showToast(LocaleKeys.firstNameMandatory.tr());
|
|
|
|
Utils.showToast(LocaleKeys.firstNameMandatory.tr());
|
|
|
|
//("First name is mandatory");
|
|
|
|
//("First name is mandatory");
|
|
|
|
isValid = false;
|
|
|
|
isValid = false;
|
|
|
|
} else if (lastName!.isEmpty) {
|
|
|
|
} else if (lastName!.isEmpty) {
|
|
|
|
Utils.showToast(LocaleKeys.surnameNameMandatory.tr());
|
|
|
|
Utils.showToast(LocaleKeys.surnameNameMandatory.tr());
|
|
|
|
//("Surname is mandatory");
|
|
|
|
//("Surname is mandatory");
|
|
|
|
isValid = false;
|
|
|
|
isValid = false;
|
|
|
|
} else if (email!.isNotEmpty) {
|
|
|
|
} else if (email!.isNotEmpty) {
|
|
|
|
if(!isEmail(email!)){
|
|
|
|
if (!isEmail(email!)) {
|
|
|
|
Utils.showToast(LocaleKeys.enterValidEmail.tr());
|
|
|
|
Utils.showToast(LocaleKeys.enterValidEmail.tr());
|
|
|
|
//("Enter Valid Email");
|
|
|
|
//("Enter Valid Email");
|
|
|
|
isValid = false;
|
|
|
|
isValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if (password!.isEmpty) {
|
|
|
|
} else if (password!.isEmpty) {
|
|
|
|
Utils.showToast(LocaleKeys.passwordNameMandatory.tr());
|
|
|
|
Utils.showToast(LocaleKeys.passwordNameMandatory.tr());
|
|
|
|
//("Password is mandatory");
|
|
|
|
//("Password is mandatory");
|
|
|
|
isValid = false;
|
|
|
|
isValid = false;
|
|
|
|
} else if (!isChecked) {
|
|
|
|
} else if (!isChecked) {
|
|
|
|
Utils.showToast(LocaleKeys.pleaseAcceptTerms.tr());
|
|
|
|
Utils.showToast(LocaleKeys.pleaseAcceptTerms.tr());
|
|
|
|
//("Please accept terms");
|
|
|
|
//("Please accept terms");
|
|
|
|
isValid = false;
|
|
|
|
isValid = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isValid;
|
|
|
|
return isValid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RegExp numReg = RegExp(r".*[0-9].*");
|
|
|
|
|
|
|
|
RegExp letterReg = RegExp(r".*[A-Za-z].*");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String _displayText = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void _checkPassword(String value) {
|
|
|
|
|
|
|
|
password = value.trim();
|
|
|
|
|
|
|
|
if (password!.length <= 6) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_strength = 1 / 4;
|
|
|
|
|
|
|
|
_displayText = 'Your password is too short';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (password!.length < 8) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_strength = 2 / 4;
|
|
|
|
|
|
|
|
_displayText = 'Your password is acceptable but not strong';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!letterReg.hasMatch(password!) || !numReg.hasMatch(password!)) {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_strength = 3 / 4;
|
|
|
|
|
|
|
|
_displayText = 'Your password is strong';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_strength = 1;
|
|
|
|
|
|
|
|
_displayText = 'Your password is very strong';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|