use random pngs
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
import 'package:stream_chat_flutter/src/channel_header.dart';
|
||||
@@ -5,6 +6,7 @@ import 'package:stream_chat_flutter/src/channel_preview.dart';
|
||||
import 'package:stream_chat_flutter/src/message_input.dart';
|
||||
import 'package:stream_chat_flutter/src/reaction_icon.dart';
|
||||
import 'package:stream_chat_flutter/src/stream_icons.dart';
|
||||
import 'package:stream_chat_flutter/src/utils.dart';
|
||||
|
||||
/// Inherited widget providing the [StreamChatThemeData] to the widget tree
|
||||
class StreamChatTheme extends InheritedWidget {
|
||||
@@ -226,9 +228,9 @@ class StreamChatThemeData {
|
||||
defaultChannelImage: (context, channel) => SizedBox(),
|
||||
backgroundColor: isDark ? Colors.black : Colors.white,
|
||||
defaultUserImage: (context, user) => Center(
|
||||
child: Text(
|
||||
user.name?.substring(0, 1) ?? '',
|
||||
style: TextStyle(color: Colors.white),
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: getRandomPicUrl(user),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
channelPreviewTheme: ChannelPreviewTheme(
|
||||
|
||||
@@ -27,6 +27,7 @@ class UserAvatar extends StatelessWidget {
|
||||
final hasImage = user.extraData?.containsKey('image') == true &&
|
||||
user.extraData['image'] != null &&
|
||||
user.extraData['image'] != '';
|
||||
final streamChatTheme = StreamChatTheme.of(context);
|
||||
return GestureDetector(
|
||||
onTap: onTap != null
|
||||
? () {
|
||||
@@ -39,36 +40,22 @@ class UserAvatar extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
ClipRRect(
|
||||
borderRadius: borderRadius ??
|
||||
StreamChatTheme.of(context)
|
||||
.ownMessageTheme
|
||||
.avatarTheme
|
||||
.borderRadius,
|
||||
streamChatTheme.ownMessageTheme.avatarTheme.borderRadius,
|
||||
child: Container(
|
||||
constraints: constraints ??
|
||||
StreamChatTheme.of(context)
|
||||
.ownMessageTheme
|
||||
.avatarTheme
|
||||
.constraints,
|
||||
streamChatTheme.ownMessageTheme.avatarTheme.constraints,
|
||||
decoration: BoxDecoration(
|
||||
color: StreamChatTheme.of(context).accentColor,
|
||||
color: streamChatTheme.accentColor,
|
||||
),
|
||||
child: hasImage
|
||||
? CachedNetworkImage(
|
||||
imageUrl: user.extraData['image'],
|
||||
errorWidget: (_, __, ___) {
|
||||
return Center(
|
||||
child: Text(
|
||||
user.name[0],
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
);
|
||||
return streamChatTheme.defaultUserImage(context, user);
|
||||
},
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: StreamChatTheme.of(context).defaultUserImage(context, user),
|
||||
: streamChatTheme.defaultUserImage(context, user),
|
||||
),
|
||||
),
|
||||
if (showOnlineStatus && user.online == true)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
Future<void> launchURL(BuildContext context, String url) async {
|
||||
@@ -42,3 +43,7 @@ Future<bool> showConfirmationDialog(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Get random png with initials
|
||||
String getRandomPicUrl(User user) =>
|
||||
'https://getstream.io/random_png/?id=${user.id}&name=${user.name}';
|
||||
|
||||
Reference in New Issue
Block a user