Skip to content
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

Compose box redesign #928

Merged
merged 8 commits into from
Nov 16, 2024
Merged

Compose box redesign #928

merged 8 commits into from
Nov 16, 2024

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Sep 4, 2024

Fixes: #915

@PIG208 PIG208 changed the title Compose box redesign WIP: Compose box redesign Sep 4, 2024
@PIG208 PIG208 changed the title WIP: Compose box redesign WIP Compose box redesign Sep 4, 2024
@PIG208 PIG208 force-pushed the pr-compose branch 5 times, most recently from c17497f to a566c67 Compare September 6, 2024 23:29
@PIG208 PIG208 changed the title WIP Compose box redesign Compose box redesign Sep 6, 2024
@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Sep 6, 2024
@PIG208 PIG208 requested a review from chrisbobbe September 6, 2024 23:30
@PIG208 PIG208 marked this pull request as ready for review September 6, 2024 23:30
@PIG208
Copy link
Member Author

PIG208 commented Sep 7, 2024

(getting the screenshots ready)

@PIG208 PIG208 force-pushed the pr-compose branch 3 times, most recently from c96e62c to 525240a Compare September 7, 2024 04:47
@PIG208
Copy link
Member Author

PIG208 commented Sep 7, 2024

The design specifies a 8px high padding before the message content:

image

The content can be scrolled past the padding, then clipped at the top border of the compose box:

image

This turned out to be tricky to implement, because InputDecorator's contentPadding also pads the scrollable view, and the content cannot be scrolled past the padding, leaving a gap:

with padding without padding
image Screenshot from 2024-09-07 00-50-07

A previous workaround was to fully vertically expand TextField by wrapping it within a SingleChildScrollView (implemented in e16251f), which does not handle the case that the cursor gets scrolled out of view when editing:

Example

image

The latest workaround disables clipping on the TextField and wraps it with a ClipRect, whose size is determined by a ConstrainedBox under our control.

@PIG208 PIG208 force-pushed the pr-compose branch 2 times, most recently from 9f9fb43 to 340a5ce Compare September 7, 2024 05:17
@PIG208
Copy link
Member Author

PIG208 commented Sep 10, 2024

I think I have found a true simple solution to this: set TextField.clipBehavior to Clip.none, set InputDecoration.contentPadding and wrap the TextField with a ClipRect under our control. This seems to work perfectly without the cursor issue.

@PIG208
Copy link
Member Author

PIG208 commented Sep 10, 2024

Preview
light dark
1000014499 1000014506
1000014500 1000014501
1000014503 1000014502
1000014504 1000014505
1000014508 1000014507
1000014509 1000014510
1000014512 1000014511

@PIG208
Copy link
Member Author

PIG208 commented Sep 10, 2024

Updated the PR with the screenshots. Ready for @chrisbobbe and @alya to review!

@PIG208 PIG208 requested a review from alya September 10, 2024 21:47
@PIG208 PIG208 assigned chrisbobbe and unassigned chrisbobbe Sep 16, 2024
@PIG208 PIG208 removed the maintainer review PR ready for review by Zulip maintainers label Sep 16, 2024
@alya
Copy link
Collaborator

alya commented Sep 17, 2024

I haven't compared carefully vs. the designs in Figma, but the screenshots look nice!

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @PIG208 for building this, and @chrisbobbe for the previous rounds of review!

Various comments below. I've read most of the branch, but not the last commit:
ea7d8b3 compose_box: Support redesigned button feedback

or the tests of the next-to-last, main commit:
1f49f51 compose_box: Implement most of compose box redesign

Comment on lines 1027 to 1029
child: SafeArea(left: false, right: false,
child: child)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this relies on an assumption that child is going to take care of the left and right insets.

Looking at where this _ComposeBoxContainer widget gets used, that's true at one call site, in _ComposeBoxLayout. But the other call site puts an _ErrorBanner there, and that doesn't appear to take care of these.

That could be handled by having _ErrorBanner use its own SafeArea widget. But probably the right answer is for the compose-box container to continue handling SafeArea with a minimum of 8px on both sides, like it does in main, to keep that job centralized.

