-
Notifications
You must be signed in to change notification settings - Fork 221
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
lightbox: Added user's avatar in the lightbox app bar #1092
base: main
Are you sure you want to change the base?
Conversation
3b20b77
to
a1e4aff
Compare
Thanks @shivanshsharma13 ! Please add screenshots showing your changes to the PR description. |
HI @alya Done! |
Thanks for the PR. Before we can review this, it will need (a) tests and (b) to follow our Git style. See our README at: https://github.com/zulip/zulip-flutter#submitting-a-pull-request |
Oh also:
|
a1e4aff
to
38a8e09
Compare
Hi, sorry was a bit confused. Now I have implemented the correct code. It's ready for review. Adding test for this as well. |
|
38a8e09
to
15e1ea8
Compare
Done the changes!
|
Thanks! How about making it size 36px and border-radius Here's a screenshot with those numbers I've suggested: Also please fix indentation and whitespace to match the project's style, and use |
Thanks for those screenshots, although I notice they're a little pixelated.
As I said, the RN app uses 36 and 36 / 8. The lightbox page will likely change when our designer makes a design for it. Temporarily, I think taking these numbers from the RN app is fine. There's no point using the Please choose either:
Please also update the commit with the other things I requested: #1092 (comment) |
15e1ea8
to
1835cba
Compare
Hi, Thanks for the detailed explanation. Added the 36 size and 36/8 as per suggestion. Also changed the indentation. It's ready for review.🙂 |
CI has caught a failing test; please fix that. |
1835cba
to
a4c4cf7
Compare
Sorry, I just missed updating the test file earlier. It's done now. Thanks! |
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 update @shivanshsharma13! Left some comments. Also a commit message nit:
Lightbox: Added user's avatar in the lightbox app bar
to
lightbox: Added user's avatar in the lightbox app bar
For finding the right prefix, git log --oneline -- lib/widgets/lightbox.dart
is handy.
lib/widgets/lightbox.dart
Outdated
]) | ||
), | ||
), | ||
], | ||
), |
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: Looks like this change expands the parentheses into separate lines. We should fix this.
]) | |
), | |
), | |
], | |
), | |
]))), | |
]), |
lib/widgets/lightbox.dart
Outdated
], | ||
), | ||
bottom: widget.buildAppBarBottom(context) | ||
); |
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: same issue here
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.
bump (need to move the parenthesis)
prepareBoringImageHttpClient(); | ||
final timestamp = DateTime.parse("2024-07-23 23:12:24").millisecondsSinceEpoch ~/ 1000; | ||
final message = eg.streamMessage(sender: eg.otherUser, timestamp: timestamp); | ||
await setupPage(tester, message: message, thumbnailUrl: null); | ||
|
||
// We're looking for a RichText, in the app bar, with both the | ||
// sender's name and the timestamp. |
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 comment was specifically for explaining what RichText
was used for. Let's leave it as-is
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.
The comment belongs to the part started with final labelTextWidget
, so it should come before that and replace // Check sender name and timestamp
.
test/widgets/lightbox_test.dart
Outdated
// Check Avatar properties | ||
final avatar = tester.widget<Avatar>(find.byType(Avatar)); | ||
check(avatar.size).equals(36); | ||
check(avatar.borderRadius).equals(36 / 8); |
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.
The design properties like size
and borderRadius
are usually verified during reviews. We typically don't need test for these because it only captures a limited scope of bugs and becomes another place to update if the design spec 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.
Thank you for the review! Should I remove the test, or would you suggest modifying it in some way? Looking forward to your guidance! For now I just removed the test for size and border radius
a4c4cf7
to
afd311c
Compare
Thanks for the detailed review. I acknowledged the suggested changes. Please let me know if anything needs to be changed!🙂 |
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 update! Left some comments.
lib/widgets/lightbox.dart
Outdated
], | ||
), | ||
bottom: widget.buildAppBarBottom(context) | ||
); |
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.
bump (need to move the parenthesis)
prepareBoringImageHttpClient(); | ||
final timestamp = DateTime.parse("2024-07-23 23:12:24").millisecondsSinceEpoch ~/ 1000; | ||
final message = eg.streamMessage(sender: eg.otherUser, timestamp: timestamp); | ||
await setupPage(tester, message: message, thumbnailUrl: null); | ||
|
||
// We're looking for a RichText, in the app bar, with both the | ||
// sender's name and the timestamp. |
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.
The comment belongs to the part started with final labelTextWidget
, so it should come before that and replace // Check sender name and timestamp
.
afd311c
to
fd10604
Compare
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.
One more commit message nit:
lightbox: Added user's avatar in the lightbox app bar
See the commit style guide linked in our README: https://github.com/zulip/zulip-flutter?tab=readme-ov-file#submitting-a-pull-request
Commit summaries should be started with an imperative verb:
lightbox: Add user's avatar on the lightbox app bar
lib/widgets/lightbox.dart
Outdated
style: themeData.textTheme.titleSmall!.copyWith(color: appBarForegroundColor)), | ||
]))), | ||
]), | ||
bottom: widget.buildAppBarBottom(context)); |
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: Hmm, didn't notice this until now — bottom
is a parameter for AppBar
, so it should be at the same indent level as other parameters like title
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 sorry for overlooking it before. Thanks
This change updates the lightbox to display the message author's avatar alongside their name and the date in the app bar. The avatar is positioned in the "start" direction (left for LTR layouts, right for RTL layouts) to align with the behavior in the React Native app. Fixes: zulip#41
fd10604
to
e094f50
Compare
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 @shivanshsharma13, and thanks @chrisbobbe and @PIG208 for the previous reviews! Comments below.
// Check Avatar properties | ||
final avatar = tester.widget<Avatar>(find.byType(Avatar)); | ||
check(avatar.userId).equals(message.senderId); |
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.
Let's make this a new separate test case (a separate call to testWidgets
), rather than adding complexity to an existing test case.
That way the new test case doesn't need to worry about e.g. the timestamp of the message, and the existing test case doesn't get this added logic sitting in between things like the setup that prepares the timestamp's value, and the check that says how it should look. For the test to make sense, the reader needs to see those things together and compare them, so it's best to minimize unrelated things coming in between and separating them.
text: TextSpan( | ||
children: [ |
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: preserve formatting of code you're not changing
text: TextSpan( | |
children: [ | |
text: TextSpan(children: [ |
Avatar(size: 36, borderRadius: 36 / 8, userId: widget.message.senderId), | ||
const SizedBox(width: 8), | ||
Expanded( | ||
child: RichText( |
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.
Is there an updated screenshot of what the current version looks like? I see one at the top of the PR but I'm not sure it's up to date.
])), | ||
title: Row(children: [ | ||
Avatar(size: 36, borderRadius: 36 / 8, userId: widget.message.senderId), | ||
const SizedBox(width: 8), |
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.
From the screenshots in the thread, this 8px spacing looks kind of crowded to me. Is there a source in particular you took this value from?
What does it look like if it's 12px, or 16px?
// Make smaller, like a subtitle | ||
style: themeData.textTheme.titleSmall!.copyWith(color: appBarForegroundColor)), | ||
]))), | ||
]), |
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 close-bracket gets aligned with the start of the line the open-bracket is on. Same thing as for braces {}
and parens ()
.
// Check Avatar properties | ||
final avatar = tester.widget<Avatar>(find.byType(Avatar)); | ||
check(avatar.userId).equals(message.senderId); |
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.
// Check Avatar properties | |
final avatar = tester.widget<Avatar>(find.byType(Avatar)); | |
check(avatar.userId).equals(message.senderId); | |
final avatar = tester.widget<Avatar>(find.byType(Avatar)); | |
check(avatar.userId).equals(message.senderId); |
This comment doesn't say anything the code just under it doesn't already say just as clearly.
It's also wrong — this code checks only one property.
I believe this illustrates the classic way that comments tend to become wrong over time, which is that you edited the code (#1092 (comment)) and didn't update the comment. If that can happen when you yourself are editing the code, within the same PR where you wrote the comment in the first place, you can imagine it happens all the time when other people are updating the code months and years later.
The fact that comments routinely become wrong is a major reason to leave out comments except those that pull their weight by really adding something that's not easy to see by just looking at the code.
In the lightbox, the RN app shows the message author's avatar along with their name in the app bar. This change implements the same behavior in the Flutter app, positioning the avatar beside the name/date text in the "start" direction (left in LTR layouts, right in RTL layouts).
The changes:
Screenshot-
Fixes #41