add default user image to theme
This commit is contained in:
@@ -28,13 +28,6 @@ class MyApp extends StatelessWidget {
|
|||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
home: Container(
|
home: Container(
|
||||||
child: StreamChat(
|
child: StreamChat(
|
||||||
streamChatThemeData: StreamChatThemeData(
|
|
||||||
defaultChannelImage: (context, channel) {
|
|
||||||
return Center(
|
|
||||||
child: Text('AAA'),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
client: client,
|
client: client,
|
||||||
child: ChannelListPage(),
|
child: ChannelListPage(),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ class StreamChatState extends State<StreamChat>
|
|||||||
final theme = defaultTheme.copyWith(
|
final theme = defaultTheme.copyWith(
|
||||||
primaryColor: themeData?.primaryColor,
|
primaryColor: themeData?.primaryColor,
|
||||||
defaultChannelImage: themeData?.defaultChannelImage,
|
defaultChannelImage: themeData?.defaultChannelImage,
|
||||||
|
defaultUserImage: themeData?.defaultUserImage,
|
||||||
channelTheme: defaultTheme.channelTheme.copyWith(
|
channelTheme: defaultTheme.channelTheme.copyWith(
|
||||||
channelHeaderTheme:
|
channelHeaderTheme:
|
||||||
defaultTheme.channelTheme.channelHeaderTheme.copyWith(
|
defaultTheme.channelTheme.channelHeaderTheme.copyWith(
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ class StreamChatThemeData {
|
|||||||
/// The widget that will be built when the channel image is unavailable
|
/// The widget that will be built when the channel image is unavailable
|
||||||
final Widget Function(BuildContext, Channel) defaultChannelImage;
|
final Widget Function(BuildContext, Channel) defaultChannelImage;
|
||||||
|
|
||||||
|
/// The widget that will be built when the user image is unavailable
|
||||||
|
final Widget Function(BuildContext, User) defaultUserImage;
|
||||||
|
|
||||||
/// Create a theme from scratch
|
/// Create a theme from scratch
|
||||||
StreamChatThemeData({
|
StreamChatThemeData({
|
||||||
this.primaryColor,
|
this.primaryColor,
|
||||||
@@ -64,6 +67,7 @@ class StreamChatThemeData {
|
|||||||
this.otherMessageTheme,
|
this.otherMessageTheme,
|
||||||
this.ownMessageTheme,
|
this.ownMessageTheme,
|
||||||
this.defaultChannelImage,
|
this.defaultChannelImage,
|
||||||
|
this.defaultUserImage,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Create a theme from a Material [Theme]
|
/// Create a theme from a Material [Theme]
|
||||||
@@ -103,12 +107,14 @@ class StreamChatThemeData {
|
|||||||
MessageTheme ownMessageTheme,
|
MessageTheme ownMessageTheme,
|
||||||
MessageTheme otherMessageTheme,
|
MessageTheme otherMessageTheme,
|
||||||
Widget Function(BuildContext, Channel) defaultChannelImage,
|
Widget Function(BuildContext, Channel) defaultChannelImage,
|
||||||
|
Widget Function(BuildContext, User) defaultUserImage,
|
||||||
}) =>
|
}) =>
|
||||||
StreamChatThemeData(
|
StreamChatThemeData(
|
||||||
primaryColor: primaryColor ?? this.primaryColor,
|
primaryColor: primaryColor ?? this.primaryColor,
|
||||||
secondaryColor: secondaryColor ?? this.secondaryColor,
|
secondaryColor: secondaryColor ?? this.secondaryColor,
|
||||||
accentColor: accentColor ?? this.accentColor,
|
accentColor: accentColor ?? this.accentColor,
|
||||||
defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage,
|
defaultChannelImage: defaultChannelImage ?? this.defaultChannelImage,
|
||||||
|
defaultUserImage: defaultUserImage ?? this.defaultUserImage,
|
||||||
channelPreviewTheme: channelPreviewTheme?.copyWith(
|
channelPreviewTheme: channelPreviewTheme?.copyWith(
|
||||||
title:
|
title:
|
||||||
channelPreviewTheme.title ?? this.channelPreviewTheme.title,
|
channelPreviewTheme.title ?? this.channelPreviewTheme.title,
|
||||||
@@ -178,6 +184,12 @@ 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(),
|
||||||
|
defaultUserImage: (context, user) => Center(
|
||||||
|
child: Text(
|
||||||
|
user.name?.substring(0, 1) ?? '',
|
||||||
|
style: TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
channelPreviewTheme: ChannelPreviewTheme(
|
channelPreviewTheme: ChannelPreviewTheme(
|
||||||
avatarTheme: AvatarTheme(
|
avatarTheme: AvatarTheme(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class UserAvatar extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
)
|
)
|
||||||
: SizedBox(),
|
: StreamChatTheme.of(context).defaultUserImage(context, user),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user