Showing
5 changed files
with
63 additions
and
43 deletions
| @@ -43,7 +43,9 @@ class AddSecurityEmailController extends GetxController { | @@ -43,7 +43,9 @@ class AddSecurityEmailController extends GetxController { | ||
| 43 | final isPasswordObscured = true.obs; | 43 | final isPasswordObscured = true.obs; |
| 44 | final isOldPasswordObscured = true.obs; | 44 | final isOldPasswordObscured = true.obs; |
| 45 | final hasPostUpdatePassword = false.obs; | 45 | final hasPostUpdatePassword = false.obs; |
| 46 | + final hasPostUpdateConfirmPassword = false.obs; | ||
| 46 | final hasClickSetAPassword = false.obs; | 47 | final hasClickSetAPassword = false.obs; |
| 48 | + final hasClickSetAConfirmPassword = false.obs; | ||
| 47 | final hasClickVerifyPassword = false.obs; | 49 | final hasClickVerifyPassword = false.obs; |
| 48 | final hasClickForgotSubmitNewPassword = false.obs; | 50 | final hasClickForgotSubmitNewPassword = false.obs; |
| 49 | 51 | ||
| @@ -65,6 +67,8 @@ class AddSecurityEmailController extends GetxController { | @@ -65,6 +67,8 @@ class AddSecurityEmailController extends GetxController { | ||
| 65 | 67 | ||
| 66 | void _onEmailChanged() { | 68 | void _onEmailChanged() { |
| 67 | emailInput.value = emailController.text.replaceAll(' ', '').trim(); | 69 | emailInput.value = emailController.text.replaceAll(' ', '').trim(); |
| 70 | + hasSubmittedEmail.value = false; | ||
| 71 | + isEmailExist.value = false; | ||
| 68 | } | 72 | } |
| 69 | 73 | ||
| 70 | void _onCodeChanged() { | 74 | void _onCodeChanged() { |
| @@ -73,10 +77,17 @@ class AddSecurityEmailController extends GetxController { | @@ -73,10 +77,17 @@ class AddSecurityEmailController extends GetxController { | ||
| 73 | 77 | ||
| 74 | void _onPasswordChanged() { | 78 | void _onPasswordChanged() { |
| 75 | passwordInput.value = passwordController.text.trim(); | 79 | passwordInput.value = passwordController.text.trim(); |
| 80 | + hasClickVerifyPassword.value = false; | ||
| 81 | + hasClickForgotSubmitNewPassword.value = false; | ||
| 82 | + hasPostUpdatePassword.value = false; | ||
| 83 | + hasClickSetAPassword.value = false; | ||
| 84 | + hasClickSetAConfirmPassword.value = false; | ||
| 76 | } | 85 | } |
| 77 | 86 | ||
| 78 | void _onConfirmPasswordChanged() { | 87 | void _onConfirmPasswordChanged() { |
| 79 | confirmPasswordInput.value = confirmPasswordController.text.trim(); | 88 | confirmPasswordInput.value = confirmPasswordController.text.trim(); |
| 89 | + hasPostUpdateConfirmPassword.value = false; | ||
| 90 | + hasClickSetAConfirmPassword.value = false; | ||
| 80 | } | 91 | } |
| 81 | 92 | ||
| 82 | void _onOldPasswordChanged() { | 93 | void _onOldPasswordChanged() { |
| @@ -211,12 +222,13 @@ class AddSecurityEmailController extends GetxController { | @@ -211,12 +222,13 @@ class AddSecurityEmailController extends GetxController { | ||
| 211 | 222 | ||
| 212 | Future<void> setPassword(BuildContext context) async { | 223 | Future<void> setPassword(BuildContext context) async { |
| 213 | hasClickSetAPassword.value = true; | 224 | hasClickSetAPassword.value = true; |
| 225 | + hasClickSetAConfirmPassword.value = true; | ||
| 214 | if (!isPasswordValid) { | 226 | if (!isPasswordValid) { |
| 215 | - AppToast.show(l10n.invalidPasswordFormat); | 227 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 216 | return; | 228 | return; |
| 217 | } | 229 | } |
| 218 | if (!isConfirmPasswordValid2) { | 230 | if (!isConfirmPasswordValid2) { |
| 219 | - AppToast.show(l10n.invalidPasswordFormat); | 231 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 220 | return; | 232 | return; |
| 221 | } | 233 | } |
| 222 | if (passwordInput.value != confirmPasswordInput.value) { | 234 | if (passwordInput.value != confirmPasswordInput.value) { |
| @@ -248,17 +260,18 @@ class AddSecurityEmailController extends GetxController { | @@ -248,17 +260,18 @@ class AddSecurityEmailController extends GetxController { | ||
| 248 | 260 | ||
| 249 | Future<void> changePassword(BuildContext context) async { | 261 | Future<void> changePassword(BuildContext context) async { |
| 250 | hasPostUpdatePassword.value = true; | 262 | hasPostUpdatePassword.value = true; |
| 263 | + hasPostUpdateConfirmPassword.value = true; | ||
| 251 | 264 | ||
| 252 | if (oldPasswordInput.value.isEmpty) { | 265 | if (oldPasswordInput.value.isEmpty) { |
| 253 | - AppToast.show(l10n.invalidPasswordFormat); | 266 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 254 | return; | 267 | return; |
| 255 | } | 268 | } |
| 256 | if (!isPasswordValid) { | 269 | if (!isPasswordValid) { |
| 257 | - AppToast.show(l10n.invalidPasswordFormat); | 270 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 258 | return; | 271 | return; |
| 259 | } | 272 | } |
| 260 | if (!isConfirmPasswordValid2) { | 273 | if (!isConfirmPasswordValid2) { |
| 261 | - AppToast.show(l10n.invalidPasswordFormat); | 274 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 262 | return; | 275 | return; |
| 263 | } | 276 | } |
| 264 | if (passwordInput.value != confirmPasswordInput.value) { | 277 | if (passwordInput.value != confirmPasswordInput.value) { |
| @@ -296,7 +309,7 @@ class AddSecurityEmailController extends GetxController { | @@ -296,7 +309,7 @@ class AddSecurityEmailController extends GetxController { | ||
| 296 | Future<void> verifyPassword() async { | 309 | Future<void> verifyPassword() async { |
| 297 | hasClickVerifyPassword.value = true; | 310 | hasClickVerifyPassword.value = true; |
| 298 | if (!isPasswordValid) { | 311 | if (!isPasswordValid) { |
| 299 | - AppToast.show(l10n.invalidPasswordFormat); | 312 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 300 | return; | 313 | return; |
| 301 | } | 314 | } |
| 302 | try { | 315 | try { |
| @@ -346,11 +359,11 @@ class AddSecurityEmailController extends GetxController { | @@ -346,11 +359,11 @@ class AddSecurityEmailController extends GetxController { | ||
| 346 | Future<void> forgotSubmitNewPassword(BuildContext context) async { | 359 | Future<void> forgotSubmitNewPassword(BuildContext context) async { |
| 347 | hasClickForgotSubmitNewPassword.value = true; | 360 | hasClickForgotSubmitNewPassword.value = true; |
| 348 | if (codeInput.value.isEmpty) { | 361 | if (codeInput.value.isEmpty) { |
| 349 | - AppToast.show(context.l10n.invalidCode); | 362 | + // AppToast.show(context.l10n.invalidCode); |
| 350 | return; | 363 | return; |
| 351 | } | 364 | } |
| 352 | if (!isPasswordValid) { | 365 | if (!isPasswordValid) { |
| 353 | - AppToast.show(l10n.invalidPasswordFormat); | 366 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 354 | return; | 367 | return; |
| 355 | } | 368 | } |
| 356 | try { | 369 | try { |
| @@ -159,7 +159,8 @@ class AddSecurityEmailView extends GetView<AddSecurityEmailController> { | @@ -159,7 +159,8 @@ class AddSecurityEmailView extends GetView<AddSecurityEmailController> { | ||
| 159 | child: Padding( | 159 | child: Padding( |
| 160 | padding: | 160 | padding: |
| 161 | const EdgeInsets.only(top: 8.0, left: 20, right: 20), | 161 | const EdgeInsets.only(top: 8.0, left: 20, right: 20), |
| 162 | - child: Obx(() => controller.isEmailExist.value | 162 | + child: Obx(() => c.emailInput.value.isNotEmpty && |
| 163 | + controller.isEmailExist.value | ||
| 163 | ? Text( | 164 | ? Text( |
| 164 | l10n.thisEmailIsAlreadyLinkedToAnotherAccountPleaseUseADifferentEmail, | 165 | l10n.thisEmailIsAlreadyLinkedToAnotherAccountPleaseUseADifferentEmail, |
| 165 | textAlign: TextAlign.center, | 166 | textAlign: TextAlign.center, |
| @@ -716,7 +717,7 @@ class SetSecurityEmailPasswordView extends GetView<AddSecurityEmailController> { | @@ -716,7 +717,7 @@ class SetSecurityEmailPasswordView extends GetView<AddSecurityEmailController> { | ||
| 716 | borderSide: BorderSide( | 717 | borderSide: BorderSide( |
| 717 | color: c.isConfirmPasswordValid2 | 718 | color: c.isConfirmPasswordValid2 |
| 718 | ? context.colors.primary | 719 | ? context.colors.primary |
| 719 | - : c.hasClickSetAPassword.value | 720 | + : c.hasClickSetAConfirmPassword.value |
| 720 | ? context.colors.warning | 721 | ? context.colors.warning |
| 721 | : context.colors.textTertiary, | 722 | : context.colors.textTertiary, |
| 722 | width: 1, | 723 | width: 1, |
| @@ -756,7 +757,7 @@ class SetSecurityEmailPasswordView extends GetView<AddSecurityEmailController> { | @@ -756,7 +757,7 @@ class SetSecurityEmailPasswordView extends GetView<AddSecurityEmailController> { | ||
| 756 | style: TextStyle( | 757 | style: TextStyle( |
| 757 | color: c.isConfirmPasswordValid2 | 758 | color: c.isConfirmPasswordValid2 |
| 758 | ? context.colors.textTertiary | 759 | ? context.colors.textTertiary |
| 759 | - : c.hasClickSetAPassword.value | 760 | + : c.hasClickSetAConfirmPassword.value |
| 760 | ? context.colors.warning | 761 | ? context.colors.warning |
| 761 | : context.colors.textTertiary, | 762 | : context.colors.textTertiary, |
| 762 | fontSize: 12, | 763 | fontSize: 12, |
| @@ -1355,7 +1356,8 @@ class ReSetSecurityEmailPasswordView | @@ -1355,7 +1356,8 @@ class ReSetSecurityEmailPasswordView | ||
| 1355 | borderSide: BorderSide( | 1356 | borderSide: BorderSide( |
| 1356 | color: c.isConfirmPasswordValid2 | 1357 | color: c.isConfirmPasswordValid2 |
| 1357 | ? context.colors.primary | 1358 | ? context.colors.primary |
| 1358 | - : c.hasPostUpdatePassword.value | 1359 | + : c.hasPostUpdateConfirmPassword |
| 1360 | + .value | ||
| 1359 | ? context.colors.warning | 1361 | ? context.colors.warning |
| 1360 | : context.colors.textTertiary, | 1362 | : context.colors.textTertiary, |
| 1361 | width: 1, | 1363 | width: 1, |
| @@ -1409,7 +1411,7 @@ class ReSetSecurityEmailPasswordView | @@ -1409,7 +1411,7 @@ class ReSetSecurityEmailPasswordView | ||
| 1409 | style: TextStyle( | 1411 | style: TextStyle( |
| 1410 | color: c.isConfirmPasswordValid2 | 1412 | color: c.isConfirmPasswordValid2 |
| 1411 | ? context.colors.textTertiary | 1413 | ? context.colors.textTertiary |
| 1412 | - : c.hasPostUpdatePassword.value | 1414 | + : c.hasPostUpdateConfirmPassword.value |
| 1413 | ? context.colors.warning | 1415 | ? context.colors.warning |
| 1414 | : context.colors.textTertiary, | 1416 | : context.colors.textTertiary, |
| 1415 | fontSize: 12, | 1417 | fontSize: 12, |
| @@ -1680,21 +1682,22 @@ class ForgotEmailVerificationView extends GetView<AddSecurityEmailController> { | @@ -1680,21 +1682,22 @@ class ForgotEmailVerificationView extends GetView<AddSecurityEmailController> { | ||
| 1680 | const SizedBox(height: 8), | 1682 | const SizedBox(height: 8), |
| 1681 | Padding( | 1683 | Padding( |
| 1682 | padding: const EdgeInsets.symmetric(horizontal: 16), | 1684 | padding: const EdgeInsets.symmetric(horizontal: 16), |
| 1683 | - child: Text( | ||
| 1684 | - textAlign: TextAlign.center, | ||
| 1685 | - context.l10n | ||
| 1686 | - .passwordMustBeAtLeast6CharactersAndInclude1NumberAnd1UppercaseLetter, | ||
| 1687 | - style: TextStyle( | ||
| 1688 | - color: controller.isPasswordValid | ||
| 1689 | - ? context.colors.textTertiary | ||
| 1690 | - : controller.hasClickForgotSubmitNewPassword | ||
| 1691 | - .value | ||
| 1692 | - ? context.colors.warning | ||
| 1693 | - : context.colors.textTertiary, | ||
| 1694 | - fontSize: 12, | ||
| 1695 | - fontWeight: FontWeight.w400, | ||
| 1696 | - ), | ||
| 1697 | - ), | 1685 | + child: Obx(() => Text( |
| 1686 | + textAlign: TextAlign.center, | ||
| 1687 | + context.l10n | ||
| 1688 | + .passwordMustBeAtLeast6CharactersAndInclude1NumberAnd1UppercaseLetter, | ||
| 1689 | + style: TextStyle( | ||
| 1690 | + color: controller.isPasswordValid | ||
| 1691 | + ? context.colors.textTertiary | ||
| 1692 | + : controller | ||
| 1693 | + .hasClickForgotSubmitNewPassword | ||
| 1694 | + .value | ||
| 1695 | + ? context.colors.warning | ||
| 1696 | + : context.colors.textTertiary, | ||
| 1697 | + fontSize: 12, | ||
| 1698 | + fontWeight: FontWeight.w400, | ||
| 1699 | + ), | ||
| 1700 | + )), | ||
| 1698 | ), | 1701 | ), |
| 1699 | Offstage( | 1702 | Offstage( |
| 1700 | offstage: true, | 1703 | offstage: true, |
| @@ -62,6 +62,7 @@ class LoginController extends GetxController { | @@ -62,6 +62,7 @@ class LoginController extends GetxController { | ||
| 62 | 62 | ||
| 63 | /// 是否已经点击过「Continue」(用于控制提示文字是否变红) | 63 | /// 是否已经点击过「Continue」(用于控制提示文字是否变红) |
| 64 | final hasTriedEmailLogin = false.obs; | 64 | final hasTriedEmailLogin = false.obs; |
| 65 | + final hasTriedEmailPwd = false.obs; | ||
| 65 | final resetPasswordCode = ''.obs; | 66 | final resetPasswordCode = ''.obs; |
| 66 | 67 | ||
| 67 | void togglePasswordVisibility() { | 68 | void togglePasswordVisibility() { |
| @@ -242,8 +243,10 @@ class LoginController extends GetxController { | @@ -242,8 +243,10 @@ class LoginController extends GetxController { | ||
| 242 | 243 | ||
| 243 | emailController.addListener(() { | 244 | emailController.addListener(() { |
| 244 | emailInput.value = emailController.text; | 245 | emailInput.value = emailController.text; |
| 246 | + hasTriedEmailLogin.value = false; | ||
| 245 | }); | 247 | }); |
| 246 | passwordController.addListener(() { | 248 | passwordController.addListener(() { |
| 249 | + hasTriedEmailPwd.value = false; | ||
| 247 | passwordInput.value = passwordController.text; | 250 | passwordInput.value = passwordController.text; |
| 248 | }); | 251 | }); |
| 249 | resetPasswordCodeController.addListener(() { | 252 | resetPasswordCodeController.addListener(() { |
| @@ -359,14 +362,15 @@ class LoginController extends GetxController { | @@ -359,14 +362,15 @@ class LoginController extends GetxController { | ||
| 359 | /// 邮箱登录 Continue 按钮点击 | 362 | /// 邮箱登录 Continue 按钮点击 |
| 360 | Future<void> emailLogin() async { | 363 | Future<void> emailLogin() async { |
| 361 | hasTriedEmailLogin.value = true; | 364 | hasTriedEmailLogin.value = true; |
| 365 | + hasTriedEmailPwd.value = true; | ||
| 362 | 366 | ||
| 363 | if (!isEmailValid) { | 367 | if (!isEmailValid) { |
| 364 | - AppToast.show(l10n.invalidEmailFormat); | 368 | + // AppToast.show(l10n.invalidEmailFormat); |
| 365 | return; | 369 | return; |
| 366 | } | 370 | } |
| 367 | 371 | ||
| 368 | if (!isPasswordValid) { | 372 | if (!isPasswordValid) { |
| 369 | - AppToast.show(l10n.invalidPasswordFormat); | 373 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 370 | return; | 374 | return; |
| 371 | } | 375 | } |
| 372 | 376 | ||
| @@ -413,16 +417,16 @@ class LoginController extends GetxController { | @@ -413,16 +417,16 @@ class LoginController extends GetxController { | ||
| 413 | 417 | ||
| 414 | Future<void> resetPassword() async { | 418 | Future<void> resetPassword() async { |
| 415 | if (!isEmailValid) { | 419 | if (!isEmailValid) { |
| 416 | - AppToast.show(l10n.invalidEmailFormat); | 420 | + // AppToast.show(l10n.invalidEmailFormat); |
| 417 | return; | 421 | return; |
| 418 | } | 422 | } |
| 419 | 423 | ||
| 420 | - if (resetPasswordCodeController.text.isEmpty) { | 424 | + if (resetPasswordCode.value.isEmpty) { |
| 421 | AppToast.show(l10n.invalidCode); | 425 | AppToast.show(l10n.invalidCode); |
| 422 | return; | 426 | return; |
| 423 | } | 427 | } |
| 424 | if (!isPasswordValid) { | 428 | if (!isPasswordValid) { |
| 425 | - AppToast.show(l10n.invalidPasswordFormat); | 429 | + // AppToast.show(l10n.invalidPasswordFormat); |
| 426 | return; | 430 | return; |
| 427 | } | 431 | } |
| 428 | 432 |
| @@ -219,12 +219,12 @@ class EmailLoginNewPasswordView extends GetView<LoginController> { | @@ -219,12 +219,12 @@ class EmailLoginNewPasswordView extends GetView<LoginController> { | ||
| 219 | keyboardType: TextInputType.visiblePassword, | 219 | keyboardType: TextInputType.visiblePassword, |
| 220 | obscureText: isObscured, | 220 | obscureText: isObscured, |
| 221 | autofillHints: const [AutofillHints.newPassword], | 221 | autofillHints: const [AutofillHints.newPassword], |
| 222 | - onSubmitted: (value) { | ||
| 223 | - if (controller.canResetPassword) { | ||
| 224 | - FocusScope.of(context).unfocus(); | ||
| 225 | - controller.resetPassword(); | ||
| 226 | - } | ||
| 227 | - }, | 222 | + // onSubmitted: (value) { |
| 223 | + // if (controller.canResetPassword) { | ||
| 224 | + // FocusScope.of(context).unfocus(); | ||
| 225 | + // controller.resetPassword(); | ||
| 226 | + // } | ||
| 227 | + // }, | ||
| 228 | obscuringCharacter: '*', | 228 | obscuringCharacter: '*', |
| 229 | // maxLength: 13, | 229 | // maxLength: 13, |
| 230 | contextMenuBuilder: (BuildContext context, | 230 | contextMenuBuilder: (BuildContext context, |
| @@ -304,7 +304,7 @@ class EmailLoginNewPasswordView extends GetView<LoginController> { | @@ -304,7 +304,7 @@ class EmailLoginNewPasswordView extends GetView<LoginController> { | ||
| 304 | 304 | ||
| 305 | // 密码格式提示 | 305 | // 密码格式提示 |
| 306 | Obx(() { | 306 | Obx(() { |
| 307 | - final hasTried = controller.hasTriedEmailLogin.value; | 307 | + final hasTried = controller.hasTriedEmailPwd.value; |
| 308 | final pwOk = controller.isPasswordValid; | 308 | final pwOk = controller.isPasswordValid; |
| 309 | final isError = hasTried && | 309 | final isError = hasTried && |
| 310 | !pwOk && | 310 | !pwOk && |
| @@ -326,7 +326,8 @@ class EmailLoginNewPasswordView extends GetView<LoginController> { | @@ -326,7 +326,8 @@ class EmailLoginNewPasswordView extends GetView<LoginController> { | ||
| 326 | const SizedBox(height: 39), | 326 | const SizedBox(height: 39), |
| 327 | Obx(() { | 327 | Obx(() { |
| 328 | final canProceed = | 328 | final canProceed = |
| 329 | - controller.passwordInput.value.isNotEmpty; | 329 | + controller.resetPasswordCode.value.isNotEmpty && |
| 330 | + controller.passwordInput.value.isNotEmpty; | ||
| 330 | return SizedBox( | 331 | return SizedBox( |
| 331 | height: 48, | 332 | height: 48, |
| 332 | child: ElevatedButton( | 333 | child: ElevatedButton( |
| @@ -310,8 +310,7 @@ class EmailLoginView extends GetView<LoginController> { | @@ -310,8 +310,7 @@ class EmailLoginView extends GetView<LoginController> { | ||
| 310 | 310 | ||
| 311 | // 密码格式提示 | 311 | // 密码格式提示 |
| 312 | Obx(() { | 312 | Obx(() { |
| 313 | - final hasTried = | ||
| 314 | - controller.hasTriedEmailLogin.value; | 313 | + final hasTried = controller.hasTriedEmailPwd.value; |
| 315 | final pwOk = controller.isPasswordValid; | 314 | final pwOk = controller.isPasswordValid; |
| 316 | final isError = hasTried && !pwOk; | 315 | final isError = hasTried && !pwOk; |
| 317 | return Text( | 316 | return Text( |
-
Please register or login to post a comment