mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2025-01-05 18:25:58 +03:00
Show correct cancel text in ResponsiveDialog
This commit is contained in:
parent
e21fb7525c
commit
fab5fa2687
@ -51,12 +51,19 @@ class _ResponsiveDialogState extends State<ResponsiveDialog> {
|
|||||||
_focus.dispose();
|
_focus.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _getCancelText(BuildContext context) {
|
||||||
|
final l10n = AppLocalizations.of(context)!;
|
||||||
|
return widget.onCancel == null && widget.actions.isEmpty
|
||||||
|
? l10n.s_close
|
||||||
|
: l10n.s_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildFullscreen(BuildContext context) => Scaffold(
|
Widget _buildFullscreen(BuildContext context) => Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: widget.title,
|
title: widget.title,
|
||||||
actions: widget.actions,
|
actions: widget.actions,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
tooltip: AppLocalizations.of(context)!.s_close,
|
tooltip: _getCancelText(context),
|
||||||
icon: const Icon(Symbols.close),
|
icon: const Icon(Symbols.close),
|
||||||
onPressed: widget.allowCancel
|
onPressed: widget.allowCancel
|
||||||
? () {
|
? () {
|
||||||
@ -72,10 +79,6 @@ class _ResponsiveDialogState extends State<ResponsiveDialog> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildDialog(BuildContext context) {
|
Widget _buildDialog(BuildContext context) {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
|
||||||
final cancelText = widget.onCancel == null && widget.actions.isEmpty
|
|
||||||
? l10n.s_close
|
|
||||||
: l10n.s_cancel;
|
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: widget.allowCancel,
|
canPop: widget.allowCancel,
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
@ -94,7 +97,7 @@ class _ResponsiveDialogState extends State<ResponsiveDialog> {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: Text(cancelText),
|
child: Text(_getCancelText(context)),
|
||||||
),
|
),
|
||||||
...widget.actions
|
...widget.actions
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user