From 9bb5e06c96c71205926dbe056f2e1a2d4284e0fb Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Wed, 6 May 2020 09:28:47 +0200 Subject: [PATCH] Refs #46: add background color as part of StreamChatThemeData --- lib/src/stream_chat.dart | 8 ++++---- lib/src/stream_chat_theme.dart | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/stream_chat.dart b/lib/src/stream_chat.dart index 258a308f..acd829ff 100644 --- a/lib/src/stream_chat.dart +++ b/lib/src/stream_chat.dart @@ -74,12 +74,11 @@ class StreamChatState extends State child: Builder( builder: (context) { final materialTheme = Theme.of(context); - final isDark = materialTheme.brightness == Brightness.dark; + final streamChatTheme = StreamChatTheme.of(context); return Theme( data: materialTheme.copyWith( - accentColor: StreamChatTheme.of(context).accentColor, - scaffoldBackgroundColor: isDark ? Colors.black : Colors.white, - backgroundColor: isDark ? Colors.black : Colors.white, + accentColor: streamChatTheme.accentColor, + scaffoldBackgroundColor: streamChatTheme.backgroundColor, ), child: WillPopScope( onWillPop: () async { @@ -116,6 +115,7 @@ class StreamChatState extends State primaryColor: themeData?.primaryColor, defaultChannelImage: themeData?.defaultChannelImage, defaultUserImage: themeData?.defaultUserImage, + backgroundColor: themeData?.backgroundColor, channelTheme: defaultTheme.channelTheme.copyWith( channelHeaderTheme: defaultTheme.channelTheme.channelHeaderTheme.copyWith( diff --git a/lib/src/stream_chat_theme.dart b/lib/src/stream_chat_theme.dart index 289f477d..ca574716 100644 --- a/lib/src/stream_chat_theme.dart +++ b/lib/src/stream_chat_theme.dart @@ -39,6 +39,9 @@ class StreamChatThemeData { /// Accent color of the chat widgets final Color accentColor; + /// Background color of the chat widgets + final Color backgroundColor; + /// Theme of the [ChannelPreview] final ChannelPreviewTheme channelPreviewTheme; @@ -62,6 +65,7 @@ class StreamChatThemeData { this.primaryColor, this.secondaryColor, this.accentColor, + this.backgroundColor, this.channelPreviewTheme, this.channelTheme, this.otherMessageTheme, @@ -78,6 +82,7 @@ class StreamChatThemeData { accentColor: theme.accentColor, primaryColor: theme.colorScheme.primary, secondaryColor: theme.colorScheme.secondary, + backgroundColor: theme.scaffoldBackgroundColor, channelTheme: ChannelTheme( inputGradient: LinearGradient(colors: [ theme.accentColor.withOpacity(.5), @@ -102,6 +107,7 @@ class StreamChatThemeData { Color primaryColor, Color secondaryColor, Color accentColor, + Color backgroundColor, ChannelPreviewTheme channelPreviewTheme, ChannelTheme channelTheme, MessageTheme ownMessageTheme, @@ -115,6 +121,7 @@ class StreamChatThemeData { accentColor: accentColor ?? this.accentColor, defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage, defaultUserImage: defaultUserImage ?? this.defaultUserImage, + backgroundColor: backgroundColor ?? this.backgroundColor, channelPreviewTheme: channelPreviewTheme?.copyWith( title: channelPreviewTheme.title ?? this.channelPreviewTheme.title, @@ -184,6 +191,7 @@ class StreamChatThemeData { accentColor: accentColor, primaryColor: isDark ? Colors.black : Colors.white, defaultChannelImage: (context, channel) => SizedBox(), + backgroundColor: isDark ? Colors.black : Colors.white, defaultUserImage: (context, user) => Center( child: Text( user.name?.substring(0, 1) ?? '',