add onLinkTap to MessageWidget

This commit is contained in:
Salvatore Giordano
2020-08-25 11:09:37 +02:00
parent 1e8fbd2854
commit 5bcc9bdf91
2 changed files with 12 additions and 1 deletions
+7 -1
View File
@@ -11,10 +11,12 @@ class MessageText extends StatelessWidget {
@required this.message,
@required this.messageTheme,
this.onMentionTap,
this.onLinkTap,
}) : super(key: key);
final Message message;
final void Function(User) onMentionTap;
final void Function(String) onLinkTap;
final MessageTheme messageTheme;
@override
@@ -35,7 +37,11 @@ class MessageText extends StatelessWidget {
print('tap on ${mentionedUser.name}');
}
} else {
launchURL(context, link);
if (onLinkTap != null) {
onLinkTap(link);
} else {
launchURL(context, link);
}
}
},
styleSheet: MarkdownStyleSheet.fromTheme(
+5
View File
@@ -97,6 +97,9 @@ class MessageWidget extends StatefulWidget {
/// The function called when tapping on UserAvatar
final void Function(User) onUserAvatarTap;
/// The function called when tapping on a link
final void Function(String) onLinkTap;
final List<Read> readList;
/// If true show the users username next to the timestamp of the message
@@ -128,6 +131,7 @@ class MessageWidget extends StatefulWidget {
this.showDeleteMessage = true,
this.showEditMessage = true,
this.onUserAvatarTap,
this.onLinkTap,
this.onMessageActions,
this.editMessageInputBuilder,
this.textBuilder,
@@ -764,6 +768,7 @@ class _MessageWidgetState extends State<MessageWidget> {
return widget.textBuilder != null
? widget.textBuilder(context, widget.message)
: MessageText(
onLinkTap: widget.onLinkTap,
message: widget.message,
onMentionTap: widget.onMentionTap,
messageTheme: widget.messageTheme,