feat(ui): added backgroundColor property to the various header widgets

Also updated CHANGELOG.md
This commit is contained in:
groovinchip
2021-08-06 11:39:51 -04:00
parent 8585456edd
commit 91c0a7031a
5 changed files with 23 additions and 4 deletions
@@ -4,6 +4,7 @@
- [#516](https://github.com/GetStream/stream-chat-flutter/issues/516): Added `StreamChatThemeData.placeholderUserImage` for - [#516](https://github.com/GetStream/stream-chat-flutter/issues/516): Added `StreamChatThemeData.placeholderUserImage` for
building a widget when the `UserAvatar` image is loading building a widget when the `UserAvatar` image is loading
- Added a `backgroundColor` property to the various header widgets
🔄 Changed 🔄 Changed
@@ -67,6 +67,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
this.subtitle, this.subtitle,
this.leading, this.leading,
this.actions, this.actions,
this.backgroundColor,
}) : preferredSize = const Size.fromHeight(kToolbarHeight), }) : preferredSize = const Size.fromHeight(kToolbarHeight),
super(key: key); super(key: key);
@@ -102,6 +103,9 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
/// By default it shows the [ChannelAvatar] /// By default it shows the [ChannelAvatar]
final List<Widget>? actions; final List<Widget>? actions;
/// The background color for this [ChannelHeader].
final Color? backgroundColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final channel = StreamChannel.of(context).channel; final channel = StreamChannel.of(context).channel;
@@ -141,7 +145,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget {
brightness: Theme.of(context).brightness, brightness: Theme.of(context).brightness,
elevation: 1, elevation: 1,
leading: leadingWidget, leading: leadingWidget,
backgroundColor: channelHeaderTheme.color, backgroundColor: backgroundColor ?? channelHeaderTheme.color,
actions: actions ?? actions: actions ??
<Widget>[ <Widget>[
Padding( Padding(
@@ -61,6 +61,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
this.subtitle, this.subtitle,
this.leading, this.leading,
this.actions, this.actions,
this.backgroundColor,
}) : super(key: key); }) : super(key: key);
/// Pass this if you don't have a [StreamChatClient] in your widget tree. /// Pass this if you don't have a [StreamChatClient] in your widget tree.
@@ -93,6 +94,9 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
/// By default it shows the new chat button /// By default it shows the new chat button
final List<Widget>? actions; final List<Widget>? actions;
/// The background color for this [ChannelListHeader].
final Color? backgroundColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final _client = client ?? StreamChat.of(context).client; final _client = client ?? StreamChat.of(context).client;
@@ -124,7 +128,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
textTheme: Theme.of(context).textTheme, textTheme: Theme.of(context).textTheme,
brightness: Theme.of(context).brightness, brightness: Theme.of(context).brightness,
elevation: 1, elevation: 1,
backgroundColor: channelListHeaderThemeData.color, backgroundColor:
backgroundColor ?? channelListHeaderThemeData.color,
centerTitle: true, centerTitle: true,
leading: leading ?? leading: leading ??
Center( Center(
@@ -19,6 +19,7 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
this.onImageTap, this.onImageTap,
this.userName = '', this.userName = '',
this.sentAt = '', this.sentAt = '',
this.backgroundColor,
}) : preferredSize = const Size.fromHeight(kToolbarHeight), }) : preferredSize = const Size.fromHeight(kToolbarHeight),
super(key: key); super(key: key);
@@ -50,6 +51,9 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
/// Stores the current index of media shown /// Stores the current index of media shown
final int currentIndex; final int currentIndex;
/// The background color of this [GalleryHeader].
final Color? backgroundColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final galleryHeaderThemeData = GalleryHeaderTheme.of(context); final galleryHeaderThemeData = GalleryHeaderTheme.of(context);
@@ -66,7 +70,8 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
onPressed: onBackPressed, onPressed: onBackPressed,
) )
: const SizedBox(), : const SizedBox(),
backgroundColor: galleryHeaderThemeData.backgroundColor, backgroundColor:
backgroundColor ?? galleryHeaderThemeData.backgroundColor,
actions: <Widget>[ actions: <Widget>[
if (!message.isEphemeral) if (!message.isEphemeral)
IconButton( IconButton(
@@ -70,6 +70,7 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
this.actions, this.actions,
this.onTitleTap, this.onTitleTap,
this.showTypingIndicator = true, this.showTypingIndicator = true,
this.backgroundColor,
}) : preferredSize = const Size.fromHeight(kToolbarHeight), }) : preferredSize = const Size.fromHeight(kToolbarHeight),
super(key: key); super(key: key);
@@ -102,6 +103,9 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
/// if a user is typing in this thread /// if a user is typing in this thread
final bool showTypingIndicator; final bool showTypingIndicator;
/// The background color of this [ThreadHeader].
final Color? backgroundColor;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final channelHeaderTheme = ChannelHeaderTheme.of(context); final channelHeaderTheme = ChannelHeaderTheme.of(context);
@@ -136,7 +140,7 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
showUnreads: true, showUnreads: true,
) )
: const SizedBox()), : const SizedBox()),
backgroundColor: channelHeaderTheme.color, backgroundColor: backgroundColor ?? channelHeaderTheme.color,
centerTitle: true, centerTitle: true,
actions: actions, actions: actions,
title: InkWell( title: InkWell(