@@ -262,6 +262,8 @@ class _MessageListPageState extends State<MessageListPage> implements MessageLis
262
262
263
263
List <Widget >? actions;
264
264
if (narrow case TopicNarrow (: final streamId)) {
265
+ // The helper [_getEffectiveCenterTitle] relies on the fact that we
266
+ // have at most one action here.
265
267
(actions ?? = []).add (IconButton (
266
268
icon: const Icon (ZulipIcons .message_feed),
267
269
tooltip: zulipLocalizations.channelFeedButtonTooltip,
@@ -314,7 +316,6 @@ class MessageListAppBarTitle extends StatelessWidget {
314
316
315
317
Widget _buildStreamRow (BuildContext context, {
316
318
ZulipStream ? stream,
317
- required String text,
318
319
}) {
319
320
// A null [Icon.icon] makes a blank space.
320
321
final icon = (stream != null ) ? iconDataForStream (stream) : null ;
@@ -327,10 +328,42 @@ class MessageListAppBarTitle extends StatelessWidget {
327
328
children: [
328
329
Icon (size: 16 , icon),
329
330
const SizedBox (width: 4 ),
330
- Flexible (child: Text (text )),
331
+ Flexible (child: Text (stream ? .name ?? '(unknown stream)' )),
331
332
]);
332
333
}
333
334
335
+ Widget _buildTopicRow (BuildContext context, {
336
+ required ZulipStream ? stream,
337
+ required String topic,
338
+ }) {
339
+ return Text (topic, style: const TextStyle (
340
+ fontSize: 13 ,
341
+ ).merge (weightVariableTextStyle (context)));
342
+ }
343
+
344
+ // TODO(upstream): provide an API for this
345
+ // Adapted from [AppBar._getEffectiveCenterTitle].
346
+ bool _getEffectiveCenterTitle (ThemeData theme) {
347
+ bool platformCenter () {
348
+ switch (theme.platform) {
349
+ case TargetPlatform .android:
350
+ case TargetPlatform .fuchsia:
351
+ case TargetPlatform .linux:
352
+ case TargetPlatform .windows:
353
+ return false ;
354
+ case TargetPlatform .iOS:
355
+ case TargetPlatform .macOS:
356
+ // We rely on the fact that there is at most one action
357
+ // on the message list app bar, so that the expression returned
358
+ // in the original helper, `actions == null || actions!.length < 2`,
359
+ // always evaluates to `true`:
360
+ return true ;
361
+ }
362
+ }
363
+
364
+ return theme.appBarTheme.centerTitle ?? platformCenter ();
365
+ }
366
+
334
367
@override
335
368
Widget build (BuildContext context) {
336
369
final zulipLocalizations = ZulipLocalizations .of (context);
@@ -348,14 +381,20 @@ class MessageListAppBarTitle extends StatelessWidget {
348
381
case ChannelNarrow (: var streamId):
349
382
final store = PerAccountStoreWidget .of (context);
350
383
final stream = store.streams[streamId];
351
- final streamName = stream? .name ?? '(unknown channel)' ;
352
- return _buildStreamRow (context, stream: stream, text: streamName);
384
+ return _buildStreamRow (context, stream: stream);
353
385
354
386
case TopicNarrow (: var streamId, : var topic):
387
+ final theme = Theme .of (context);
355
388
final store = PerAccountStoreWidget .of (context);
356
389
final stream = store.streams[streamId];
357
- final streamName = stream? .name ?? '(unknown channel)' ;
358
- return _buildStreamRow (context, stream: stream, text: "$streamName > $topic " );
390
+ final centerTitle = _getEffectiveCenterTitle (theme);
391
+ return Column (
392
+ crossAxisAlignment: centerTitle ? CrossAxisAlignment .center
393
+ : CrossAxisAlignment .start,
394
+ children: [
395
+ _buildStreamRow (context, stream: stream),
396
+ _buildTopicRow (context, stream: stream, topic: topic),
397
+ ]);
359
398
360
399
case DmNarrow (: var otherRecipientIds):
361
400
final store = PerAccountStoreWidget .of (context);
0 commit comments