fix channel image and user avatar widget size
This commit is contained in:
+13
-13
@@ -38,7 +38,7 @@ import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
|||||||
/// The widget uses a [StreamBuilder] to render the channel information image as soon as it updates.
|
/// The widget uses a [StreamBuilder] to render the channel information image as soon as it updates.
|
||||||
///
|
///
|
||||||
/// By default the widget radius size is 40x40 pixels.
|
/// By default the widget radius size is 40x40 pixels.
|
||||||
/// Set the property [size] to set a custom dimension.
|
/// Set the property [constraints] to set a custom dimension.
|
||||||
///
|
///
|
||||||
/// The widget renders the ui based on the first ancestor of type [StreamChatTheme].
|
/// The widget renders the ui based on the first ancestor of type [StreamChatTheme].
|
||||||
/// Modify it to change the widget appearance.
|
/// Modify it to change the widget appearance.
|
||||||
@@ -46,14 +46,14 @@ class ChannelImage extends StatelessWidget {
|
|||||||
const ChannelImage({
|
const ChannelImage({
|
||||||
Key key,
|
Key key,
|
||||||
this.channel,
|
this.channel,
|
||||||
this.size = 40,
|
this.constraints,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The channel to show the image of
|
/// The channel to show the image of
|
||||||
final Channel channel;
|
final Channel channel;
|
||||||
|
|
||||||
/// The diameter of the image
|
/// The diameter of the image
|
||||||
final double size;
|
final BoxConstraints constraints;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -63,14 +63,13 @@ class ChannelImage extends StatelessWidget {
|
|||||||
stream: channel.extraDataStream,
|
stream: channel.extraDataStream,
|
||||||
initialData: channel.extraData,
|
initialData: channel.extraData,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
var image = '';
|
String image;
|
||||||
if (snapshot.data?.containsKey('image') == true) {
|
if (snapshot.data?.containsKey('image') == true) {
|
||||||
image = snapshot.data['image'];
|
image = snapshot.data['image'];
|
||||||
} else if (channel.state.members.length == 2) {
|
} else if (channel.state.members.length == 2) {
|
||||||
final otherMember = channel.state.members.firstWhere(
|
final otherMember = channel.state.members
|
||||||
(member) => member.user.id != client.user.id
|
.firstWhere((member) => member.user.id != client.user.id);
|
||||||
);
|
image = otherMember.user.extraData['image'];
|
||||||
image = otherMember.user.image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
@@ -79,14 +78,15 @@ class ChannelImage extends StatelessWidget {
|
|||||||
.avatarTheme
|
.avatarTheme
|
||||||
.borderRadius,
|
.borderRadius,
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints: StreamChatTheme.of(context)
|
constraints: constraints ??
|
||||||
.channelPreviewTheme
|
StreamChatTheme.of(context)
|
||||||
.avatarTheme
|
.channelPreviewTheme
|
||||||
.constraints,
|
.avatarTheme
|
||||||
|
.constraints,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: StreamChatTheme.of(context).accentColor,
|
color: StreamChatTheme.of(context).accentColor,
|
||||||
),
|
),
|
||||||
child: image != ''
|
child: image != null
|
||||||
? CachedNetworkImage(
|
? CachedNetworkImage(
|
||||||
imageUrl: image,
|
imageUrl: image,
|
||||||
errorWidget: (_, __, ___) {
|
errorWidget: (_, __, ___) {
|
||||||
|
|||||||
@@ -28,17 +28,18 @@ class ChannelName extends StatelessWidget {
|
|||||||
stream: channel.extraDataStream,
|
stream: channel.extraDataStream,
|
||||||
initialData: channel.extraData,
|
initialData: channel.extraData,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
var title;
|
String title;
|
||||||
if (snapshot.data['name'] == null && channel.state.members.length == 2) {
|
if (snapshot.data['name'] == null &&
|
||||||
final otherMember = channel.state.members.firstWhere(
|
channel.state.members.length == 2) {
|
||||||
(member) => member.user.id != client.user.id
|
final otherMember = channel.state.members
|
||||||
);
|
.firstWhere((member) => member.user.id != client.user.id);
|
||||||
title = otherMember.user.name;
|
title = otherMember.user.name;
|
||||||
} else {
|
} else {
|
||||||
title = snapshot.data['name'] ?? channel.id;
|
title = snapshot.data['name'] ?? channel.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Text(title,
|
return Text(
|
||||||
|
title,
|
||||||
style: textStyle,
|
style: textStyle,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ class UserAvatar extends StatelessWidget {
|
|||||||
const UserAvatar({
|
const UserAvatar({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.user,
|
@required this.user,
|
||||||
this.radius = 16,
|
this.constraints,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final User user;
|
final User user;
|
||||||
final double radius;
|
final BoxConstraints constraints;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -20,7 +20,7 @@ class UserAvatar extends StatelessWidget {
|
|||||||
borderRadius:
|
borderRadius:
|
||||||
StreamChatTheme.of(context).ownMessageTheme.avatarTheme.borderRadius,
|
StreamChatTheme.of(context).ownMessageTheme.avatarTheme.borderRadius,
|
||||||
child: Container(
|
child: Container(
|
||||||
constraints:
|
constraints: constraints ??
|
||||||
StreamChatTheme.of(context).ownMessageTheme.avatarTheme.constraints,
|
StreamChatTheme.of(context).ownMessageTheme.avatarTheme.constraints,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: StreamChatTheme.of(context).accentColor,
|
color: StreamChatTheme.of(context).accentColor,
|
||||||
|
|||||||
Reference in New Issue
Block a user