feat(auth): improve resend button style with countdown
This commit is contained in:
@@ -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,36 +235,40 @@ class _RegisterVerificationViewState extends State<RegisterVerificationView> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
SizedBox(
|
_buildResendButton(canResend),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
Widget _buildStepIndicator() {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
Reference in New Issue
Block a user