Skip to content

Commit 91b9335

Browse files
recent dms [nfc]: Handle bottom insets explicitly in recent DMs page
This reverts part of 742320c for RecentDmConversationsPageBody, and also handles bottom insets for the new DMs button. As this widget is planned to be used outside the context of home page, specifically for the upcoming share page.
1 parent 37f71c6 commit 91b9335

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

lib/widgets/recent_dm_conversations.dart

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class _RecentDmConversationsPageBodyState extends State<RecentDmConversationsPag
9191
final zulipLocalizations = ZulipLocalizations.of(context);
9292
final sorted = model!.sorted;
9393

94+
// This value will be zero when this page is used in the context of
95+
// home-page, see comment on `bottom: false` arg in use of `SafeArea`
96+
// below.
97+
final bottomInsets = MediaQuery.paddingOf(context).bottom;
98+
9499
return Stack(
95100
alignment: Alignment.bottomCenter,
96101
clipBehavior: Clip.none,
@@ -99,9 +104,21 @@ class _RecentDmConversationsPageBodyState extends State<RecentDmConversationsPag
99104
PageBodyEmptyContentPlaceholder(
100105
message: zulipLocalizations.recentDmConversationsEmptyPlaceholder)
101106
else
102-
SafeArea( // horizontal insets
107+
SafeArea(
108+
// Don't pad the bottom here; we want the list content to do that.
109+
//
110+
// When this page is used in the context of the home page, this
111+
// param and the below use of `MediaQuery.paddingOf(context).bottom`
112+
// via `bottomInsets` would be noop, because
113+
// `Scaffold.bottomNavigationBar` in the home page handles that for
114+
// us. But this page is planned to be used for share-to-zulip page,
115+
// so we need this to be handled here.
116+
//
117+
// Other *PageBody widgets don't handle this because they aren't
118+
// planned to be (re-)used outside the context of the home page.
119+
bottom: false,
103120
child: ListView.builder(
104-
padding: EdgeInsets.only(bottom: 90),
121+
padding: EdgeInsets.only(bottom: bottomInsets + 90),
105122
itemCount: sorted.length,
106123
itemBuilder: (context, index) {
107124
final narrow = sorted[index];
@@ -125,7 +142,7 @@ class _RecentDmConversationsPageBodyState extends State<RecentDmConversationsPag
125142
onDmSelect: _handleDmSelect);
126143
})),
127144
Positioned(
128-
bottom: 21,
145+
bottom: bottomInsets + 21,
129146
child: _NewDmButton(onDmSelect: _handleDmSelectForNewDms)),
130147
]);
131148
}

0 commit comments

Comments
 (0)