fix(ui): fix centerTitle for ChannelHeader

This commit is contained in:
Salvatore Giordano
2022-04-27 10:44:43 +02:00
parent c553507cc8
commit cfad4bfc87
2 changed files with 27 additions and 1 deletions
@@ -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(