feat: 私信可选

This commit is contained in:
guozhigq
2024-08-24 00:07:08 +08:00
parent ec30235421
commit 15e1cb5d47

View File

@ -84,7 +84,7 @@ class ChatItem extends StatelessWidget {
emojiMap[e['text']] = e['url']; emojiMap[e['text']] = e['url'];
} }
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)) {
@ -95,6 +95,17 @@ class ChatItem extends StatelessWidget {
src: emojiMap[emojiKey]!, src: emojiMap[emojiKey]!,
), ),
)); ));
} else {
children.add(
TextSpan(
text: emojiKey,
style: TextStyle(
color: textColor(context),
letterSpacing: 0.6,
height: 1.5,
),
),
);
} }
return ''; return '';
}, },
@ -109,13 +120,13 @@ class ChatItem extends StatelessWidget {
return ''; return '';
}, },
); );
return RichText( return SelectableText.rich(
text: TextSpan( TextSpan(
children: children, children: children,
), ),
); );
} else { } else {
return Text( return SelectableText(
text, text,
style: TextStyle( style: TextStyle(
letterSpacing: 0.6, letterSpacing: 0.6,
@ -133,7 +144,7 @@ class ChatItem extends StatelessWidget {
case MsgType.pic_card: case MsgType.pic_card:
return SystemNotice2(item: item); return SystemNotice2(item: item);
case MsgType.notify_text: case MsgType.notify_text:
return Text( return SelectableText(
jsonDecode(content['content']) jsonDecode(content['content'])
.map((m) => m['text'] as String) .map((m) => m['text'] as String)
.join("\n"), .join("\n"),
@ -530,7 +541,7 @@ class SystemNotice extends StatelessWidget {
Divider( Divider(
color: Theme.of(context).colorScheme.primary.withOpacity(0.05), color: Theme.of(context).colorScheme.primary.withOpacity(0.05),
), ),
Text( SelectableText(
content['text'], content['text'],
) )
], ],