-
Notifications
You must be signed in to change notification settings - Fork 309
Edit-message (4/n): Misc. preparation for edit-message feature #1471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good to me overall. Left a small comment, and marking for Greg's review.
@@ -21,11 +21,11 @@ Widget _dialogActionText(String text) { | |||
/// | |||
/// See also: | |||
/// * [showDialog], whose return value this class is intended to wrap. | |||
class DialogStatus { | |||
class DialogStatus<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to document the meaning of the type parameter. Specially, from showDialog
, this part seems relevant:
/// If the application has multiple [Navigator] objects, it may be necessary to
/// call `Navigator.of(context, rootNavigator: true).pop(result)` to close the
/// dialog rather than just `Navigator.pop(context, result)`.
///
/// Returns a [Future] that resolves to the value (if any) that was passed to
/// [Navigator.pop] when the dialog was closed.
We just need to adapt it to fit our wrapper class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Generally this looks good; a couple of small comments (adding to Zixuan's above).
lib/widgets/dialog.dart
Outdated
/// Resolves when the dialog is closed. | ||
final Future<void> closed; | ||
final Future<T?> closed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the meaning of the value that this resolves to?
(I think this question overlaps with Zixuan's comment above.)
test/widgets/dialog_test.dart
Outdated
actionButtonText: 'Sure',); | ||
await tester.pump(); | ||
await tester.tap(find.text('Sure')); | ||
await check(dialog.closed).completes((it) => it.equals(SuggestedActionDialogResult.doAction)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: line too long: key information past 80 columns (namely the only information that distinguishes this check from its opposite in the other test case 🙂)
To avoid wasting a lot of vertical space in the edit-message compose box (coming up) with large text-scale settings. Related: zulip#1023
Move vertical padding so it won't wrap the trailing element, when present (as a `buildTrailing` that returns non-null). When we add the "Cancel" and "Save" buttons for the edit-message banner, those will want to control their own outer vertical padding to make it respond to taps, because the painted button is supposed to be just 28px tall, which is too small for a touch target; see discussion linked in dartdoc. NFC because `buildTrailing` on _Banner's only subclass, _ErrorBanner, returns null.
fba1233
to
1d410a7
Compare
Thanks for the reviews! Revision pushed. |
lib/widgets/dialog.dart
Outdated
child: _dialogActionText(actionButtonText ?? zulipLocalizations.dialogContinue)), | ||
])); | ||
return DialogStatus(_wrapFutureExpectingNonNull(future)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah interesting.
What happens if the user tries to dismiss the dialog without tapping either button? E.g. by tapping outside the dialog's area (on the obscured remainder of the page that's under the dialog), or by using the Android "back" gesture/button.
I think we'd want to have those work, and have the same effect as tapping the "Cancel" button.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, thanks for catching this—addressing this in the new revision.
1d410a7
to
8694baa
Compare
Thanks for the review! Revision pushed. |
lib/widgets/app.dart
Outdated
logOutAccount(GlobalStoreWidget.of(context), accountId); | ||
}); | ||
actionButtonText: zulipLocalizations.logOutConfirmationDialogConfirmButton); | ||
if (await dialog.closed == true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, hmm, I guess this doesn't look ideal. What it means is "did the user press the 'Log out' button", but what it looks like it means is "was the dialog closed".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Maybe rename the field, say to result
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the revision! LGTM modulo the subthread above, and two nits below.
lib/widgets/dialog.dart
Outdated
/// If this completes with null, the dialog was dismissed. | ||
/// Otherwise, completes with a [T] identifying the interaction's outcome. | ||
/// | ||
/// See, e.g., [showSuggestedActionDialog] and [SuggestedActionDialogResult]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the latter reference no longer exists
lib/widgets/dialog.dart
Outdated
context: context, | ||
builder: (BuildContext context) => AlertDialog( | ||
title: Text(title), | ||
content: SingleChildScrollView(child: Text(message)), | ||
actions: [ | ||
TextButton( | ||
onPressed: () => Navigator.pop(context), | ||
onPressed: () => Navigator.pop<bool?>(context, null), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the types allow bool
here (and below):
onPressed: () => Navigator.pop<bool?>(context, null), | |
onPressed: () => Navigator.pop<bool>(context, null), |
and that seems a bit more consistent with bool
as the type parameter on showDialog
With this API, we can use showSuggestedActionDialog in an "early return" style -- await the user's choice, and early return if they chose to dismiss the dialog. That's particularly helpful when the confirmation dialog is opened in an `if` block. We'll use this for the upcoming "edit message" feature (zulip#126), where we plan to offer a confirmation dialog before entering an edit-message session, but only if the compose box has text for a new message in it (which would be discarded if the user wants to go ahead).
8694baa
to
4596245
Compare
Thanks for the review! Revision pushed. |
Thanks! Looks good; merging. |
Here's a small batch of miscellaneous prep work for the edit-message feature, #126.