fix(auth): reset countdown after resend and add sending state
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user