Skip to content

Commit 6604cf4

Browse files
committed
compose [nfc]: Make confirmation dialog message flexible
1 parent 9c0b955 commit 6604cf4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/widgets/compose_box.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,11 +1849,15 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
18491849

18501850
@override
18511851
void startEditInteraction(int messageId) async {
1852-
if (await _abortBecauseContentInputNotEmpty()) return;
1852+
final zulipLocalizations = ZulipLocalizations.of(context);
1853+
1854+
if (await _abortBecauseContentInputNotEmpty(
1855+
message: zulipLocalizations.discardDraftConfirmationDialogMessage)) {
1856+
return;
1857+
}
18531858
if (!mounted) return;
18541859

18551860
final store = PerAccountStoreWidget.of(context);
1856-
final zulipLocalizations = ZulipLocalizations.of(context);
18571861

18581862
switch (store.getEditMessageErrorStatus(messageId)) {
18591863
case null:
@@ -1878,12 +1882,14 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
18781882

18791883
/// If there's text in the compose box, give a confirmation dialog
18801884
/// asking if it can be discarded and await the result.
1881-
Future<bool> _abortBecauseContentInputNotEmpty() async {
1885+
Future<bool> _abortBecauseContentInputNotEmpty({
1886+
required String message,
1887+
}) async {
18821888
final zulipLocalizations = ZulipLocalizations.of(context);
18831889
if (controller.content.textNormalized.isNotEmpty) {
18841890
final dialog = showSuggestedActionDialog(context: context,
18851891
title: zulipLocalizations.discardDraftConfirmationDialogTitle,
1886-
message: zulipLocalizations.discardDraftConfirmationDialogMessage,
1892+
message: message,
18871893
// TODO(#1032) "destructive" style for action button
18881894
actionButtonText: zulipLocalizations.discardDraftConfirmationDialogConfirmButton);
18891895
if (await dialog.result != true) return true;

0 commit comments

Comments
 (0)