add on mention tap
This commit is contained in:
@@ -37,8 +37,12 @@ class MessageWidget extends StatefulWidget {
|
|||||||
this.onThreadTap,
|
this.onThreadTap,
|
||||||
this.onMessageActions,
|
this.onMessageActions,
|
||||||
this.isParent = false,
|
this.isParent = false,
|
||||||
|
this.onMentionTap,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
/// Function called on mention tap
|
||||||
|
final void Function(User) onMentionTap;
|
||||||
|
|
||||||
/// Function called on long press
|
/// Function called on long press
|
||||||
final Function(BuildContext, Message) onMessageActions;
|
final Function(BuildContext, Message) onMessageActions;
|
||||||
|
|
||||||
@@ -360,7 +364,8 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
if (widget.message.text.trim().isNotEmpty) {
|
if (widget.message.text.trim().isNotEmpty) {
|
||||||
String text = widget.message.text;
|
String text = widget.message.text;
|
||||||
widget.message.mentionedUsers?.forEach((u) {
|
widget.message.mentionedUsers?.forEach((u) {
|
||||||
text = text.replaceAll(u.name, '**${u.name}**');
|
text = text.replaceAll(
|
||||||
|
'@${u.name}', '[@${u.name}](@${u.name.replaceAll(' ', '')})');
|
||||||
});
|
});
|
||||||
|
|
||||||
column.children.addAll(
|
column.children.addAll(
|
||||||
@@ -395,9 +400,23 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
padding: EdgeInsets.all(10),
|
padding: EdgeInsets.all(10),
|
||||||
constraints: BoxConstraints.loose(Size.fromWidth(300)),
|
constraints: BoxConstraints.loose(Size.fromWidth(300)),
|
||||||
child: MarkdownBody(
|
child: MarkdownBody(
|
||||||
data: '${text}',
|
data: text,
|
||||||
onTapLink: (link) {
|
onTapLink: (link) {
|
||||||
_launchURL(link);
|
if (link.startsWith('@')) {
|
||||||
|
final mentionedUser =
|
||||||
|
widget.message.mentionedUsers.firstWhere(
|
||||||
|
(u) => '@${u.name.replaceAll(' ', '')}' == link,
|
||||||
|
orElse: () => null,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (widget.onMentionTap != null) {
|
||||||
|
widget.onMentionTap(mentionedUser);
|
||||||
|
} else {
|
||||||
|
print('tap on ${mentionedUser.name}');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_launchURL(link);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
styleSheet: MarkdownStyleSheet.fromTheme(
|
styleSheet: MarkdownStyleSheet.fromTheme(
|
||||||
Theme.of(context).copyWith(
|
Theme.of(context).copyWith(
|
||||||
@@ -456,7 +475,6 @@ class _MessageWidgetState extends State<MessageWidget>
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: IntrinsicWidth(child: column),
|
child: IntrinsicWidth(child: column),
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
print('widget.message.type: ${widget.message.type}');
|
|
||||||
if (widget.message.type == 'ephemeral') {
|
if (widget.message.type == 'ephemeral') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ dependencies:
|
|||||||
file_picker: ^1.4.3+2
|
file_picker: ^1.4.3+2
|
||||||
image_picker: ^0.6.3+4
|
image_picker: ^0.6.3+4
|
||||||
keyboard_visibility: ^0.5.6
|
keyboard_visibility: ^0.5.6
|
||||||
stream_chat: ^0.1.16
|
stream_chat: ^0.1.17
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
pedantic: ^1.8.0+1
|
pedantic: ^1.8.0+1
|
||||||
|
|||||||
Reference in New Issue
Block a user