update copy, redesign dialog

This commit is contained in:
Adam Velebil 2024-09-04 09:23:27 +02:00
parent 75f74895cb
commit 9a41051b57
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
8 changed files with 138 additions and 46 deletions

View File

@ -15,30 +15,76 @@
*/
import 'package:flutter/material.dart';
import 'package:material_symbols_icons/symbols.dart';
import '../app/state.dart';
import 'tap_request_dialog.dart';
void showAlertDialog(ref, String title, String message) =>
void showAlertDialog(ref, String title, String message, String description,
[Function()? onClosed]) =>
ref.read(withContextProvider)((context) async {
ref.read(androidDialogProvider).closeDialog();
final l10n = ref.read(l10nProvider);
Navigator.of(context).popUntil((route) {
return route.isFirst;
});
await showDialog(
routeSettings: const RouteSettings(name: 'android_alert_dialog'),
useSafeArea: true,
context: context,
builder: (dialogContext) {
return AlertDialog(
title: Text(title),
actions: [
TextButton(
onPressed: () async {
Navigator.of(dialogContext).pop();
},
child: Text(l10n.s_close))
],
content: Text(message));
});
builder: (dialogContext) =>
_AndroidAlertDialog(title, message, description));
if (onClosed != null) {
onClosed();
}
});
class _AndroidAlertDialog extends StatelessWidget {
final String title;
final String message;
final String description;
const _AndroidAlertDialog(this.title, this.message, this.description);
@override
Widget build(BuildContext context) {
return Dialog(
child: Stack(fit: StackFit.loose, children: [
Positioned(
top: 5,
right: 5,
child: IconButton(
autofocus: true,
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Symbols.close, fill: 1, size: 24),
),
),
Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: Theme.of(context).textTheme.headlineMedium,
),
const SizedBox(
height: 32,
),
Text(
message,
style: Theme.of(context).textTheme.bodyLarge,
),
const SizedBox(
height: 32,
),
Text(
description,
style: Theme.of(context).textTheme.bodySmall,
),
],
),
)
]));
}
}

View File

@ -143,23 +143,39 @@ Exception handlePlatformException(PlatformException platformException, ref) {
switch (decoded) {
case ApduException apduException:
if (apduException.sw == 0x6985) {
showAlertDialog(ref, l10n.l_account_add_failure_title,
l10n.p_account_add_failure_6985);
showAlertDialog(
ref,
l10n.l_operation_failed,
l10n.l_add_account_no_password,
l10n.p_add_account_no_password_desc,
);
return CancellationException();
}
if (apduException.sw == 0x6982) {
showAlertDialog(ref, l10n.l_account_add_failure_title,
l10n.p_account_add_failure_6982);
showAlertDialog(
ref,
l10n.l_operation_failed,
l10n.l_add_account_key_locked,
l10n.p_add_account_key_locked_desc,
);
return CancellationException();
}
case PlatformException pe:
if (pe.code == 'JobCancellationException') {
showAlertDialog(ref, l10n.l_account_add_failure_title,
l10n.p_account_add_failure_application_not_available);
showAlertDialog(
ref,
l10n.l_operation_failed,
l10n.l_add_account_no_oath,
l10n.p_add_account_no_oath_desc,
);
return CancellationException();
} else if (pe.code == 'IllegalArgumentException') {
showAlertDialog(ref, l10n.l_account_add_failure_title,
l10n.p_account_add_failure_exists);
showAlertDialog(
ref,
l10n.l_operation_failed,
l10n.l_add_account_already_exists,
l10n.p_add_account_already_exists_desc,
);
return CancellationException();
}
}

View File

@ -427,11 +427,16 @@
"message": {}
}
},
"l_operation_failed": null,
"l_account_add_failure_title": null,
"p_account_add_failure_6985": null,
"p_account_add_failure_6982": null,
"p_account_add_failure_exists": null,
"p_account_add_failure_application_not_available": null,
"l_add_account_no_password": null,
"p_add_account_no_password_desc": null,
"l_add_account_key_locked": null,
"p_add_account_key_locked_desc": null,
"l_add_account_already_exists": null,
"p_add_account_already_exists_desc": null,
"l_add_account_no_oath": null,
"p_add_account_no_oath_desc": null,
"l_account_name_required": "Ihr Konto muss einen Namen haben",
"l_name_already_exists": "Für diesen Aussteller existiert dieser Name bereits",
"l_account_already_exists": "Dieses Konto existiert bereits auf dem YubiKey",

View File

