verification code, auto submit (#6822)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-01-07 05:07:25 -08:00 committed by GitHub
parent 396d7680d3
commit 159c883bf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -615,6 +615,7 @@ Future<bool?> verificationCodeDialog(
var autoLogin = true;
var isInProgress = false;
String? errorText;
String preCode = '';
final code = TextEditingController();
final focusNode = FocusNode()..requestFocus();
@ -625,12 +626,6 @@ Future<bool?> verificationCodeDialog(
return code.text.length >= 6;
}
code.addListener(() {
if (errorText != null) {
setState(() => errorText = null);
}
});
void onVerify() async {
if (!validate()) {
setState(
@ -671,6 +666,19 @@ Future<bool?> verificationCodeDialog(
setState(() => isInProgress = false);
}
code.addListener(() {
if (errorText != null) {
setState(() => errorText = null);
}
if (preCode.length != 6 && code.text.length == 6) {
onVerify();
}
if (!isEmailVerification && preCode.length != 10 && code.text.length == 10) {
onVerify();
}
preCode = code.text;
});
return CustomAlertDialog(
title: Text(translate("Verification code")),
contentBoxConstraints: BoxConstraints(maxWidth: 300),