feat: Added bold mentions in previews, added file names for last message
This commit is contained in:
@@ -220,7 +220,9 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
} else if (e.type == 'giphy') {
|
} else if (e.type == 'giphy') {
|
||||||
return '[GIF]';
|
return '[GIF]';
|
||||||
}
|
}
|
||||||
return null;
|
return e == lastMessage.attachments.last
|
||||||
|
? e.title
|
||||||
|
: '${e.title}, ';
|
||||||
}).where((e) => e != null),
|
}).where((e) => e != null),
|
||||||
lastMessage.text ?? '',
|
lastMessage.text ?? '',
|
||||||
];
|
];
|
||||||
@@ -228,22 +230,53 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
text = parts.join(' ');
|
text = parts.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
return Text(
|
return RichText(
|
||||||
text,
|
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style:
|
text: _getDisplayText(
|
||||||
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
text,
|
||||||
color: StreamChatTheme.of(context)
|
lastMessage.mentionedUsers,
|
||||||
.channelPreviewTheme
|
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
||||||
.subtitle
|
color: StreamChatTheme.of(context)
|
||||||
.color,
|
.channelPreviewTheme
|
||||||
fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
|
.subtitle
|
||||||
? FontStyle.italic
|
.color,
|
||||||
: FontStyle.normal,
|
fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
|
||||||
),
|
? FontStyle.italic
|
||||||
|
: FontStyle.normal),
|
||||||
|
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
||||||
|
color: StreamChatTheme.of(context)
|
||||||
|
.channelPreviewTheme
|
||||||
|
.subtitle
|
||||||
|
.color,
|
||||||
|
fontStyle: (lastMessage.isSystem || lastMessage.isDeleted)
|
||||||
|
? FontStyle.italic
|
||||||
|
: FontStyle.normal,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextSpan _getDisplayText(String text, List<User> mentions,
|
||||||
|
TextStyle normalTextStyle, TextStyle mentionsTextStyle) {
|
||||||
|
var textList = text.split(' ');
|
||||||
|
List<TextSpan> resList = [];
|
||||||
|
for (var e in textList) {
|
||||||
|
if (mentions.any((element) => '@${element.name}' == e)) {
|
||||||
|
resList.add(TextSpan(
|
||||||
|
text: '$e ',
|
||||||
|
style: mentionsTextStyle,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
resList.add(TextSpan(
|
||||||
|
text: '$e ',
|
||||||
|
style: normalTextStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TextSpan(children: resList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,9 @@ class MessageSearchItem extends StatelessWidget {
|
|||||||
} else if (e.type == 'giphy') {
|
} else if (e.type == 'giphy') {
|
||||||
return '[GIF]';
|
return '[GIF]';
|
||||||
}
|
}
|
||||||
return null;
|
return e == message.attachments.last
|
||||||
|
? (e.title ?? 'File')
|
||||||
|
: '${e.title ?? 'File'}, ';
|
||||||
}).where((e) => e != null),
|
}).where((e) => e != null),
|
||||||
message.text ?? '',
|
message.text ?? '',
|
||||||
];
|
];
|
||||||
@@ -121,6 +123,26 @@ class MessageSearchItem extends StatelessWidget {
|
|||||||
text = parts.join(' ');
|
text = parts.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return RichText(
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
text: _getDisplayText(
|
||||||
|
text,
|
||||||
|
message.mentionedUsers,
|
||||||
|
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
||||||
|
fontStyle: (message.isSystem || message.isDeleted)
|
||||||
|
? FontStyle.italic
|
||||||
|
: FontStyle.normal,
|
||||||
|
),
|
||||||
|
StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith(
|
||||||
|
fontStyle: (message.isSystem || message.isDeleted)
|
||||||
|
? FontStyle.italic
|
||||||
|
: FontStyle.normal,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return Text(
|
return Text(
|
||||||
text,
|
text,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
@@ -132,4 +154,25 @@ class MessageSearchItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextSpan _getDisplayText(String text, List<User> mentions,
|
||||||
|
TextStyle normalTextStyle, TextStyle mentionsTextStyle) {
|
||||||
|
var textList = text.split(' ');
|
||||||
|
List<TextSpan> resList = [];
|
||||||
|
for (var e in textList) {
|
||||||
|
if (mentions.any((element) => '@${element.name}' == e)) {
|
||||||
|
resList.add(TextSpan(
|
||||||
|
text: '$e ',
|
||||||
|
style: mentionsTextStyle,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
resList.add(TextSpan(
|
||||||
|
text: '$e ',
|
||||||
|
style: normalTextStyle,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TextSpan(children: resList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user