Skip to content

msglist: Implement new edited/moved label design. #900

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

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

PIG208
Copy link
Member

@PIG208 PIG208 commented Aug 20, 2024

This replaces the gutter edit state marker design. Since it leads to message displacement, a previous test case is no longer applicable.

We also inline part of what was previously in edit_state_marker.dart, because the new design simplifies the implementation.

Figma design: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3038-56393&t=WMT80mwuFaruNbVf-1

Fixes: #171

@PIG208
Copy link
Member Author

PIG208 commented Aug 20, 2024

Wasn't able to reopen #765 after accidentally closing it:

image

Here's the new PR for the new design.

@PIG208
Copy link
Member Author

PIG208 commented Aug 20, 2024

Screenshots
light dark
Screenshot from 2024-08-20 17-43-19 Screenshot from 2024-08-20 17-43-06

@PIG208 PIG208 added the maintainer review PR ready for review by Zulip maintainers label Aug 20, 2024
@PIG208 PIG208 force-pushed the marker-ui-final branch 4 times, most recently from 85e0fb9 to 3ce5a96 Compare August 20, 2024 21:57
@PIG208 PIG208 requested a review from chrisbobbe August 20, 2024 21:58
@PIG208
Copy link
Member Author

PIG208 commented Aug 21, 2024

Rebased and simplified the implementation a bit.

@gnprice
Copy link
Member

gnprice commented Aug 22, 2024

Wasn't able to reopen #765 after accidentally closing it:

FWIW for next time: I think the solution there is to push the commits you want back to the PR's branch, and then re-open the PR.

(In particular the error message there says "There are no new commits on the … branch", i.e. the branch is empty compared to main. You can fix that by pushing to fix what's in the branch.)

@gnprice
Copy link
Member

gnprice commented Aug 22, 2024

Though in this case, since the implementation is radically different from #765, a fresh PR is probably cleanest anyway.

@PIG208
Copy link
Member Author

PIG208 commented Aug 22, 2024

FWIW for next time: I think the solution there is to push the commits you want back to the PR's branch, and then re-open the PR.

I do recall running into the same issue a few years back. Couldn't find the link right now.

My attempted fix this time was amending the latest commit, and adding an empty commit on top of it. It's interesting that it didn't work. Will look into this next time (without mistakenly pushing to upstream!)

Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Thanks! Small comments below.

@@ -86,7 +84,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
required this.dateSeparator,
required this.dateSeparatorText,
required this.dmRecipientHeaderBg,
required this.editedMovedMarkerCollapsed,
required this.editStateLabel,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like there's a Figma design variable for this, labelEdited, so let's use that and put it in DesignVariables, sorted alphabetically in the default section (not marked // Not exactly from the Figma design […] or // Not named variables in Figma […]).

Comment on lines 1282 to 1290
if ((message.reactions?.total ?? 0) > 0)
ReactionChipsList(messageId: message.id, reactions: message.reactions!)
ReactionChipsList(messageId: message.id, reactions: message.reactions!),
if (editStateText != null)
Text(editStateText, textAlign: TextAlign.end,
style: TextStyle(
color: messageListTheme.editStateLabel,
fontFamily: 'Source Sans 3',
fontSize: 12,
height: (12 / 12))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the Figma isn't clear whether the reaction chips or the marker should come first, vertically. How about putting the marker first? In the case where there are dozens of reaction chips that wrap onto many lines, I think it would be neater and clearer if the EDITED or MOVED marker were above them instead of below them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that sounds good to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just to be sure, started a disccusion on CZO.

Text(editStateText, textAlign: TextAlign.end,
style: TextStyle(
color: messageListTheme.editStateLabel,
fontFamily: 'Source Sans 3',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we'll get 'Source Sans 3' automatically here, like in most other places, because this is rendered on a Material (via Scaffold, I think), and Material applies TextTheme.bodyMedium to its children via AnimatedDefaultTextStyle, and we've set TextTheme.bodyMedium to include 'Source Sans 3' (see zulipTypography in lib/widgets/text.dart).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like we're also redundantly passing 'Source Sans 3' where we render the sender name in MessageWithPossibleSender. Removing that (perhaps with a link to my explanation here, or quoting/paraphrasing it) would be a helpful cleanup in a separate NFC commit.

color: messageListTheme.editStateLabel,
fontFamily: 'Source Sans 3',
fontSize: 12,
height: (12 / 12))),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
height: (12 / 12))),
height: (12 / 12),
letterSpacing: proportionalLetterSpacing(context, 0.05, baseFontSize: 12),

I notice the Figma has 0.6px letter spacing, but if we use proportionalLetterSpacing, it'll grow and shrink with the system font-size setting, and that seems like a nice refinement.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for catching that! Didn't know that we have proportionalLetterSpacing.

Looks like 0.6px comes from the dev mode typography section, but the 5% letter spacing is probably intended:
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh interesting, so yeah, it looks like the 5% is expressed in the Figma too :) thanks for noticing that.

},
"messageIsEditedLabel": "EDITED",
"@messageIsEditedLabel": {
"description": "Label for an edited message."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"description": "Label for an edited message."
"description": "Label for an edited message. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)"

(similarly below)

Copy link
Member Author

Choose a reason for hiding this comment

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

One thing I was wondering about when implementing this, is that whether we should programmatically upper case the letters and translate the label normally, or just do it the current way.

We do have a precedent: "loginMethodDivider": "OR". But I can also see the appeal to using i18n.toUpperCase for something purely for styling purposes (similar to the text-transform: uppercase; approach as one could do in web), because in this case we aren't using uppercase letters to convey emphasis/exaggeration in the writing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Started a discussion here. My guess is that it might be preferred to just use uppercase letters, but I'm curious if there are better ways.

@PIG208
Copy link
Member Author

PIG208 commented Aug 26, 2024

Screenshots
light dart
Screenshot from 2024-08-26 14-23-01 image

PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Aug 26, 2024
We supplied the font 'Source Sans 3' to `TextTheme.bodyMedium` in
`lib/widgets/text.dart`. When rendered, `Material` applies this font via
`AnimatedDefaultTextStyle` by default, so there is no need to override
`fontFamily` explicitly.

See:

  zulip#900 (comment)

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208 PIG208 force-pushed the marker-ui-final branch 2 times, most recently from f976938 to 9a0f7da Compare August 26, 2024 18:44
@PIG208 PIG208 requested a review from chrisbobbe August 26, 2024 19:10
@PIG208
Copy link
Member Author

PIG208 commented Aug 26, 2024

Implemented the suggested changes. Thanks for the review @chrisbobbe! Started some CZO discussions on things that I have questions about.

@chrisbobbe
Copy link
Collaborator

Thanks! This LGTM except the CZO discussion seems like it's settling on having the marker come after the reactions list instead of before. Marking for Greg's review once he's back from vacation.

@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 Aug 27, 2024
@PIG208
Copy link
Member Author

PIG208 commented Aug 27, 2024

Pushed to move the marker after the reactions list.

@PIG208
Copy link
Member Author

PIG208 commented Sep 5, 2024

Updated the PR to share the final row between reaction chips and the edit state label mentioned here.

If necessary, we could add an RTL test case later for the new commit if we like this approach.

@PIG208
Copy link
Member Author

PIG208 commented Sep 5, 2024

Preview

Space saving

Before After
Screenshot from 2024-09-04 23-39-51 Screenshot from 2024-09-04 23-39-18

Overlap prevention

Barely enough space Not enough space Not enough space (w/o the workaround)
Screenshot from 2024-09-04 23-35-25 Screenshot from 2024-09-04 23-35-29 image

PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Sep 7, 2024
We supplied the font 'Source Sans 3' to `TextTheme.bodyMedium` in
`lib/widgets/text.dart`. When rendered, `Material` applies this font via
`AnimatedDefaultTextStyle` by default, so there is no need to override
`fontFamily` explicitly.

See:

  zulip#900 (comment)

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208 PIG208 requested review from gnprice and removed request for chrisbobbe September 11, 2024 17:05
PIG208 added a commit to PIG208/zulip-flutter that referenced this pull request Sep 12, 2024
We supplied the font 'Source Sans 3' to `TextTheme.bodyMedium` in
`lib/widgets/text.dart`. When rendered, `Material` applies this font via
`AnimatedDefaultTextStyle` by default, so there is no need to override
`fontFamily` explicitly.

See:

  zulip#900 (comment)

Signed-off-by: Zixuan James Li <[email protected]>
@PIG208 PIG208 force-pushed the marker-ui-final branch 3 times, most recently from 9c52563 to 783b5a2 Compare September 12, 2024 22:08
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, and thanks @chrisbobbe for the previous reviews!

Let's skip for now the complexity of trying to squash the edited/moved marker onto the same line as the end of the message. I think this version doesn't yet quite work — see below — and I'm also a little concerned about making the layout complicated, if for example the user is reading a long thread that got moved and so all the messages have markers. If people really find the extra vertical space annoying, we can revisit that.

Otherwise this all looks good, with just one nit below.

trailingPlaceholder: editStateLabel),
]),
if (editStateLabel != null)
PositionedDirectional(bottom: 0, end: 0, child: editStateLabel),
Copy link
Member

