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
? (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<User> mentions,
TextStyle normalTextStyle, TextStyle mentionsTextStyle) {
TextSpan _getDisplayText(
String text,
List<User> mentions,
List<Attachment> attachments,
TextStyle normalTextStyle,
TextStyle mentionsTextStyle) {
var textList = text.split(' ');
List<TextSpan> 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 ',
+15 -3
View File
@@ -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<User> mentions,
TextStyle normalTextStyle, TextStyle mentionsTextStyle) {
TextSpan _getDisplayText(
String text,
List<User> mentions,
List<Attachment> attachments,
TextStyle normalTextStyle,
TextStyle mentionsTextStyle) {
var textList = text.split(' ');
List<TextSpan> 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 ',