@ -427,11 +427,16 @@
"message": {}
}
},
"l_operation_failed": "Operation failed",
"l_account_add_failure_title": "Add account failed",
"p_account_add_failure_6985": "The account could not be added to YubiKey. Please, set password first.",
"p_account_add_failure_6982": "The account could not be added to YubiKey. Please, unlock the key first.",
"p_account_add_failure_exists": "Account already exists on the key.",
"p_account_add_failure_application_not_available": "This YubiKey does not support OATH accounts.",
"l_add_account_no_password": "Set password first",
"p_add_account_no_password_desc": "Your YubiKey needs password to be set before accounts can be added to it.",
"l_add_account_key_locked": "Unlock the key",
"p_add_account_key_locked_desc": "Your YubiKey is password protected. Unlock it before adding accounts.",
"l_add_account_already_exists": "Account already exists on the key",
"p_add_account_already_exists_desc": "The YubiKey already contains account with the same name. Change the account details to add it.",
"l_add_account_no_oath": "This YubiKey does not support accounts",
"p_add_account_no_oath_desc": "Only YubiKey 5 with enabled OATH application can store accounts.",
"l_account_name_required": "Your account must have a name",
"l_name_already_exists": "This name already exists for the issuer",
"l_account_already_exists": "This account already exists on the YubiKey",

View File

@ -427,11 +427,16 @@
"message": {}
}
},
"l_operation_failed": null,
"l_account_add_failure_title": null,
"p_account_add_failure_6985": null,
"p_account_add_failure_6982": null,
"p_account_add_failure_exists": null,
"p_account_add_failure_application_not_available": null,
"l_add_account_no_password": null,
"p_add_account_no_password_desc": null,
"l_add_account_key_locked": null,
"p_add_account_key_locked_desc": null,
"l_add_account_already_exists": null,
"p_add_account_already_exists_desc": null,
"l_add_account_no_oath": null,
"p_add_account_no_oath_desc": null,
"l_account_name_required": "Votre compte doit avoir un nom",
"l_name_already_exists": "Ce nom existe déjà pour l'émetteur",
"l_account_already_exists": "Ce compte existe déjà sur la YubiKey",

View File

@ -427,11 +427,16 @@
"message": {}
}
},
"l_operation_failed": null,
"l_account_add_failure_title": null,
"p_account_add_failure_6985": null,
"p_account_add_failure_6982": null,
"p_account_add_failure_exists": null,
"p_account_add_failure_application_not_available": null,
"l_add_account_no_password": null,
"p_add_account_no_password_desc": null,
"l_add_account_key_locked": null,
"p_add_account_key_locked_desc": null,
"l_add_account_already_exists": null,
"p_add_account_already_exists_desc": null,
"l_add_account_no_oath": null,
"p_add_account_no_oath_desc": null,
"l_account_name_required": "アカウントには名前が必要です",
"l_name_already_exists": "この名前は発行者にすでに存在します",
"l_account_already_exists": "このアカウントはYubiKeyにすでに存在します",

View File

@ -427,11 +427,16 @@
"message": {}
}
},
"l_operation_failed": null,
"l_account_add_failure_title": null,
"p_account_add_failure_6985": null,
"p_account_add_failure_6982": null,
"p_account_add_failure_exists": null,
"p_account_add_failure_application_not_available": null,
"l_add_account_no_password": null,
"p_add_account_no_password_desc": null,
"l_add_account_key_locked": null,
"p_add_account_key_locked_desc": null,
"l_add_account_already_exists": null,
"p_add_account_already_exists_desc": null,
"l_add_account_no_oath": null,
"p_add_account_no_oath_desc": null,
"l_account_name_required": "Twoje konto musi mieć nazwę",
"l_name_already_exists": "Ta nazwa już istnieje dla tego wydawcy",
"l_account_already_exists": "To konto już istnieje w YubiKey",

View File

@ -427,11 +427,16 @@
"message": {}
}
},
"l_operation_failed": null,
"l_account_add_failure_title": null,
"p_account_add_failure_6985": null,
"p_account_add_failure_6982": null,
"p_account_add_failure_exists": null,
"p_account_add_failure_application_not_available": null,
"l_add_account_no_password": null,
"p_add_account_no_password_desc": null,
"l_add_account_key_locked": null,
"p_add_account_key_locked_desc": null,
"l_add_account_already_exists": null,
"p_add_account_already_exists_desc": null,
"l_add_account_no_oath": null,
"p_add_account_no_oath_desc": null,
"l_account_name_required": "Tài khoản của bạn phải có tên",
"l_name_already_exists": "Tên này đã tồn tại cho nhà phát hành",
"l_account_already_exists": "Tài khoản này đã tồn tại trên YubiKey",