Skip to content

Commit 4fe4b2e

Browse files
gnpriceGaurav-Kushwaha-1225
authored andcommitted
dialog [nfc]: Generalize to ModalStatus, renaming DialogStatus
We'll soon use this for modal bottom sheets too, aka action sheets. Arguably that could mean it belongs in some other file, not specific to dialogs nor bottom sheets. But there isn't an obvious other file for it, and I think this is as good a home as any.
1 parent 0417c87 commit 4fe4b2e

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

lib/widgets/content.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ class GlobalTime extends StatelessWidget {
12141214
final GlobalTimeNode node;
12151215
final TextStyle ambientTextStyle;
12161216

1217-
static final _dateFormat = DateFormat('EEE, MMM d, y, h:mm a'); // TODO(i18n): localize date
1217+
static final _dateFormat = DateFormat('EEE, MMM d, y, h:mm a'); // TODO(intl): localize date
12181218

12191219
@override
12201220
Widget build(BuildContext context) {
@@ -1318,12 +1318,12 @@ class MessageTableCell extends StatelessWidget {
13181318
}
13191319

13201320
void _launchUrl(BuildContext context, String urlString) async {
1321-
DialogStatus showError(BuildContext context, String? message) {
1321+
ModalStatus showError(BuildContext context, String? message) {
13221322
final zulipLocalizations = ZulipLocalizations.of(context);
13231323
return showErrorDialog(context: context,
1324-
title: zulipLocalizations.errorCouldNotOpenLinkTitle,
1324+
title: 'Unable to open link',
13251325
message: [
1326-
zulipLocalizations.errorCouldNotOpenLink(urlString),
1326+
'Link could not be opened: $urlString',
13271327
if (message != null) message,
13281328
].join("\n\n"));
13291329
}
@@ -1571,7 +1571,6 @@ InlineSpan _errorUnimplemented(UnimplementedNode node, {required BuildContext co
15711571
// because release mode isn't yet about general users but developer demos,
15721572
// and we want to keep the demos honest.
15731573
// TODO(#194) think through UX for general release
1574-
// TODO(#1285) translate this
15751574
final htmlNode = node.htmlNode;
15761575
if (htmlNode is dom.Element) {
15771576
return TextSpan(children: [

lib/widgets/dialog.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,28 @@ Widget _dialogActionText(String text) {
1616
);
1717
}
1818

19-
/// Tracks the status of a dialog, in being still open or already closed.
19+
/// Tracks the status of a modal dialog or modal bottom sheet,
20+
/// in being still open or already closed.
2021
///
2122
/// See also:
22-
/// * [showDialog], whose return value this class is intended to wrap.
23-
class DialogStatus {
24-
const DialogStatus(this.closed);
23+
/// * [showDialog] and [showModalBottomSheet], whose return values
24+
/// this class is intended to wrap.
25+
class ModalStatus {
26+
const ModalStatus(this.closed);
2527

26-
/// Resolves when the dialog is closed.
28+
/// Resolves when the dialog or bottom sheet is closed.
2729
final Future<void> closed;
2830
}
2931

3032
/// Displays an [AlertDialog] with a dismiss button.
3133
///
32-
/// The [DialogStatus.closed] field of the return value can be used
34+
/// The [ModalStatus.closed] field of the return value can be used
3335
/// for waiting for the dialog to be closed.
3436
// This API is inspired by [ScaffoldManager.showSnackBar]. We wrap
35-
// [showDialog]'s return value, a [Future], inside [DialogStatus]
37+
// [showDialog]'s return value, a [Future], inside [ModalStatus]
3638
// whose documentation can be accessed. This helps avoid confusion when
3739
// intepreting the meaning of the [Future].
38-
DialogStatus showErrorDialog({
40+
ModalStatus showErrorDialog({
3941
required BuildContext context,
4042
required String title,
4143
String? message,
@@ -51,7 +53,7 @@ DialogStatus showErrorDialog({
5153
onPressed: () => Navigator.pop(context),
5254
child: _dialogActionText(zulipLocalizations.errorDialogContinue)),
5355
]));
54-
return DialogStatus(future);
56+
return ModalStatus(future);
5557
}
5658

5759
void showSuggestedActionDialog({

0 commit comments

Comments
 (0)