Skip to content

Conversation

@chrisbobbe
Copy link
Collaborator

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
image

The most interesting change is to extract a base class _Banner out of _ErrorBanner:

We'll make a new subclass with a name like _EditMessageBanner for #126; here's a rough sketch of what that'll look like:

class _EditMessageBanner extends _Banner { const _EditMessageBanner(); @override String getLabel(ZulipLocalizations zulipLocalizations) => zulipLocalizations.composeBoxBannerLabelEditMessage; @override Color getLabelColor(DesignVariables designVariables) => designVariables.bannerTextIntInfo; @override Color getBackgroundColor(DesignVariables designVariables) => designVariables.bannerBgIntInfo; @override Widget? buildTrailing(context) { return Row(mainAxisSize: MainAxisSize.min, spacing: 8, children: [ ZulipWebUiKitButton(label: 'Cancel', onPressed: () {}), ZulipWebUiKitButton(label: 'Save', attention: ZulipWebUiKitButtonAttention.high, onPressed: () {}), ]); } }

Related: #126

Copy link
Member

@PIG208 PIG208 left a 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.

Comment on lines +1382 to +1441
@override
String getLabel(ZulipLocalizations zulipLocalizations) =>
_getLabel(zulipLocalizations);
final String Function(ZulipLocalizations) _getLabel;
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

@chrisbobbe chrisbobbe requested a review from gnprice March 24, 2025 22:47
@chrisbobbe chrisbobbe assigned gnprice and unassigned PIG208 Mar 24, 2025
@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Mar 24, 2025
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.
@gnprice gnprice merged commit e524e6b into zulip:main Mar 25, 2025
@gnprice
Copy link
Member

gnprice commented Mar 25, 2025

Thanks to you both! Looks good; merged.

@chrisbobbe chrisbobbe deleted the edit-message-1 branch March 25, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration review Added by maintainers when PR may be ready for integration

3 participants