moved tap logic to UserAvatar Widget

This commit is contained in:
Luis Pulido
2020-04-23 12:31:01 -04:00
parent 061962ea8b
commit c5ba6dc390
2 changed files with 44 additions and 34 deletions
+3 -7
View File
@@ -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 &&
+18 -4
View File
@@ -9,19 +9,32 @@ 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) {
onUserAvatarTap(user);
}
},
child: ClipRRect(
borderRadius: StreamChatTheme.of(context)
.ownMessageTheme
.avatarTheme
.borderRadius,
child: Container( child: Container(
constraints: 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,
), ),
@@ -45,6 +58,7 @@ class UserAvatar extends StatelessWidget {
) )
: StreamChatTheme.of(context).defaultUserImage(context, user), : StreamChatTheme.of(context).defaultUserImage(context, user),
), ),
),
); );
} }
} }