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) { Widget _buildCodeInput(RegisterState state) {
final canResend =
_countdown == 0 && state.status != FormzSubmissionStatus.inProgress;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -232,33 +235,37 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
SizedBox( _buildResendButton(canResend),
width: 112, ],
),
],
);
}
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, height: 40,
child: OutlinedButton( child: OutlinedButton(
onPressed: state.status == FormzSubmissionStatus.inProgress onPressed: canResend ? _handleResendCode : null,
? null
: _handleResendCode,
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
backgroundColor: AppColors.background, backgroundColor: AppColors.background,
side: const BorderSide(color: AppColors.input), side: BorderSide(color: borderColor),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
borderRadius: BorderRadius.circular(6),
), ),
), child: Text(
child: const Text( text,
'发送验证码',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: AppColors.slate500, color: textColor,
), ),
), ),
), ),
),
],
),
],
); );
} }