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