Skip to content

Commit ac1c602

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 601936d commit ac1c602

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

Diff for: lib/widgets/content.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ 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,
13241324
title: zulipLocalizations.errorCouldNotOpenLinkTitle,

Diff for: lib/widgets/dialog.dart

+11-9
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)