-
Notifications
You must be signed in to change notification settings - Fork 325
Decrease whitespace at end of message feed #1628
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
15b7af9
to
ae80e4f
Compare
Updated, this time decreasing the 11px to 5px instead of making it zero. I've kept the screenshots from the previous revision, though, and added ones from this revision. PTAL! |
5px seems like a fine adjustment to me. |
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 taking care of this! Comments below.
lib/model/message_list.dart
Outdated
|| oneMessagePerBlock | ||
|| !haveSameRecipient(prevMessage, message) | ||
) { | ||
if (prevMessage == null) { | ||
items.add(MessageListRecipientHeaderItem(message)); | ||
canShareSender = false; | ||
} else { | ||
assert(items.last is MessageListMessageBaseItem); |
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.
msglist [nfc]: Pull out some asserts that also apply when haveSameRecipient
These invariants apply regardless of `haveSameRecipient`.
That also apply when not haveSameRecipient, right?
(The case where they were previously being asserted is one where haveSameRecipient is always true.)
lib/widgets/message_list.dart
Outdated
if (item.isLastInBlock && !item.isLastInFeed) | ||
const SizedBox(height: 11) | ||
else if (item.isLastInFeed) | ||
const SizedBox(height: 5), |
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: can swap these cases to simplify one of the conditions
lib/model/message_list.dart
Outdated
|
||
if (!messagesSameDay(prevMessageItem.message, message)) { | ||
items.add(MessageListDateSeparatorItem(message)); | ||
prevMessageItem.isLastInFeed = false; |
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'd rather avoid making this _addItemsForMessage method more complicated if we can help it — it has a complicated job already as it is.
The question "is this the last item in the feed" seems like it can be answered easily within the MessageList widget, by looking at the index in the list. After all, the invariant says:
..isLastInFeed.equals(i == model.items.length);
(where i
is the index after the item in question).
So instead how about:
- MessageItem gains a boolean field isLastInFeed.
- _buildItem gains a matching parameter.
- Its two call sites compare
itemIndex
tototalItems
to determine that parameter.
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.
Sure, that's reasonable; I've done this in my new revision.
It puts a bit more of the work in widget code, which doesn't have tests for this new padding logic; would that be a blocker to merging?
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, ideally there'd be a widget test or two for this. (I guess in particular one for the usual case, and one for the case where the bottom sliver is empty but the top is nonempty, checking effectively that that first _buildItem
call site is doing the right thing.)
If that isn't quick to write, though, it's not a blocker for merging.
See discussion linked in the comment.
ae80e4f
to
9ee0db2
Compare
Thanks! Revision pushed. I've left in the two NFC commits because they seemed potentially helpful, but are now orthogonal to the interesting changes here: 359b99a msglist [nfc]: Make a common codepath for prevMessage != null Happy to remove or revise though if helpful. |
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 revision! Just small comments.
lib/widgets/message_list.dart
Outdated
narrow: widget.narrow, | ||
header: header, | ||
item: data); | ||
item: data, | ||
isLastInFeed: isLastInFeed); |
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: metadata before payload / child
-like argument (so here, isLastInFeed before header and item)
lib/model/message_list.dart
Outdated
|
||
if (!messagesSameDay(prevMessageItem.message, message)) { | ||
items.add(MessageListDateSeparatorItem(message)); | ||
prevMessageItem.isLastInFeed = false; |
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, ideally there'd be a widget test or two for this. (I guess in particular one for the usual case, and one for the case where the bottom sliver is empty but the top is nonempty, checking effectively that that first _buildItem
call site is doing the right thing.)
If that isn't quick to write, though, it's not a blocker for merging.
lib/model/message_list.dart
Outdated
final prevMessageItem = items.last as MessageListMessageBaseItem; | ||
assert(identical(prevMessageItem.message, prevMessage)); | ||
assert(prevMessageItem.isLastInBlock); | ||
prevMessageItem.isLastInBlock = false; | ||
assert(prevMessageItem.isLastInBlock); // though this may mutate; see below | ||
|
||
if (!messagesSameDay(prevMessageItem.message, message)) { | ||
items.add(MessageListDateSeparatorItem(message)); | ||
if (oneMessagePerBlock || !haveSameRecipient(prevMessage, message)) { | ||
items.add(MessageListRecipientHeaderItem(message)); | ||
canShareSender = false; | ||
} else { | ||
canShareSender = prevMessageItem.message.senderId == message.senderId; | ||
prevMessageItem.isLastInBlock = false; |
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, I think the refactors in the middle two commits are no longer helpful. The assertions are really there to support the prevMessageItem
local, and then the last one is for checking the precondition of the assignment right after it:
assert(prevMessageItem.isLastInBlock);
prevMessageItem.isLastInBlock = false;
So separating them from that line, and from the uses of prevMessageItem
in general, isn't an improvement.
9ee0db2
to
47ae5e3
Compare
Thanks! Revision pushed. |
Thanks! Merged. |
This does two things:
Proposed by Tim in chat:
#mobile > space at end of thread @ 💬
Screenshots coming soon.