Skip to content

Commit 40b1426

Browse files
committed
dialog: Add "Learn more"-button param to showErrorDialog
1 parent 692c2f5 commit 40b1426

12 files changed

+70
-1
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@
447447
"@dialogClose": {
448448
"description": "Button label in dialogs to close."
449449
},
450+
"errorDialogLearnMore": "Learn more",
451+
"@errorDialogLearnMore": {
452+
"description": "Button label in error dialogs to open a web page with more information."
453+
},
450454
"errorDialogContinue": "OK",
451455
"@errorDialogContinue": {
452456
"description": "Button label in error dialogs to acknowledge the error and close the dialog."

lib/generated/l10n/zulip_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,12 @@ abstract class ZulipLocalizations {
693693
/// **'Close'**
694694
String get dialogClose;
695695

696+
/// Button label in error dialogs to open a web page with more information.
697+
///
698+
/// In en, this message translates to:
699+
/// **'Learn more'**
700+
String get errorDialogLearnMore;
701+
696702
/// Button label in error dialogs to acknowledge the error and close the dialog.
697703
///
698704
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
348348
@override
349349
String get dialogClose => 'Close';
350350

351+
@override
352+
String get errorDialogLearnMore => 'Learn more';
353+
351354
@override
352355
String get errorDialogContinue => 'OK';
353356

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
348348
@override
349349
String get dialogClose => 'Close';
350350

351+
@override
352+
String get errorDialogLearnMore => 'Learn more';
353+
351354
@override
352355
String get errorDialogContinue => 'OK';
353356

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
348348
@override
349349
String get dialogClose => 'Close';
350350

351+
@override
352+
String get errorDialogLearnMore => 'Learn more';
353+
351354
@override
352355
String get errorDialogContinue => 'OK';
353356

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
348348
@override
349349
String get dialogClose => 'Close';
350350

351+
@override
352+
String get errorDialogLearnMore => 'Learn more';
353+
351354
@override
352355
String get errorDialogContinue => 'OK';
353356

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
348348
@override
349349
String get dialogClose => 'Zamknij';
350350

351+
@override
352+
String get errorDialogLearnMore => 'Learn more';
353+
351354
@override
352355
String get errorDialogContinue => 'OK';
353356

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
348348
@override
349349
String get dialogClose => 'Закрыть';
350350

351+
@override
352+
String get errorDialogLearnMore => 'Learn more';
353+
351354
@override
352355
String get errorDialogContinue => 'OK';
353356

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
348348
@override
349349
String get dialogClose => 'Zavrieť';
350350

351+
@override
352+
String get errorDialogLearnMore => 'Learn more';
353+
351354
@override
352355
String get errorDialogContinue => 'OK';
353356

lib/widgets/dialog.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
import '../generated/l10n/zulip_localizations.dart';
4+
import 'actions.dart';
45

56
Widget _dialogActionText(String text) {
67
return Text(
@@ -27,7 +28,8 @@ class DialogStatus {
2728
final Future<void> closed;
2829
}
2930

30-
/// Displays an [AlertDialog] with a dismiss button.
31+
/// Displays an [AlertDialog] with a dismiss button
32+
/// and optional "Learn more" button.
3133
///
3234
/// The [DialogStatus.closed] field of the return value can be used
3335
/// for waiting for the dialog to be closed.
@@ -39,6 +41,7 @@ DialogStatus showErrorDialog({
3941
required BuildContext context,
4042
required String title,
4143
String? message,
44+
Uri? learnMoreButtonUrl,
4245
}) {
4346
final zulipLocalizations = ZulipLocalizations.of(context);
4447
final future = showDialog<void>(
@@ -47,6 +50,10 @@ DialogStatus showErrorDialog({
4750
title: Text(title),
4851
content: message != null ? SingleChildScrollView(child: Text(message)) : null,
4952
actions: [
53+
if (learnMoreButtonUrl != null)
54+
TextButton(
55+
onPressed: () => PlatformActions.launchUrl(context, learnMoreButtonUrl),
56+
child: _dialogActionText(zulipLocalizations.errorDialogLearnMore)),
5057
TextButton(
5158
onPressed: () => Navigator.pop(context),
5259
child: _dialogActionText(zulipLocalizations.errorDialogContinue)),

0 commit comments

Comments
 (0)