- Notifications
You must be signed in to change notification settings - Fork 374
Edit-message (1/n): Refactor compose-box banner logic #1430
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
PIG208 left a comment
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! Left a comment; this otherwise LGTM.
| @override | ||
| String getLabel(ZulipLocalizations zulipLocalizations) => | ||
| _getLabel(zulipLocalizations); | ||
| final String Function(ZulipLocalizations) _getLabel; |
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.
I can see how this is needed for _EditMessageBanner to just be able to override getLabel. What's the drawback of having an API similar to Flutter widgets like Container and make _ErrorBanner and _EditMessageBanner direct subclasses of StatelessWidget? For example:
class _EditMessageBanner extends StatelessWidget { const _EditMessageBanner(); @override Widget build(BuildContext context) { final zulipLocalizations = ZulipLocalizations.of(context); final designVariables = DesignVariables.of(context); final trailing = Row( // … ); return _Banner( label: zulipLocalizations.errorDialogTitle, labelColor: designVariables.btnLabelAttMediumIntDanger, backgroundColor: designVariables.bannerBgIntDanger, trailing: trailing); } }Maybe keeping _Banner as an abstract base class is needed for code structuring reasons/later changes?
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.
I think the idea was just to have one fewer widget in the widget tree.
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.
That alternate API looks like a good one to me. Maybe we'll refactor to it later.
I think an extra widget in the tree isn't a big deal. The style Flutter goes for in general is that widgets are cheap; there are lots of widgets; and they're configured mostly by composition (like in the example code above), rather than by inheritance.
We'll add a new subclass for the "Cancel" / "Save" banner in the upcoming edit-message compose box.
In the Figma: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4010-6425&m=dev https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-17028&m=dev the banner label's 9px vertical padding is factored as 5px applied to the whole banner, and 4px applied to just the label, excluding trailing buttons. Follow that, so it can work as intended when we add such buttons.
And add some features to _Banner to support that TODO, and a Figma link.
Before, the 8px end padding would just be added to any SafeArea padding. Now, it's done using SafeArea.minimum, so it doesn't get too big.
When we add a _Banner subclass for the edit-message compose box, we'd like it to control its own label instead of expecting it from callers.
_ComposeBoxContainer also supports an error banner that doesn't replace the text inputs. We don't use that feature yet (the Figma has some examples where it'll be helpful: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-16992&m=dev and we used it in a draft toward zulip#720 that wasn't merged: zulip#720 (comment) ) but it seems helpful anyway to nail down this helper like this.
The Figma also has examples of warning-, info-, and brand-styled banners, not just error-colored ones: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3988-38201&m=dev https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-13405&m=dev We're about to add an info-styled one, for the edit-message feature.
| Thanks to you both! Looks good; merged. |
These commits help get the code ready to implement the blue "Edit message" banner, with the "Cancel" and "Save" buttons; see Figma:
https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3988-38201&m=dev

The most interesting change is to extract a base class
_Bannerout of_ErrorBanner:We'll make a new subclass with a name like
_EditMessageBannerfor #126; here's a rough sketch of what that'll look like:Related: #126