moved tap logic to UserAvatar Widget
This commit is contained in:
@@ -155,13 +155,9 @@ class _MessageWidgetState extends State<MessageWidget>
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (widget.onUserAvatarTap != null) {
|
||||
widget.onUserAvatarTap(widget.message.user);
|
||||
}
|
||||
},
|
||||
child: UserAvatar(user: widget.message.user),
|
||||
UserAvatar(
|
||||
user: widget.message.user,
|
||||
onUserAvatarTap: widget.onUserAvatarTap,
|
||||
),
|
||||
if (_isMyMessage &&
|
||||
widget.nextMessage == null &&
|
||||
|
||||
+41
-27
@@ -9,41 +9,55 @@ class UserAvatar extends StatelessWidget {
|
||||
Key key,
|
||||
@required this.user,
|
||||
this.constraints,
|
||||
this.onUserAvatarTap,
|
||||
}) : super(key: key);
|
||||
|
||||
final User user;
|
||||
final BoxConstraints constraints;
|
||||
final void Function(User) onUserAvatarTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ClipRRect(
|
||||
borderRadius:
|
||||
StreamChatTheme.of(context).ownMessageTheme.avatarTheme.borderRadius,
|
||||
child: Container(
|
||||
constraints: constraints ??
|
||||
StreamChatTheme.of(context).ownMessageTheme.avatarTheme.constraints,
|
||||
decoration: BoxDecoration(
|
||||
color: StreamChatTheme.of(context).accentColor,
|
||||
),
|
||||
child: user.extraData?.containsKey('image') ?? false
|
||||
? CachedNetworkImage(
|
||||
imageUrl: user.extraData['image'],
|
||||
errorWidget: (_, __, ___) {
|
||||
return Center(
|
||||
child: Text(
|
||||
user.extraData?.containsKey('name') ?? false
|
||||
? user.extraData['name'][0]
|
||||
: '',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (onUserAvatarTap != null) {
|
||||
onUserAvatarTap(user);
|
||||
}
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: StreamChatTheme.of(context)
|
||||
.ownMessageTheme
|
||||
.avatarTheme
|
||||
.borderRadius,
|
||||
child: Container(
|
||||
constraints: constraints ??
|
||||
StreamChatTheme.of(context)
|
||||
.ownMessageTheme
|
||||
.avatarTheme
|
||||
.constraints,
|
||||
decoration: BoxDecoration(
|
||||
color: StreamChatTheme.of(context).accentColor,
|
||||
),
|
||||
child: user.extraData?.containsKey('image') ?? false
|
||||
? CachedNetworkImage(
|
||||
imageUrl: user.extraData['image'],
|
||||
errorWidget: (_, __, ___) {
|
||||
return Center(
|
||||
child: Text(
|
||||
user.extraData?.containsKey('name') ?? false
|
||||
? user.extraData['name'][0]
|
||||
: '',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: StreamChatTheme.of(context).defaultUserImage(context, user),
|
||||
);
|
||||
},
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: StreamChatTheme.of(context).defaultUserImage(context, user),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user