Remove warning while saving a new code
This commit is contained in:
parent
cad9f00ebe
commit
f6d32e22f2
1 changed files with 29 additions and 22 deletions
|
@ -128,6 +128,10 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
|
|||
_showIncorrectDetailsDialog(context, message: message);
|
||||
return;
|
||||
}
|
||||
if (widget.code == null) {
|
||||
_saveCode();
|
||||
return;
|
||||
}
|
||||
ButtonResult? result = await showChoiceActionSheet(
|
||||
context,
|
||||
title: context.l10n.warning,
|
||||
|
@ -139,28 +143,7 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
|
|||
|
||||
if (result == null) return;
|
||||
if (result.action == ButtonAction.first) {
|
||||
try {
|
||||
final account = _accountController.text.trim();
|
||||
final issuer = _issuerController.text.trim();
|
||||
final secret =
|
||||
_secretController.text.trim().replaceAll(' ', '');
|
||||
final Code newCode = widget.code == null
|
||||
? Code.fromAccountAndSecret(
|
||||
account,
|
||||
issuer,
|
||||
secret,
|
||||
)
|
||||
: widget.code!.copyWith(
|
||||
account: account,
|
||||
issuer: issuer,
|
||||
secret: secret,
|
||||
);
|
||||
// Verify the validity of the code
|
||||
getOTP(newCode);
|
||||
Navigator.of(context).pop(newCode);
|
||||
} catch (e) {
|
||||
_showIncorrectDetailsDialog(context);
|
||||
}
|
||||
_saveCode();
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
|
@ -180,6 +163,30 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
|
|||
);
|
||||
}
|
||||
|
||||
void _saveCode() {
|
||||
try {
|
||||
final account = _accountController.text.trim();
|
||||
final issuer = _issuerController.text.trim();
|
||||
final secret = _secretController.text.trim().replaceAll(' ', '');
|
||||
final Code newCode = widget.code == null
|
||||
? Code.fromAccountAndSecret(
|
||||
account,
|
||||
issuer,
|
||||
secret,
|
||||
)
|
||||
: widget.code!.copyWith(
|
||||
account: account,
|
||||
issuer: issuer,
|
||||
secret: secret,
|
||||
);
|
||||
// Verify the validity of the code
|
||||
getOTP(newCode);
|
||||
Navigator.of(context).pop(newCode);
|
||||
} catch (e) {
|
||||
_showIncorrectDetailsDialog(context);
|
||||
}
|
||||
}
|
||||
|
||||
void _showIncorrectDetailsDialog(
|
||||
BuildContext context, {
|
||||
String? message,
|
||||
|
|
Loading…
Add table
Reference in a new issue