From 5a1ebdb9d6d3eb70528f04accfe44b1de282fd5c Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Mon, 17 Jun 2024 15:07:06 -0700 Subject: [PATCH] content/msglist: Fix vertical position of horizontal scrollbar in codeblock Discussion of this solution: https://github.com/zulip/zulip-flutter/issues/736#issuecomment-2168952424 Fixes: #736 --- lib/widgets/message_list.dart | 8 +++++++- test/widgets/message_list_test.dart | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index ea8b65456e..c22dd6314f 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -301,7 +301,7 @@ class _MessageListState extends State with PerAccountStoreAwareStat final length = model!.items.length; const centerSliverKey = ValueKey('center sliver'); - final sliver = SliverStickyHeaderList( + Widget sliver = SliverStickyHeaderList( headerPlacement: HeaderPlacement.scrollingStart, delegate: SliverChildBuilderDelegate( // To preserve state across rebuilds for individual [MessageItem] @@ -337,6 +337,12 @@ class _MessageListState extends State with PerAccountStoreAwareStat return _buildItem(data, i); })); + if (widget.narrow is CombinedFeedNarrow) { + // TODO(#311) If we have a bottom nav, it will pad the bottom + // inset, and this shouldn't be necessary + sliver = SliverSafeArea(sliver: sliver); + } + return CustomScrollView( // TODO: Offer `ScrollViewKeyboardDismissBehavior.interactive` (or // similar) if that is ever offered: diff --git a/test/widgets/message_list_test.dart b/test/widgets/message_list_test.dart index aa7cd1fa3f..7f25cb10d4 100644 --- a/test/widgets/message_list_test.dart +++ b/test/widgets/message_list_test.dart @@ -86,6 +86,22 @@ void main() { return scrollView.controller; } + group('presents message content appropriately', () { + // regression test for https://github.com/zulip/zulip-flutter/issues/736 + testWidgets('content in "Combined feed" not asked to consume insets (including bottom)', (tester) async { + const fakePadding = FakeViewPadding(left: 10, top: 10, right: 10, bottom: 10); + tester.view.viewInsets = fakePadding; + tester.view.padding = fakePadding; + + await setupMessageListPage(tester, narrow: const CombinedFeedNarrow(), + messages: [eg.streamMessage(content: ContentExample.codeBlockPlain.html)]); + + final element = tester.element(find.byType(CodeBlock)); + final padding = MediaQuery.of(element).padding; + check(padding).equals(EdgeInsets.zero); + }); + }); + group('fetch older messages on scroll', () { int? itemCount(WidgetTester tester) => tester.widget(find.byType(CustomScrollView)).semanticChildCount;