Skip to content

Commit debe99e

Browse files
gnpricechrisbobbe
authored andcommitted
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 618a75c commit debe99e

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
@@ -686,15 +686,9 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
686686
if (childIndex < 0) return null;
687687
return childIndex;
688688
},
689-
childCount: bottomItems + 3,
689+
childCount: bottomItems + 1,
690690
(context, childIndex) {
691-
// To reinforce that the end of the feed has been reached:
692-
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680603
693-
if (childIndex == bottomItems + 2) return const SizedBox(height: 36);
694-
695-
if (childIndex == bottomItems + 1) return MarkAsReadWidget(narrow: widget.narrow);
696-
697-
if (childIndex == bottomItems) return TypingStatusWidget(narrow: widget.narrow);
691+
if (childIndex == bottomItems) return _buildEndCap();
698692

699693
final itemIndex = topItems + childIndex;
700694
final data = model.items[itemIndex];
@@ -743,6 +737,16 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
743737
};
744738
}
745739

740+
Widget _buildEndCap() {
741+
return Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
742+
TypingStatusWidget(narrow: widget.narrow),
743+
MarkAsReadWidget(narrow: widget.narrow),
744+
// To reinforce that the end of the feed has been reached:
745+
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680603
746+
const SizedBox(height: 36),
747+
]);
748+
}
749+
746750
Widget _buildItem(MessageListItem data) {
747751
switch (data) {
748752
case MessageListRecipientHeaderItem():

0 commit comments

Comments
 (0)