feat: Added file italics

This commit is contained in:
Deven Joshi
2021-01-06 15:35:15 +05:30
parent fc00acb890
commit a8c60a8482
2 changed files with 30 additions and 6 deletions
+15 -3
View File
@@ -222,7 +222,7 @@ class ChannelPreview extends StatelessWidget {
} }
return e == lastMessage.attachments.last return e == lastMessage.attachments.last
? (e.title ?? 'File') ? (e.title ?? 'File')
: '${e.title ?? 'File'}, '; : '${e.title ?? 'File'} , ';
}).where((e) => e != null), }).where((e) => e != null),
lastMessage.text ?? '', lastMessage.text ?? '',
]; ];
@@ -236,6 +236,7 @@ class ChannelPreview extends StatelessWidget {
text: _getDisplayText( text: _getDisplayText(
text, text,
lastMessage.mentionedUsers, lastMessage.mentionedUsers,
lastMessage.attachments,
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
color: StreamChatTheme.of(context) color: StreamChatTheme.of(context)
.channelPreviewTheme .channelPreviewTheme
@@ -259,8 +260,12 @@ class ChannelPreview extends StatelessWidget {
); );
} }
TextSpan _getDisplayText(String text, List<User> mentions, TextSpan _getDisplayText(
TextStyle normalTextStyle, TextStyle mentionsTextStyle) { String text,
List<User> mentions,
List<Attachment> attachments,
TextStyle normalTextStyle,
TextStyle mentionsTextStyle) {
var textList = text.split(' '); var textList = text.split(' ');
List<TextSpan> resList = []; List<TextSpan> resList = [];
for (var e in textList) { for (var e in textList) {
@@ -269,6 +274,13 @@ class ChannelPreview extends StatelessWidget {
text: '$e ', text: '$e ',
style: mentionsTextStyle, 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 { } else {
resList.add(TextSpan( resList.add(TextSpan(
text: '$e ', text: '$e ',
+15 -3
View File
@@ -115,7 +115,7 @@ class MessageSearchItem extends StatelessWidget {
} }
return e == message.attachments.last return e == message.attachments.last
? (e.title ?? 'File') ? (e.title ?? 'File')
: '${e.title ?? 'File'}, '; : '${e.title ?? 'File'} , ';
}).where((e) => e != null), }).where((e) => e != null),
message.text ?? '', message.text ?? '',
]; ];
@@ -129,6 +129,7 @@ class MessageSearchItem extends StatelessWidget {
text: _getDisplayText( text: _getDisplayText(
text, text,
message.mentionedUsers, message.mentionedUsers,
message.attachments,
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
fontStyle: (message.isSystem || message.isDeleted) fontStyle: (message.isSystem || message.isDeleted)
? FontStyle.italic ? FontStyle.italic
@@ -155,8 +156,12 @@ class MessageSearchItem extends StatelessWidget {
); );
} }
TextSpan _getDisplayText(String text, List<User> mentions, TextSpan _getDisplayText(
TextStyle normalTextStyle, TextStyle mentionsTextStyle) { String text,
List<User> mentions,
List<Attachment> attachments,
TextStyle normalTextStyle,
TextStyle mentionsTextStyle) {
var textList = text.split(' '); var textList = text.split(' ');
List<TextSpan> resList = []; List<TextSpan> resList = [];
for (var e in textList) { for (var e in textList) {
@@ -165,6 +170,13 @@ class MessageSearchItem extends StatelessWidget {
text: '$e ', text: '$e ',
style: mentionsTextStyle, 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 { } else {
resList.add(TextSpan( resList.add(TextSpan(
text: '$e ', text: '$e ',