Choose a reason for hiding this comment

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

What happens if there are no reactions, but the message's own text ends with a full line? I think in this version that will end up having an overlap of the "EDITED" marker and the message text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, yeah, that could totally happen. It does look like that furthering this implementation to fix that as well can make it more complicated, unless we get a different solution.

Comment on lines 1261 to 1262
final editStateLabel = editStateText == null ? null : Text(editStateText,
textAlign: TextAlign.end,
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
final editStateLabel = editStateText == null ? null : Text(editStateText,
textAlign: TextAlign.end,
final editStateLabel = editStateText == null ? null
: Text(editStateText,
textAlign: TextAlign.end,

That way the Text constructor name, and editStateText which holds the actual text content, stay more visible and next to the other arguments to Text.

Copy link
Member Author

@PIG208 PIG208 Sep 13, 2024

Choose a reason for hiding this comment

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

Starting textAlign in a new line for the now inlined editStateLabel because we don't need to render another copy now.

@PIG208
Copy link
Member Author

PIG208 commented Sep 13, 2024

Dropped the commit 783b5a2, and pushed an update. Thanks!

We supplied the font 'Source Sans 3' to `TextTheme.bodyMedium` in
`lib/widgets/text.dart`. When rendered, `Material` applies this font via
`AnimatedDefaultTextStyle` by default, so there is no need to override
`fontFamily` explicitly.

See:

  zulip#900 (comment)

Signed-off-by: Zixuan James Li <[email protected]>
This replaces the gutter edit state marker design. Since it leads to
message displacement, the test "edit state updates do not affect
layout" is no longer applicable.

We also inline part of what was previously in edit_state_marker.dart,
because the new design simplifies the implementation, and remove the
now unused icons.

The design variables are taken from the Figma design:

  https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3038-56393&t=WMT80mwuFaruNbVf-1

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

gnprice commented Sep 16, 2024

Thanks! Looks good; merging.

@gnprice gnprice merged commit 6ca5524 into zulip:main Sep 16, 2024
1 check passed
@PIG208 PIG208 deleted the marker-ui-final branch September 17, 2024 00:18
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.

Show edited/moved marker on messages
3 participants