add centerTitle and elevation to ChannelHeader

This commit is contained in:
S-ecki
2022-03-01 17:27:03 +01:00
parent f318b619ae
commit 0c28043365
@@ -61,9 +61,11 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
this.showConnectionStateTile = false, this.showConnectionStateTile = false,
this.title, this.title,
this.subtitle, this.subtitle,
this.centerTitle,
this.leading, this.leading,
this.actions, this.actions,
this.backgroundColor, this.backgroundColor,
this.elevation,
}) : preferredSize = const Size.fromHeight(kToolbarHeight), }) : preferredSize = const Size.fromHeight(kToolbarHeight),
super(key: key); super(key: key);
@@ -92,6 +94,9 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
/// Subtitle widget /// Subtitle widget
final Widget? subtitle; final Widget? subtitle;
// Whether the title should be centered
final bool? centerTitle;
/// Leading widget /// Leading widget
final Widget? leading; final Widget? leading;
@@ -102,6 +107,9 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
/// The background color for this [ChannelHeader]. /// The background color for this [ChannelHeader].
final Color? backgroundColor; final Color? backgroundColor;
/// The elevation for this [ChannelHeader].
final double? elevation;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final channel = StreamChannel.of(context).channel; final channel = StreamChannel.of(context).channel;
@@ -144,7 +152,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
systemOverlayStyle: theme.brightness == Brightness.dark systemOverlayStyle: theme.brightness == Brightness.dark
? SystemUiOverlayStyle.light ? SystemUiOverlayStyle.light
: SystemUiOverlayStyle.dark, : SystemUiOverlayStyle.dark,
elevation: 1, elevation: elevation ?? 1,
leading: leadingWidget, leading: leadingWidget,
backgroundColor: backgroundColor ?? channelHeaderTheme.color, backgroundColor: backgroundColor ?? channelHeaderTheme.color,
actions: actions ?? actions: actions ??
@@ -162,7 +170,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
), ),
), ),
], ],
centerTitle: true, centerTitle: centerTitle ?? true,
title: InkWell( title: InkWell(
onTap: onTitleTap, onTap: onTitleTap,
child: SizedBox( child: SizedBox(