_AttachFromCameraButton(contentController: contentController, contentFocusNode: contentFocusNode),
])),
SafeArea(
minimum: const EdgeInsets.symmetric(horizontal: 16),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version where the two children of the column use SafeArea with different minimum paddings doesn't seem quite right. In particular in the screenshots in #928 (comment) , it loses horizontal alignment between the send button and the end of the topic/content divider line.

Instead I think we want the same minimum horizontal padding on each of these SafeArea widgets (which is another reason it's helpful to centralize them as mentioned above), and then add 8px padding here on top of that. That way this always gets 8px more padding than its sibling.


/// Makes a copy of this color with [a] multiplied by `factor`.
///
/// `factor` must not be less than 0 or greater than 1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a bit easier to read when stated in the positive:

Suggested change
/// `factor` must not be less than 0 or greater than 1.
/// `factor` must be between 0 and 1, inclusive.

Comment on lines 24 to 25
check(() => color.withFadedAlpha(1.1)).throws<AssertionError>();
check(() => color.withFadedAlpha(-0.1)).throws<AssertionError>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be a separate test case (or ideally two) — these are logically independent of the main check this case is making

Comment on lines -156 to +160
borderBar: Colors.black.withValues(alpha: 0.41),
borderBar: Colors.black.withValues(alpha: 0.5),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme: Update borderBar to match Figma design

See also:
#928 (comment)

I guess this is also a reminder that it'd be good for us to take care of #831 and then the follow-up of having a script do the same with the main variables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a nit: the commit message reads to me like it's saying the previous value just wasn't written to match Figma. But from the linked comment it sounds like it was, and it just got edited in Figma since then.

That's interesting information in particular because it tells us Vlad does in practice edit existing variables that we've already used. Which motivates #831 and that follow-up task after it.

Can fix by s/match/follow change in/.

Comment on lines 25 to 26
const double _composeButtonWidth = 44;
const double _composeButtonsRowHeight = 42;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the Figma design calls for 44x42 buttons here.

But the standard minimum for accessibility is 44x44 logical pixels — and that's already the more permissive standard from Apple, where Google recommends a minimum of 48x48.

I don't see the point in cutting corners on accessibility to shave 2px of vertical space in the layout, and I don't see a rationale from Vlad about that. So let's move forward with 44x44 instead.

After this is merged, I can start a thread mentioning we made this adjustment and we'll see if Vlad has any tweaks he'd want to make elsewhere in the layout to account for that (or wants to give a rationale for why it's essential that these be only 42px tall instead of 44px). That's a follow-up because I don't want it to distract from or slow down getting this merged — in general, we want following accessibility guidelines to be the easy path of least resistance, not vice versa.

Comment on lines 1002 to 1007
icon: Icon(ZulipIcons.send,
// We set the color on `Icon` instead of `IconButton` because the
// Figma design does not apply it on the background of the button
// for states like highlighted, etc.
color: iconColor),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't follow this comment. This color property is about the foreground color, not the background, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do want to set the foreground color to iconColor; either IconButton.color or Icon.color will work.

We do want to avoid the default background colors (i.e. the color of the button: IconButton.hoverColor, IconButton.highlightColor); these are derived from IconButton.color if it is set (it is the fallback when the ambient ButtonStyle.overlayColor is not set, see IconButton.styleFrom, which is called by IconButton.build).

This exact behavior of falling back to the foreground color (IconButton.color) doesn't seem to be mentioned on the colors' dartdoc. When we set IconButton.highlightColor through an IconButtonTheme, it gets overridden by the color derived from IconButton.color.

we can clarify this bit by mentioning the specific button styles involved.

Comment on lines 390 to 393
static const verticalPadding = 8.0;
static const fontSize = 17.0;
static const lineHeight = 22.0;
static const lineHeightRatio = lineHeight / fontSize;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these are all internal, right? Let's make that clear by making them private

Comment on lines 429 to 430
// With this and the `minLines: 2` above, an empty content input
// gets 60px vertical distance between the top of the top shadow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's at default text scaling, right?

On my phone at my usual settings, I see 54px for this. If I switch my system text-size setting to default, I reproduce 60px.

Comment on lines 429 to 432
// With this and the `minLines: 2` above, an empty content input
// gets 60px vertical distance between the top of the top shadow
// and the bottom of the bottom shadow (with no text-size
// scaling). That's a bit more than the 54px given in the Figma,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, rereading, there's this reference at the end of the sentence. Clearer if it's moved next to the mention of 60x vertical distance, I think; it wasn't clear to me the first time what this parenthetical was about.

PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Nov 15, 2024
PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Nov 15, 2024
- We drop `_sendButtonSize` and `_inputVerticalPadding` because we no
  longer need them for setting the button's minHeight, along with
  `ButtonStyle` for the send button that was added in # 399, which is
  irrelevant to the new design.

- `ClipRect`'s size is determined by the `ConstrainedBox`.  This is
  mainly for showing the content through the `contentPadding` of the
  `TextField`, so that our `InsetShadowBox` can fade it smoothly there.
  The shadow is always there, but it is only visible when the
  `TextField` is long enough to be scrollable.

- For `InputDecorationTheme` on `_ComposeBoxLayout`, we eliminate
  `contentPadding`, while keeping `isDense` as `true` to explicitly
  remove paddings on the input widgets.

- Note that we use `withFadedAlpha` on `designVariables.textInput` because
  the color is already transparent in dark mode, and the helper allows us
  to multiply, instead of to override, the alpha channel of the color with
  a factor.

- DesignVariables.icon's value has been updated to match the current
  design. This would affect the appearance of the
  ChooseAccountPageOverflowButton on the choose account page, which is
  intentional.

This is "most of" the redesign because the new button feedback is
supported later.

See also:

  - zulip#928 (comment)
  - zulip#928 (comment),
    which elaborates on the issue we intend to solve with the
    `ClipRect` setup.
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350

Signed-off-by: Zixuan James Li <[email protected]>
PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Nov 15, 2024
- We drop `_sendButtonSize` and `_inputVerticalPadding` because we no
  longer need them for setting the button's minHeight, along with
  `ButtonStyle` for the send button that was added in # 399, which is
  irrelevant to the new design.

- `ClipRect`'s size is determined by the `ConstrainedBox`.  This is
  mainly for showing the content through the `contentPadding` of the
  `TextField`, so that our `InsetShadowBox` can fade it smoothly there.
  The shadow is always there, but it is only visible when the
  `TextField` is long enough to be scrollable.

- For `InputDecorationTheme` on `_ComposeBoxLayout`, we eliminate
  `contentPadding`, while keeping `isDense` as `true` to explicitly
  remove paddings on the input widgets.

- The height of the compose buttons is 42px in the Figma design, but
  44px in the implementation.  We change that to match the minimum
  button size per the accessibility recommendation from Apple.

- Note that we use `withFadedAlpha` on `designVariables.textInput` because
  the color is already transparent in dark mode, and the helper allows us
  to multiply, instead of to override, the alpha channel of the color with
  a factor.

- DesignVariables.icon's value has been updated to match the current
  design. This would affect the appearance of the
  ChooseAccountPageOverflowButton on the choose account page, which is
  intentional.

This is "most of" the redesign because the new button feedback is
supported later.

See also:

  - zulip#928 (comment)
  - zulip#928 (comment),
    which elaborates on the issue we intend to solve with the
    `ClipRect` setup.
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350
  - zulip#928 (comment)

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208
Copy link
Member Author

PIG208 commented Nov 15, 2024

Thanks for the review! I have updated the PR.

PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Nov 15, 2024
PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Nov 15, 2024
- We drop `_sendButtonSize` and `_inputVerticalPadding` because we no
  longer need them for setting the button's minHeight, along with
  `ButtonStyle` for the send button that was added in # 399, which is
  irrelevant to the new design.

- `ClipRect`'s size is determined by the `ConstrainedBox`.  This is
  mainly for showing the content through the `contentPadding` of the
  `TextField`, so that our `InsetShadowBox` can fade it smoothly there.
  The shadow is always there, but it is only visible when the
  `TextField` is long enough to be scrollable.

- For `InputDecorationTheme` on `_ComposeBoxLayout`, we eliminate
  `contentPadding`, while keeping `isDense` as `true` to explicitly
  remove paddings on the input widgets.

- The height of the compose buttons is 42px in the Figma design, but
  44px in the implementation.  We change that to match the minimum
  button size per the accessibility recommendation from Apple.

- Note that we use `withFadedAlpha` on `designVariables.textInput` because
  the color is already transparent in dark mode, and the helper allows us
  to multiply, instead of to override, the alpha channel of the color with
  a factor.

- DesignVariables.icon's value has been updated to match the current
  design. This would affect the appearance of the
  ChooseAccountPageOverflowButton on the choose account page, which is
  intentional.

This is "most of" the redesign because the new button feedback is
supported later.

See also:

  - zulip#928 (comment)
  - zulip#928 (comment),
    which elaborates on the issue we intend to solve with the
    `ClipRect` setup.
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350
  - zulip#928 (comment)

Signed-off-by: Zixuan James Li <[email protected]>
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The changes in the revision all look great.

I've now read the whole thing; comments below on the remaining parts.

One commit-message nit: use "compose" for the prefix rather than "compose_box", to save a bit of space in our often-crowded summary lines. The shorter version is what we originally used and have used most; see #886 (comment) where I looked at previous commits.

Comment on lines +1002 to +1007
// We set [Icon.color] instead of [IconButton.color] because the
// latter implicitly uses colors derived from it to override the
// ambient [ButtonStyle.overlayColor], where we set the color for
// the highlight state to match the Figma design.
color: iconColor),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks — this comment explains it.

Comment on lines 59 to 61
if (textScaleFactor != null) {
tester.platformDispatcher.textScaleFactorTestValue = textScaleFactor;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this step just go in the test cases that need it? That way we avoid making this shared helper more complex with a growing number of optional features, plus it makes it transparent in the test cases exactly what's happening.

If this step were a bit more code than this (or if we were writing lots of very short tests that used it), another tactic would be to make a helper function just for this, which those tests could call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined these without a helper, because they are short enough.

Comment on lines 722 to 723
TypingNotifier.debugEnable = false;
addTearDown(TypingNotifier.debugReset);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason this step is needed is the enterText calls inside checkContentInputMaxHeight, right?

In that case, a good home for this is inside that function. That makes clearer the relationship to why it's needed, and as a bonus makes each test case simpler.

for (int i = 0; i < maxVisibleLines - 2 + 1; i++) {
// Add one line at a time,
// until the content input reaches its max height.
await tester.enterText(finder, content);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: just inline finder; the name "finder" isn't very informative about what this line is doing

Or use contentInputFinder? That'd match the getRect call just below, and its name is clear.

Comment on lines 700 to 703
// On top of the existing two lines, add exactly the number of lines
// needed such that the last line will not visible in the content input
// after reaching the max height.
for (int i = 0; i < maxVisibleLines - 2 + 1; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop is kind of confusing to follow. A very local fix would be to make i represent the number of lines in content:

Suggested change
// On top of the existing two lines, add exactly the number of lines
// needed such that the last line will not visible in the content input
// after reaching the max height.
for (int i = 0; i < maxVisibleLines - 2 + 1; i++) {
// On top of the existing two lines, add exactly the number of lines
// needed such that the last line will not visible in the content input
// after reaching the max height.
for (int i = 2; i < maxVisibleLines + 1; i++) {

I think a further clarification is then to have just one loop variable, the number of lines, instead of effectively two in parallel (i and content). That can look like this:

      // Add one line at a time, until the content input reaches its max height.
      int numLines;
      double? height;
      for (numLines = 2; numLines <= 1000; numLines++) {
        final content = List.generate(numLines, (_) => 'foo').join('\n');
        await tester.enterText(finder, content);
        await tester.pump();
        final newHeight = tester.getRect(contentInputFinder).height;
        if (newHeight == height) {
          break;
        }
        height = newHeight;
      }
      check(height).isNotNull().isCloseTo(maxHeight, 0.5);
      // The last line added did not stretch the content input,
      // so only the lines before it are at least partially visible.
      check(numLines - 1).equals(maxVisibleLines);

@gnprice
Copy link
Member

gnprice commented Nov 15, 2024

One commit-message nit: use "compose" for the prefix rather than "compose_box"

Ah, I see we raced and you've already made that change 🙂

And use it everywhere we were using `.withValues(alpha:`
to fade a color variable, except for one place in
`lib/widgets/emoji_reaction.dart` where the variable is
semi-transparent in dark mode to begin with.
We'll do that as a non-NFC change in a later commit.

Signed-off-by: Zixuan James Li <[email protected]>
Because splashColor in dark mode is transparent, this changes the
appearance.

Signed-off-by: Zixuan James Li <[email protected]>
Because these buttons share the same superclass, we can de-duplicate
styling code without the theme override.  This helps de-nest the
layout code.

While more types of buttons that are not subclasses of
`_AttachUploadsButton` might be added, a theme is probably still
unnecessary given that we can lift a common button class that handles
the styling.

Signed-off-by: Zixuan James Li <[email protected]>
The icons are exported from the Figma design:
  https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=544-22131&node-type=CANVAS&t=hNeqhPGojoFpTJnp-0

Due to the limitation of the icon font, image.svg and send.svg have
been adjusted with a tool that converts SVG strokes to fills:
  https://www.npmjs.com/package/oslllo-svg-fixer

See also:

  - https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Icon.20not.20rendering.20correctly/near/1936793

Signed-off-by: Zixuan James Li <[email protected]>
PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Nov 15, 2024
- We drop `_sendButtonSize` and `_inputVerticalPadding` because we no
  longer need them for setting the button's minHeight, along with
  `ButtonStyle` for the send button that was added in # 399, which is
  irrelevant to the new design.

- `ClipRect`'s size is determined by the `ConstrainedBox`.  This is
  mainly for showing the content through the `contentPadding` of the
  `TextField`, so that our `InsetShadowBox` can fade it smoothly there.
  The shadow is always there, but it is only visible when the
  `TextField` is long enough to be scrollable.

- For `InputDecorationTheme` on `_ComposeBoxLayout`, we eliminate
  `contentPadding`, while keeping `isDense` as `true` to explicitly
  remove paddings on the input widgets.

- The height of the compose buttons is 42px in the Figma design, but
  44px in the implementation.  We change that to match the minimum
  button size per the accessibility recommendation from Apple.

- Note that we use `withFadedAlpha` on `designVariables.textInput` because
  the color is already transparent in dark mode, and the helper allows us
  to multiply, instead of to override, the alpha channel of the color with
  a factor.

- DesignVariables.icon's value has been updated to match the current
  design. This would affect the appearance of the
  ChooseAccountPageOverflowButton on the choose account page, which is
  intentional.

This is "most of" the redesign because the new button feedback is
supported later.

See also:

  - zulip#928 (comment)
  - zulip#928 (comment),
    which elaborates on the issue we intend to solve with the
    `ClipRect` setup.
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350
  - zulip#928 (comment)

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208

This comment was marked as outdated.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More commit-message nits:

  `ButtonStyle` for the send button that was added in # 399, which is

should complete the link


See also:

  - https://github.com/zulip/zulip-flutter/pull/928#discussion_r1815661095
  - https://github.com/zulip/zulip-flutter/pull/928#issuecomment-2335042432,
    which elaborates on the issue we intend to solve with the
    `ClipRect` setup.
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350
  - https://github.com/zulip/zulip-flutter/pull/928#discussion_r1842988359

These should each get a few words about what they're about, like the second one has. In particular that's needed so that the reader can tell whether they're relevant for whatever the reader is currently trying to understand. (Otherwise they have to go open all of them one by one… which is extra slow because both Figma, and GitHub in long threads, take a long time to load.)

The second link sounds (from the description here) like it's about the same thing as the second paragraph above. So probably it should just move into that paragraph, like:

  The shadow is always there, but it is only visible when the
  `TextField` is long enough to be scrollable. Discussion here:
    https://github.com/zulip/zulip-flutter/pull/928#issuecomment-2335042432

and then (a) its context is clear and (b) someone reading the paragraph sees there's a relevant link.

See also:
  https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3707-41711&n

ode-type=frame&t=sSYomsJzGCt34D8N-0


Similarly this should describe how the link relates to what the commit message is saying. If I understand right, that can be:

Design spec here:
  https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3707-41711&n

ode-type=frame&t=sSYomsJzGCt34D8N-0

focusNode: widget.focusNode,
fieldViewBuilder: (context) => ConstrainedBox(
constraints: BoxConstraints(maxHeight: maxHeight(context)),
child: ClipRect(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, rereading the commit message I see this:

- `ClipRect`'s size is determined by the `ConstrainedBox`.  This is
  mainly for showing the content through the `contentPadding` of the
  `TextField`, so that our `InsetShadowBox` can fade it smoothly there.

and it explains the presence of this widget. I think that will be useful information for readers of the resulting code, not only of this commit's changes. So let's put it in a code comment:

Suggested change
child: ClipRect(
// This [ClipRect] replaces the [TextField] clipping we disable below.
child: ClipRect(

(See https://github.com/zulip/zulip-mobile/blob/main/docs/style.md#commit-messages-vs-comments .)

fillColor: colorScheme.surface,
),
);
contentPadding: EdgeInsets.zero,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit-message nit:

- For `InputDecorationTheme` on `_ComposeBoxLayout`, we eliminate
  `contentPadding`, while keeping `isDense` as `true` to explicitly
  remove paddings on the input widgets.

I reread this paragraph just now and thought "wait, didn't we set contentPadding to zero? I sure thought this code still set both isDense and contentPadding". (Then I went back to the code to check.) IOW, I read this as saying we stopped passing that argument.

s/eliminate/zero out/ would fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also move the commas: "we eliminate contentPadding while keeping isDense true, to explicitly …".

As is, it looks like it's saying that the way we remove padding is by keeping isDense true, all at the same time as we eliminate contentPadding. In reality (IIUC) both parameters are part of removing padding.

PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Nov 15, 2024
- We drop `_sendButtonSize` and `_inputVerticalPadding` because we no
  longer need them for setting the button's minHeight, along with
  `ButtonStyle` for the send button that was added in # 399, which is
  irrelevant to the new design.

- `ClipRect`'s size is determined by the `ConstrainedBox`.  This is
  mainly for showing the content through the `contentPadding` of the
  `TextField`, so that our `InsetShadowBox` can fade it smoothly there.
  The shadow is always there, but it is only visible when the
  `TextField` is long enough to be scrollable. Discussion here:
    zulip#928 (comment)

- For `InputDecorationTheme` on `_ComposeBoxLayout`, we zero out
  `contentPadding` while keeping `isDense` as `true`, to explicitly
  remove paddings on the input widgets.

- The height of the compose buttons is 42px in the Figma design, but
  44px in the implementation.  We change that to match the minimum
  button size per the accessibility recommendation from Apple.
  Discussion here:
    zulip#928 (comment)

- Note that we use `withFadedAlpha` on `designVariables.textInput` because
  the color is already transparent in dark mode, and the helper allows us
  to multiply, instead of to override, the alpha channel of the color with
  a factor.  Discussion here:
    zulip#928 (comment)

- DesignVariables.icon's value has been updated to match the current
  design.  This would affect the appearance of the
  ChooseAccountPageOverflowButton on the choose account page, which is
  intentional.

This is "most of" the redesign because the new button feedback is
supported later.

Design spec here:
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350

Signed-off-by: Zixuan James Li <[email protected]>
- We drop `_sendButtonSize` and `_inputVerticalPadding` because we no
  longer need them for setting the button's minHeight, along with
  `ButtonStyle` for the send button that was added in zulip#399, which is
  irrelevant to the new design.

- `ClipRect`'s size is determined by the `ConstrainedBox`.  This is
  mainly for showing the content through the `contentPadding` of the
  `TextField`, so that our `InsetShadowBox` can fade it smoothly there.
  The shadow is always there, but it is only visible when the
  `TextField` is long enough to be scrollable. Discussion here:
    zulip#928 (comment)

- For `InputDecorationTheme` on `_ComposeBoxLayout`, we zero out
  `contentPadding` while keeping `isDense` as `true`, to explicitly
  remove paddings on the input widgets.

- The height of the compose buttons is 42px in the Figma design, but
  44px in the implementation.  We change that to match the minimum
  button size per the accessibility recommendation from Apple.
  Discussion here:
    zulip#928 (comment)

- Note that we use `withFadedAlpha` on `designVariables.textInput` because
  the color is already transparent in dark mode, and the helper allows us
  to multiply, instead of to override, the alpha channel of the color with
  a factor.  Discussion here:
    zulip#928 (comment)

- DesignVariables.icon's value has been updated to match the current
  design.  This would affect the appearance of the
  ChooseAccountPageOverflowButton on the choose account page, which is
  intentional.

This is "most of" the redesign because the new button feedback is
supported later.

Design spec here:
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395
  - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350

Signed-off-by: Zixuan James Li <[email protected]>
This disables the splash effect for all the compose buttons and the
send button, and implements a rounded rectangular background that
appears on hover/pressed.

Different from the style that all the compose buttons share, this
feedback also applies to the send button, and will apply to more buttons
in the app.  In the future we should migrate more buttons to use this
style, so it doesn't belong to a shared base class.

See also:
  https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3707-41711&node-type=frame&t=sSYomsJzGCt34D8N-0

Fixes: zulip#915

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208
Copy link
Member Author

PIG208 commented Nov 15, 2024

Moved the links to the paragraph they each correspond to, and added the comment on ClipRect (the related paragraph is still kept in the commit, in case the reader is looking back at this for a more verbose explanation on this design's origin).

@gnprice
Copy link
Member

gnprice commented Nov 16, 2024

Looks good — merging. Thanks again for all your work on this!

@gnprice gnprice merged commit 94cf40e into zulip:main Nov 16, 2024
1 check passed
@PIG208 PIG208 deleted the pr-compose branch November 18, 2024 16:04
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compose-box layout redesign
4 participants