Refs #46: add background color as part of StreamChatThemeData

This commit is contained in:
Salvatore Giordano
2020-05-06 09:28:47 +02:00
parent f44a025d05
commit 9bb5e06c96
2 changed files with 12 additions and 4 deletions
+4 -4
View File
@@ -74,12 +74,11 @@ class StreamChatState extends State<StreamChat>
child: Builder( child: Builder(
builder: (context) { builder: (context) {
final materialTheme = Theme.of(context); final materialTheme = Theme.of(context);
final isDark = materialTheme.brightness == Brightness.dark; final streamChatTheme = StreamChatTheme.of(context);
return Theme( return Theme(
data: materialTheme.copyWith( data: materialTheme.copyWith(
accentColor: StreamChatTheme.of(context).accentColor, accentColor: streamChatTheme.accentColor,
scaffoldBackgroundColor: isDark ? Colors.black : Colors.white, scaffoldBackgroundColor: streamChatTheme.backgroundColor,
backgroundColor: isDark ? Colors.black : Colors.white,
), ),
child: WillPopScope( child: WillPopScope(
onWillPop: () async { onWillPop: () async {
@@ -116,6 +115,7 @@ class StreamChatState extends State<StreamChat>
primaryColor: themeData?.primaryColor, primaryColor: themeData?.primaryColor,
defaultChannelImage: themeData?.defaultChannelImage, defaultChannelImage: themeData?.defaultChannelImage,
defaultUserImage: themeData?.defaultUserImage, defaultUserImage: themeData?.defaultUserImage,
backgroundColor: themeData?.backgroundColor,
channelTheme: defaultTheme.channelTheme.copyWith( channelTheme: defaultTheme.channelTheme.copyWith(
channelHeaderTheme: channelHeaderTheme:
defaultTheme.channelTheme.channelHeaderTheme.copyWith( defaultTheme.channelTheme.channelHeaderTheme.copyWith(
+8
View File
@@ -39,6 +39,9 @@ class StreamChatThemeData {
/// Accent color of the chat widgets /// Accent color of the chat widgets
final Color accentColor; final Color accentColor;
/// Background color of the chat widgets
final Color backgroundColor;
/// Theme of the [ChannelPreview] /// Theme of the [ChannelPreview]
final ChannelPreviewTheme channelPreviewTheme; final ChannelPreviewTheme channelPreviewTheme;
@@ -62,6 +65,7 @@ class StreamChatThemeData {
this.primaryColor, this.primaryColor,
this.secondaryColor, this.secondaryColor,
this.accentColor, this.accentColor,
this.backgroundColor,
this.channelPreviewTheme, this.channelPreviewTheme,
this.channelTheme, this.channelTheme,
this.otherMessageTheme, this.otherMessageTheme,
@@ -78,6 +82,7 @@ class StreamChatThemeData {
accentColor: theme.accentColor, accentColor: theme.accentColor,
primaryColor: theme.colorScheme.primary, primaryColor: theme.colorScheme.primary,
secondaryColor: theme.colorScheme.secondary, secondaryColor: theme.colorScheme.secondary,
backgroundColor: theme.scaffoldBackgroundColor,
channelTheme: ChannelTheme( channelTheme: ChannelTheme(
inputGradient: LinearGradient(colors: [ inputGradient: LinearGradient(colors: [
theme.accentColor.withOpacity(.5), theme.accentColor.withOpacity(.5),
@@ -102,6 +107,7 @@ class StreamChatThemeData {
Color primaryColor, Color primaryColor,
Color secondaryColor, Color secondaryColor,
Color accentColor, Color accentColor,
Color backgroundColor,
ChannelPreviewTheme channelPreviewTheme, ChannelPreviewTheme channelPreviewTheme,
ChannelTheme channelTheme, ChannelTheme channelTheme,
MessageTheme ownMessageTheme, MessageTheme ownMessageTheme,
@@ -115,6 +121,7 @@ class StreamChatThemeData {
accentColor: accentColor ?? this.accentColor, accentColor: accentColor ?? this.accentColor,
defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage, defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage,
defaultUserImage: defaultUserImage ?? this.defaultUserImage, defaultUserImage: defaultUserImage ?? this.defaultUserImage,
backgroundColor: backgroundColor ?? this.backgroundColor,
channelPreviewTheme: channelPreviewTheme?.copyWith( channelPreviewTheme: channelPreviewTheme?.copyWith(
title: title:
channelPreviewTheme.title ?? this.channelPreviewTheme.title, channelPreviewTheme.title ?? this.channelPreviewTheme.title,
@@ -184,6 +191,7 @@ class StreamChatThemeData {
accentColor: accentColor, accentColor: accentColor,
primaryColor: isDark ? Colors.black : Colors.white, primaryColor: isDark ? Colors.black : Colors.white,
defaultChannelImage: (context, channel) => SizedBox(), defaultChannelImage: (context, channel) => SizedBox(),
backgroundColor: isDark ? Colors.black : Colors.white,
defaultUserImage: (context, user) => Center( defaultUserImage: (context, user) => Center(
child: Text( child: Text(
user.name?.substring(0, 1) ?? '', user.name?.substring(0, 1) ?? '',