Skip to content

Commit f53763a

Browse files
chrisbobbegnprice
authored andcommitted
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 need to handle the horizontal device insets in different 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 79ada37 commit f53763a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/widgets/compose_box.dart

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

10881088
// TODO(design): Maybe put a max width on the compose box, like we do on
1089-
// the message list itself
1089+
// the message list itself; if so, remember to update ComposeBox's dartdoc.
10901090
return Container(width: double.infinity,
10911091
decoration: BoxDecoration(
10921092
border: Border(top: BorderSide(color: designVariables.borderBar))),
@@ -1275,6 +1275,9 @@ class _ErrorBanner extends StatelessWidget {
12751275
}
12761276
}
12771277

1278+
/// The compose box.
1279+
///
1280+
/// Takes the full screen width, covering the horizontal insets with its surface.
12781281
class ComposeBox extends StatefulWidget {
12791282
ComposeBox({super.key, required this.narrow})
12801283
: assert(ComposeBox.hasComposeBox(narrow));

lib/widgets/message_list.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,10 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
294294
// we matched to the Figma in 21dbae120. See another frame, which uses that:
295295
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=147%3A9088&mode=dev
296296
body: Builder(
297-
builder: (BuildContext context) => Center(
298-
child: Column(children: [
297+
builder: (BuildContext context) => Column(
298+
// Children are expected to take the full horizontal space
299+
// and handle the horizontal device insets.
300+
children: [
299301
MediaQuery.removePadding(
300302
// Scaffold knows about the app bar, and so has run this
301303
// BuildContext, which is under `body`, through
@@ -315,7 +317,7 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
315317
))),
316318
if (ComposeBox.hasComposeBox(narrow))
317319
ComposeBox(key: _composeBoxKey, narrow: narrow)
318-
]))));
320+
])));
319321
}
320322
}
321323

@@ -432,6 +434,10 @@ const _kShortMessageHeight = 80;
432434
// previous batch.
433435
const kFetchMessagesBufferPixels = (kMessageListFetchBatchSize / 2) * _kShortMessageHeight;
434436

437+
/// The message list.
438+
///
439+
/// Takes the full screen width, keeping its contents
440+
/// out of the horizontal insets with transparent [SafeArea] padding.
435441
class MessageList extends StatefulWidget {
436442
const MessageList({super.key, required this.narrow, required this.onNarrowChanged});
437443

@@ -531,6 +537,8 @@ class _MessageListState extends State<MessageList> with PerAccountStoreAwareStat
531537
// will have a `MediaQuery.removePadding` with `removeBottom: true`.
532538
bottom: false,
533539

540+
// Horizontally, on wide screens, this Center grows the SafeArea
541+
// to position its padding over the device insets and centers content.
534542
child: Center(
535543
child: ConstrainedBox(
536544
constraints: const BoxConstraints(maxWidth: 760),

0 commit comments

Comments
 (0)