diff --git a/lib/src/channel_preview.dart b/lib/src/channel_preview.dart index e325b04a..122e6a87 100644 --- a/lib/src/channel_preview.dart +++ b/lib/src/channel_preview.dart @@ -222,7 +222,7 @@ class ChannelPreview extends StatelessWidget { } return e == lastMessage.attachments.last ? (e.title ?? 'File') - : '${e.title ?? 'File'}, '; + : '${e.title ?? 'File'} , '; }).where((e) => e != null), lastMessage.text ?? '', ]; @@ -236,6 +236,7 @@ class ChannelPreview extends StatelessWidget { text: _getDisplayText( text, lastMessage.mentionedUsers, + lastMessage.attachments, StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( color: StreamChatTheme.of(context) .channelPreviewTheme @@ -259,8 +260,12 @@ class ChannelPreview extends StatelessWidget { ); } - TextSpan _getDisplayText(String text, List mentions, - TextStyle normalTextStyle, TextStyle mentionsTextStyle) { + TextSpan _getDisplayText( + String text, + List mentions, + List attachments, + TextStyle normalTextStyle, + TextStyle mentionsTextStyle) { var textList = text.split(' '); List resList = []; for (var e in textList) { @@ -269,6 +274,13 @@ class ChannelPreview extends StatelessWidget { text: '$e ', style: mentionsTextStyle, )); + } else if (attachments + .where((e) => e.title != null) + .any((element) => element.title == e)) { + resList.add(TextSpan( + text: '$e ', + style: normalTextStyle.copyWith(fontStyle: FontStyle.italic), + )); } else { resList.add(TextSpan( text: '$e ', diff --git a/lib/src/message_search_item.dart b/lib/src/message_search_item.dart index be257578..62e5f29d 100644 --- a/lib/src/message_search_item.dart +++ b/lib/src/message_search_item.dart @@ -115,7 +115,7 @@ class MessageSearchItem extends StatelessWidget { } return e == message.attachments.last ? (e.title ?? 'File') - : '${e.title ?? 'File'}, '; + : '${e.title ?? 'File'} , '; }).where((e) => e != null), message.text ?? '', ]; @@ -129,6 +129,7 @@ class MessageSearchItem extends StatelessWidget { text: _getDisplayText( text, message.mentionedUsers, + message.attachments, StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( fontStyle: (message.isSystem || message.isDeleted) ? FontStyle.italic @@ -155,8 +156,12 @@ class MessageSearchItem extends StatelessWidget { ); } - TextSpan _getDisplayText(String text, List mentions, - TextStyle normalTextStyle, TextStyle mentionsTextStyle) { + TextSpan _getDisplayText( + String text, + List mentions, + List attachments, + TextStyle normalTextStyle, + TextStyle mentionsTextStyle) { var textList = text.split(' '); List resList = []; for (var e in textList) { @@ -165,6 +170,13 @@ class MessageSearchItem extends StatelessWidget { text: '$e ', style: mentionsTextStyle, )); + } else if (attachments + .where((e) => e.title != null) + .any((element) => element.title == e)) { + resList.add(TextSpan( + text: '$e ', + style: normalTextStyle.copyWith(fontStyle: FontStyle.italic), + )); } else { resList.add(TextSpan( text: '$e ',