From d1e224ece446a57b09ccdc89f6fa0f7083b6f863 Mon Sep 17 00:00:00 2001 From: qzl Date: Thu, 26 Feb 2026 11:06:16 +0800 Subject: [PATCH] fix(auth): reset countdown after resend and add sending state --- .../screens/register_verification_screen.dart | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/apps/lib/features/auth/ui/screens/register_verification_screen.dart b/apps/lib/features/auth/ui/screens/register_verification_screen.dart index 23ef03f..547767f 100644 --- a/apps/lib/features/auth/ui/screens/register_verification_screen.dart +++ b/apps/lib/features/auth/ui/screens/register_verification_screen.dart @@ -93,7 +93,12 @@ class _RegisterVerificationViewState extends State { } Future _handleResendCode() async { - await context.read().resendCode(); + final cubit = context.read(); + await cubit.resendCode(); + + if (cubit.state.codeSent && mounted) { + _startCountdown(); + } } @override @@ -235,17 +240,25 @@ class _RegisterVerificationViewState extends State { ), ), const SizedBox(width: 8), - _buildResendButton(canResend), + _buildResendButton(canResend, state), ], ), ], ); } - Widget _buildResendButton(bool canResend) { + Widget _buildResendButton(bool canResend, RegisterState state) { final borderColor = canResend ? AppColors.primary : AppColors.slate300; final textColor = canResend ? AppColors.primary : AppColors.slate400; - final text = canResend ? '重新发送' : '$_countdown s'; + + String text; + if (state.status == FormzSubmissionStatus.inProgress) { + text = '发送中...'; + } else if (canResend) { + text = '重新发送'; + } else { + text = '$_countdown s'; + } return SizedBox( width: 90,