fix(auth): reset countdown after resend and add sending state

This commit is contained in:
qzl
2026-02-26 11:06:16 +08:00
parent 25b8a2b569
commit d1e224ece4
@@ -93,7 +93,12 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
}
Future<void> _handleResendCode() async {
await context.read<RegisterCubit>().resendCode();
final cubit = context.read<RegisterCubit>();
await cubit.resendCode();
if (cubit.state.codeSent && mounted) {
_startCountdown();
}
}
@override
@@ -235,17 +240,25 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
),
),
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,