opt pm msg

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-08 18:52:07 +08:00
parent d2023b1750
commit 8bf55ec95a
2 changed files with 50 additions and 56 deletions

View File

@@ -266,10 +266,12 @@ class _ReplyPageState extends CommonRichTextPubPageState<ReplyPage> {
@override @override
Future<void> onCustomPublish({List? pictures}) async { Future<void> onCustomPublish({List? pictures}) async {
Map<String, int> atNameToMid = { Map<String, int> atNameToMid = {};
for (var e in editController.items) for (var e in editController.items) {
if (e.type == RichTextType.at) e.rawText: int.parse(e.id!), if (e.type == RichTextType.at) {
}; atNameToMid[e.rawText] ??= int.parse(e.id!);
}
}
String message = editController.rawText; String message = editController.rawText;
var result = await VideoHttp.replyAdd( var result = await VideoHttp.replyAdd(
type: widget.replyType, type: widget.replyType,

View File

@@ -617,67 +617,59 @@ class ChatItem extends StatelessWidget {
required dynamic content, required dynamic content,
required Color textColor, required Color textColor,
}) { }) {
late final style = TextStyle( final style = TextStyle(color: textColor, letterSpacing: 0.6, height: 1.5);
color: textColor, final List<InlineSpan> children = [];
letterSpacing: 0.6, late final Map<String, Map> emojiMap = {};
height: 1.5, final List<String> patterns = [Constants.urlRegex.pattern];
);
if (eInfos != null) { if (eInfos != null) {
final List<InlineSpan> children = [];
Map<String, Map> emojiMap = {};
for (var e in eInfos!) { for (var e in eInfos!) {
emojiMap[e.text] = { emojiMap[e.text] ??= {
'url': e.hasGifUrl() ? e.gifUrl : e.url, 'url': e.hasGifUrl() ? e.gifUrl : e.url,
'size': e.size * 24.0, 'size': e.size * 22.0,
}; };
} }
final regex = RegExp( patterns.addAll(emojiMap.keys.map(RegExp.escape));
[ }
...emojiMap.keys.map(RegExp.escape), final regex = RegExp(patterns.join('|'));
Constants.urlRegex.pattern, content['content'].splitMapJoin(
].join('|'), regex,
); onMatch: (Match match) {
content['content'].splitMapJoin( final matchStr = match[0]!;
regex, if (matchStr.startsWith('[')) {
onMatch: (Match match) { final emoji = emojiMap[matchStr];
final matchStr = match[0]!; if (emoji != null) {
if (matchStr.startsWith('[')) { final size = emoji['size'];
final emoji = emojiMap[matchStr];
if (emoji != null) {
final size = emoji['size'];
children.add(
WidgetSpan(
child: NetworkImgLayer(
width: size,
height: size,
src: emoji['url'],
type: ImageType.emote,
),
),
);
} else {
children.add(TextSpan(text: matchStr, style: style));
}
} else {
children.add( children.add(
TextSpan( WidgetSpan(
text: matchStr, child: NetworkImgLayer(
style: style.copyWith(color: theme.colorScheme.primary), width: size,
recognizer: TapGestureRecognizer() height: size,
..onTap = () => PiliScheme.routePushFromUrl(matchStr), src: emoji['url'],
type: ImageType.emote,
),
), ),
); );
} else {
children.add(TextSpan(text: matchStr, style: style));
} }
return ''; } else {
}, children.add(
onNonMatch: (String text) { TextSpan(
children.add(TextSpan(text: text, style: style)); text: matchStr,
return ''; style: style.copyWith(color: theme.colorScheme.primary),
}, recognizer: TapGestureRecognizer()
); ..onTap = () => PiliScheme.routePushFromUrl(matchStr),
return SelectableText.rich(TextSpan(children: children)); ),
} );
return SelectableText(content['content'], style: style); }
return '';
},
onNonMatch: (String text) {
children.add(TextSpan(text: text, style: style));
return '';
},
);
return SelectableText.rich(TextSpan(children: children));
} }
Widget msgTypeNotifyMsg_10(ThemeData theme, content) { Widget msgTypeNotifyMsg_10(ThemeData theme, content) {