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