added design forgot password

This commit is contained in:
llsajjad
2025-09-08 10:00:46 +03:30
parent 837bde1677
commit bb1dbd5bbe
17 changed files with 1133 additions and 85 deletions
+40
View File
@@ -13,6 +13,9 @@ class AuthViewModel with ChangeNotifier {
: _authRepository = authRepository {
usernameController.addListener(_onTextChanged);
passwordController.addListener(_onTextChanged);
emailController.addListener(_onTextChanged);
otpController.addListener(_onTextChanged);
newPasswordController.addListener(_onTextChanged);
// usernameFocus.addListener(_onTextChanged);
// passwordFocus.addListener(_onTextChanged);
}
@@ -20,12 +23,18 @@ class AuthViewModel with ChangeNotifier {
final TextEditingController usernameController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
final TextEditingController emailController = TextEditingController();
final TextEditingController newPasswordController = TextEditingController();
final TextEditingController otpController = TextEditingController();
final FocusNode usernameFocus = FocusNode();
final FocusNode passwordFocus = FocusNode();
final FocusNode emailFocus = FocusNode();
final FocusNode newPasswordFocus = FocusNode();
final FocusNode otpFocus = FocusNode();
bool _obscurePassword = true;
bool get obscurePassword => _obscurePassword;
bool _obscureForgotPassword = true;
bool get obscureForgotPassword => _obscureForgotPassword;
bool get isLoginEnabled =>
usernameController.text.isNotEmpty && passwordController.text.isNotEmpty;
@@ -43,6 +52,37 @@ class AuthViewModel with ChangeNotifier {
notifyListeners();
}
bool get isEmailValid {
final email = emailController.text.trim();
final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
return emailRegex.hasMatch(email);
}
bool get isOtpValid {
final otp = otpController.text.trim();
return otp.length == 5;
}
bool get canSubmitOtpPage {
return isEmailValid && isOtpValid;
}
bool get isNewPasswordValid {
final password = newPasswordController.text.trim();
final hasMinLength = password.length >= 5;
final hasUppercase = RegExp(r'[A-Z]').hasMatch(password);
final hasLowercase = RegExp(r'[a-z]').hasMatch(password);
final hasSpecialChar = RegExp(r'[!@#\$%&\*\^]').hasMatch(password);
return hasMinLength && hasUppercase && hasLowercase && hasSpecialChar;
}
void toggleForgotPasswordVisibility() {
_obscureForgotPassword = !_obscureForgotPassword;
notifyListeners();
}
void _onTextChanged() {
notifyListeners();
}