Merge pull request 'forget_password_design' (#112) from forget_password_design into main

Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/112
This commit is contained in:
a.ghabeli
2025-09-08 10:17:45 +03:30
20 changed files with 1175 additions and 130 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();
}