Skip to content

Commit c1b1cbd

Browse files
committed
msglist: Add 36px space at bottom, to reinforce that end-of-feed is reached
As requested by Vlad (same link as in a code comment): https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680603 Fixes: zulip#400
1 parent 640caef commit c1b1cbd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/widgets/message_list.dart

+8-4
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
293293
final valueKey = key as ValueKey;
294294
final index = model!.findItemWithMessageId(valueKey.value);
295295
if (index == -1) return null;
296-
return length - 1 - (index - 1);
296+
return length - 1 - (index - 2);
297297
},
298298
controller: scrollController,
299-
itemCount: length + 1,
299+
itemCount: length + 2,
300300
// Setting reverse: true means the scroll starts at the bottom.
301301
// Flipping the indexes (in itemBuilder) means the start/bottom
302302
// has the latest messages.
@@ -305,9 +305,13 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
305305
// TODO on new message when scrolled up, anchor scroll to what's in view
306306
reverse: true,
307307
itemBuilder: (context, i) {
308-
if (i == 0) return MarkAsReadWidget(narrow: widget.narrow);
308+
// To reinforce that the end of the feed has been reached:
309+
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/flutter.3A.20Mark-as-read/near/1680603
310+
if (i == 0) return const SizedBox(height: 36);
309311

310-
final data = model!.items[length - 1 - (i - 1)];
312+
if (i == 1) return MarkAsReadWidget(narrow: widget.narrow);
313+
314+
final data = model!.items[length - 1 - (i - 2)];
311315
switch (data) {
312316
case MessageListHistoryStartItem():
313317
return const Center(

test/widgets/message_list_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void main() {
8181
testWidgets('basic', (tester) async {
8282
await setupMessageListPage(tester, foundOldest: false,
8383
messages: List.generate(200, (i) => eg.streamMessage(id: 950 + i, sender: eg.selfUser)));
84-
check(itemCount(tester)).equals(202);
84+
check(itemCount(tester)).equals(203);
8585

8686
// Fling-scroll upward...
8787
await tester.fling(find.byType(MessageListPage), const Offset(0, 300), 8000);
@@ -94,7 +94,7 @@ void main() {
9494
await tester.pump(Duration.zero); // Allow a frame for the response to arrive.
9595

9696
// Now we have more messages.
97-
check(itemCount(tester)).equals(302);
97+
check(itemCount(tester)).equals(303);
9898
});
9999

100100
testWidgets('observe double-fetch glitch', (tester) async {

0 commit comments

Comments
 (0)