feat(auth): improve resend button style with countdown

This commit is contained in:
qzl
2026-02-26 11:02:30 +08:00
parent 1f253c54e9
commit 25b8a2b569
@@ -201,6 +201,9 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
}
Widget _buildCodeInput(RegisterState state) {
final canResend =
_countdown == 0 && state.status != FormzSubmissionStatus.inProgress;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -232,36 +235,40 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
),
),
const SizedBox(width: 8),
SizedBox(
width: 112,
height: 40,
child: OutlinedButton(
onPressed: state.status == FormzSubmissionStatus.inProgress
? null
: _handleResendCode,
style: OutlinedButton.styleFrom(
backgroundColor: AppColors.background,
side: const BorderSide(color: AppColors.input),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
child: const Text(
'发送验证码',
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: AppColors.slate500,
),
),
),
),
_buildResendButton(canResend),
],
),
],
);
}
Widget _buildResendButton(bool canResend) {
final borderColor = canResend ? AppColors.primary : AppColors.slate300;
final textColor = canResend ? AppColors.primary : AppColors.slate400;
final text = canResend ? '重新发送' : '$_countdown s';
return SizedBox(
width: 90,
height: 40,
child: OutlinedButton(
onPressed: canResend ? _handleResendCode : null,
style: OutlinedButton.styleFrom(
backgroundColor: AppColors.background,
side: BorderSide(color: borderColor),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: Text(
text,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: textColor,
),
),
),
);
}
Widget _buildStepIndicator() {
return Row(
children: [