fix(ui): fix centerTitle for ChannelHeader
This commit is contained in:
@@ -112,6 +112,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final effectiveCenterTitle = _getEffectiveCenterTitle(Theme.of(context));
|
||||
final channel = StreamChannel.of(context).channel;
|
||||
final channelHeaderTheme = ChannelHeaderTheme.of(context);
|
||||
|
||||
@@ -175,9 +176,11 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||
onTap: onTitleTap,
|
||||
child: SizedBox(
|
||||
height: preferredSize.height,
|
||||
width: preferredSize.width,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: effectiveCenterTitle
|
||||
? CrossAxisAlignment.center
|
||||
: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
title ??
|
||||
ChannelName(
|
||||
@@ -202,4 +205,21 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
|
||||
|
||||
@override
|
||||
final Size preferredSize;
|
||||
|
||||
bool _getEffectiveCenterTitle(ThemeData theme) {
|
||||
if (centerTitle != null) return centerTitle!;
|
||||
if (theme.appBarTheme.centerTitle != null) {
|
||||
return theme.appBarTheme.centerTitle!;
|
||||
}
|
||||
switch (theme.platform) {
|
||||
case TargetPlatform.android:
|
||||
case TargetPlatform.fuchsia:
|
||||
case TargetPlatform.linux:
|
||||
case TargetPlatform.windows:
|
||||
return false;
|
||||
case TargetPlatform.iOS:
|
||||
case TargetPlatform.macOS:
|
||||
return actions == null || actions!.length < 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,12 @@ class TypingIndicator extends StatelessWidget {
|
||||
.where((element) => element.value.parentId == parentId)
|
||||
.map((e) => e.key)),
|
||||
builder: (context, data) => AnimatedSwitcher(
|
||||
layoutBuilder: (currentChild, previousChildren) => Stack(
|
||||
children: <Widget>[
|
||||
...previousChildren,
|
||||
if (currentChild != null) currentChild,
|
||||
],
|
||||
),
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: data.isNotEmpty
|
||||
? Padding(
|
||||
|
||||
Reference in New Issue
Block a user