Merge pull request #40 from nosmirck/feature/onTapUserMessage

Added onUserAvatarTap
This commit is contained in:
Salvatore Giordano
2020-04-24 15:26:56 +02:00
committed by GitHub
3 changed files with 57 additions and 28 deletions
+8
View File
@@ -65,6 +65,7 @@ class MessageListView extends StatefulWidget {
this.showOtherMessageUsername = false, this.showOtherMessageUsername = false,
this.showVideoFullScreen = true, this.showVideoFullScreen = true,
this.onMentionTap, this.onMentionTap,
this.onUserAvatarTap,
this.onMessageActions, this.onMessageActions,
}) : super(key: key); }) : super(key: key);
@@ -93,6 +94,9 @@ class MessageListView extends StatefulWidget {
/// Function called on message mention tap /// Function called on message mention tap
final void Function(User) onMentionTap; final void Function(User) onMentionTap;
/// Function called on User Avatar tap
final void Function(User) onUserAvatarTap;
/// Function called on message long press /// Function called on message long press
final Function(BuildContext, Message) onMessageActions; final Function(BuildContext, Message) onMessageActions;
@@ -154,6 +158,7 @@ class _MessageListViewState extends State<MessageListView> {
showOtherMessageUsername: showOtherMessageUsername:
widget.showOtherMessageUsername, widget.showOtherMessageUsername,
onMentionTap: widget.onMentionTap, onMentionTap: widget.onMentionTap,
onUserAvatarTap: widget.onUserAvatarTap,
onMessageActions: widget.onMessageActions, onMessageActions: widget.onMessageActions,
), ),
Padding( Padding(
@@ -216,6 +221,7 @@ class _MessageListViewState extends State<MessageListView> {
showOtherMessageUsername: widget.showOtherMessageUsername, showOtherMessageUsername: widget.showOtherMessageUsername,
showVideoFullScreen: widget.showVideoFullScreen, showVideoFullScreen: widget.showVideoFullScreen,
onMentionTap: widget.onMentionTap, onMentionTap: widget.onMentionTap,
onUserAvatarTap: widget.onUserAvatarTap,
onMessageActions: widget.onMessageActions, onMessageActions: widget.onMessageActions,
); );
} }
@@ -363,6 +369,7 @@ class _MessageListViewState extends State<MessageListView> {
showVideoFullScreen: widget.showVideoFullScreen, showVideoFullScreen: widget.showVideoFullScreen,
showOtherMessageUsername: widget.showOtherMessageUsername, showOtherMessageUsername: widget.showOtherMessageUsername,
onMentionTap: widget.onMentionTap, onMentionTap: widget.onMentionTap,
onUserAvatarTap: widget.onUserAvatarTap,
onMessageActions: widget.onMessageActions, onMessageActions: widget.onMessageActions,
); );
} }
@@ -402,6 +409,7 @@ class _MessageListViewState extends State<MessageListView> {
showVideoFullScreen: widget.showVideoFullScreen, showVideoFullScreen: widget.showVideoFullScreen,
showOtherMessageUsername: widget.showOtherMessageUsername, showOtherMessageUsername: widget.showOtherMessageUsername,
onMentionTap: widget.onMentionTap, onMentionTap: widget.onMentionTap,
onUserAvatarTap: widget.onUserAvatarTap,
onMessageActions: widget.onMessageActions, onMessageActions: widget.onMessageActions,
); );
} }
+8 -1
View File
@@ -35,6 +35,7 @@ class MessageWidget extends StatefulWidget {
@required this.message, @required this.message,
@required this.nextMessage, @required this.nextMessage,
this.onThreadTap, this.onThreadTap,
this.onUserAvatarTap,
this.onMessageActions, this.onMessageActions,
this.isParent = false, this.isParent = false,
this.onMentionTap, this.onMentionTap,
@@ -63,6 +64,9 @@ class MessageWidget extends StatefulWidget {
/// The function called when tapping on replies /// The function called when tapping on replies
final void Function(Message) onThreadTap; final void Function(Message) onThreadTap;
/// The function called when tapping on UserAvatar
final void Function(User) onUserAvatarTap;
/// True if this is the parent of the thread being showed /// True if this is the parent of the thread being showed
final bool isParent; final bool isParent;
@@ -151,7 +155,10 @@ class _MessageWidgetState extends State<MessageWidget>
), ),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
UserAvatar(user: widget.message.user), UserAvatar(
user: widget.message.user,
onTap: widget.onUserAvatarTap,
),
if (_isMyMessage && if (_isMyMessage &&
widget.nextMessage == null && widget.nextMessage == null &&
(widget.message.status == MessageSendingStatus.SENT || (widget.message.status == MessageSendingStatus.SENT ||
+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.onTap,
}) : super(key: key); }) : super(key: key);
final User user; final User user;
final BoxConstraints constraints; final BoxConstraints constraints;
final void Function(User) onTap;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ClipRRect( return GestureDetector(
borderRadius: onTap: () {
StreamChatTheme.of(context).ownMessageTheme.avatarTheme.borderRadius, if (onTap != null) {
onTap(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),
), ),
),
); );
} }
} }