Skip to content

Commit 5b8c5c0

Browse files
committed
msglist [nfc]: Build end-of-feed widgets in a helper method
This will give us a natural home for logic that makes these depend on whether we have the newest messages, once that becomes something that varies.
1 parent c9ebf4c commit 5b8c5c0

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/widgets/message_list.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,9 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
645645
if (childIndex < 0) return null;
646646
return childIndex;
647647
},
648-
childCount: bottomItems + 3,
648+
childCount: bottomItems + 1,
649649
(context, childIndex) {
650-
// To reinforce that the end of the feed has been reached:
651-
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680603
652-
if (childIndex == bottomItems + 2) return const SizedBox(height: 36);
653-
654-
if (childIndex == bottomItems + 1) return MarkAsReadWidget(narrow: widget.narrow);
655-
656-
if (childIndex == bottomItems) return TypingStatusWidget(narrow: widget.narrow);
650+
if (childIndex == bottomItems) return _buildEndCap();
657651

658652
final itemIndex = topItems + childIndex;
659653
final data = model.items[itemIndex];
@@ -702,6 +696,16 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
702696
};
703697
}
704698

699+
Widget _buildEndCap() {
700+
return Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
701+
TypingStatusWidget(narrow: widget.narrow),
702+
MarkAsReadWidget(narrow: widget.narrow),
703+
// To reinforce that the end of the feed has been reached:
704+
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680603
705+
const SizedBox(height: 36),
706+
]);
707+
}
708+
705709
Widget _buildItem(MessageListItem data) {
706710
switch (data) {
707711
case MessageListRecipientHeaderItem():

0 commit comments

Comments
 (0)