Skip to content

Commit 75b8e35

Browse files
committed
msglist [nfc]: Remove no-op Center widget in _MessageListPageState
The Center's child is a Column with the message list and possibly a compose box. Since the Column has the default MainAxisSize.max, it occupies all available vertical space, so the Center is a no-op on the vertical axis. (If an element occupies all available space on an axis, it has only one possible position on that axis, so the Center can't affect its position.) It turns out that the Column always takes all horizontal space, too; the message-list and compose-box widgets both stretch to the full screen width. This is appropriate because they want to handle the horizontal device insets in separate ways: the former by keeping visible UI outside the insets; the latter by filling the insets with padding. So the Center is a no-op in the horizontal direction, too. It's a relic from the very early prototype in late 2022 (see commit b22ef67); remove it. Also, with some new comments and dartdoc, make it clearer that the Column takes the full screen width.
1 parent 5e8d0a8 commit 75b8e35

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/widgets/compose_box.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ class _ComposeBoxContainer extends StatelessWidget {
10531053
};
10541054

10551055
// TODO(design): Maybe put a max width on the compose box, like we do on
1056-
// the message list itself
1056+
// the message list itself; if so, remember to update ComposeBox's dartdoc.
10571057
return Container(width: double.infinity,
10581058
decoration: BoxDecoration(
10591059
border: Border(top: BorderSide(color: designVariables.borderBar))),
@@ -1242,6 +1242,9 @@ class _ErrorBanner extends StatelessWidget {
12421242
}
12431243
}
12441244

1245+
/// The compose box.
1246+
///
1247+
/// Takes the full screen width, covering the horizontal insets with its surface.
12451248
class ComposeBox extends StatefulWidget {
12461249
ComposeBox({super.key, required this.narrow})
12471250
: assert(ComposeBox.hasComposeBox(narrow));

lib/widgets/message_list.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,10 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
288288
// we matched to the Figma in 21dbae120. See another frame, which uses that:
289289
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=147%3A9088&mode=dev
290290
body: Builder(
291-
builder: (BuildContext context) => Center(
292-
child: Column(children: [
291+
builder: (BuildContext context) => Column(
292+
// Children are expected to take the full horizontal space
293+
// and handle the horizontal device insets.
294+
children: [
293295
MediaQuery.removePadding(
294296
// Scaffold knows about the app bar, and so has run this
295297
// BuildContext, which is under `body`, through
@@ -305,7 +307,7 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
305307
child: MessageList(narrow: narrow, onNarrowChanged: _narrowChanged))),
306308
if (ComposeBox.hasComposeBox(narrow))
307309
ComposeBox(key: _composeBoxKey, narrow: narrow)
308-
]))));
310+
])));
309311
}
310312
}
311313

@@ -442,6 +444,11 @@ const _kShortMessageHeight = 80;
442444
// previous batch.
443445
const kFetchMessagesBufferPixels = (kMessageListFetchBatchSize / 2) * _kShortMessageHeight;
444446

447+
/// The message list.
448+
///
449+
/// Takes the full screen width,
450+
/// keeping the message list and scroll-to-bottom button
451+
/// out of the horizontal insets with transparent [SafeArea] padding.
445452
class MessageList extends StatefulWidget {
446453
const MessageList({super.key, required this.narrow, required this.onNarrowChanged});
447454

@@ -541,6 +548,8 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
541548
// will have a `MediaQuery.removePadding` with `removeBottom: true`.
542549
bottom: false,
543550

551+
// Horizontally, on wide screens, this grows the SafeArea
552+
// to position its padding over the device insets and centers content.
544553
child: Center(
545554
child: ConstrainedBox(
546555
constraints: const BoxConstraints(maxWidth: 760),

0 commit comments

Comments
 (0)