opt: pm emoji

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-29 13:57:59 +08:00
parent b3ab417c85
commit 4b6b3e8377

View File

@@ -79,20 +79,25 @@ class ChatItem extends StatelessWidget {
var text = content['content']; var text = content['content'];
if (eInfos != null) { if (eInfos != null) {
final List<InlineSpan> children = []; final List<InlineSpan> children = [];
Map<String, String> emojiMap = {}; Map<String, Map> emojiMap = {};
for (var e in eInfos!) { for (var e in eInfos!) {
emojiMap[e['text']] = e['url']; emojiMap[e['text']] = {
'url': e['gif_url'] ?? e['url'],
'size': e['size'] ?? 1,
};
} }
text.splitMapJoin( text.splitMapJoin(
RegExp(r"\[[^\[\]]+\]"), RegExp(r"\[[^\[\]]+\]"),
onMatch: (Match match) { onMatch: (Match match) {
final String emojiKey = match[0]!; final String emojiKey = match[0]!;
if (emojiMap.containsKey(emojiKey)) { if (emojiMap.containsKey(emojiKey)) {
final double size = 24.0 * emojiMap[emojiKey]!['size'];
children.add(WidgetSpan( children.add(WidgetSpan(
child: NetworkImgLayer( child: NetworkImgLayer(
width: 18, width: size,
height: 18, height: size,
src: emojiMap[emojiKey]!, src: emojiMap[emojiKey]!['url'],
type: 'emote',
), ),
)); ));
} else { } else {