feat: 评论投票渲染
This commit is contained in:
@ -430,13 +430,46 @@ InlineSpan buildContent(BuildContext context, content) {
|
|||||||
}
|
}
|
||||||
List<InlineSpan> spanChilds = [];
|
List<InlineSpan> spanChilds = [];
|
||||||
bool hasMatchMember = true;
|
bool hasMatchMember = true;
|
||||||
|
|
||||||
|
// 投票
|
||||||
|
if (content.vote.isNotEmpty) {
|
||||||
|
content.message.splitMapJoin(RegExp(r"\{vote:.*?\}"),
|
||||||
|
onMatch: (Match match) {
|
||||||
|
String matchStr = match[0]!;
|
||||||
|
spanChilds.add(
|
||||||
|
TextSpan(
|
||||||
|
text: '投票: ${content.vote['title']}',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () => {
|
||||||
|
Get.toNamed(
|
||||||
|
'/webview',
|
||||||
|
parameters: {
|
||||||
|
'url': content.vote['url'],
|
||||||
|
'type': 'vote',
|
||||||
|
'pageTitle': content.vote['title'],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return '';
|
||||||
|
}, onNonMatch: (String str) {
|
||||||
|
return str;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// content.message = content.message.replaceAll(RegExp(r"\{vote:.*?\}"), ' ');
|
||||||
// 匹配表情
|
// 匹配表情
|
||||||
String matchEmote = content.message.splitMapJoin(
|
String matchEmote = content.message.splitMapJoin(
|
||||||
RegExp(r"\[.*?\]"),
|
RegExp(r"\[.*?\]"),
|
||||||
onMatch: (Match match) {
|
onMatch: (Match match) {
|
||||||
String matchStr = match[0]!;
|
String matchStr = match[0]!;
|
||||||
|
if (content.emote.isNotEmpty &&
|
||||||
|
matchStr.indexOf('[') == matchStr.lastIndexOf('[') &&
|
||||||
|
matchStr.indexOf(']') == matchStr.lastIndexOf(']')) {
|
||||||
int size = content.emote[matchStr]['meta']['size'];
|
int size = content.emote[matchStr]['meta']['size'];
|
||||||
if (content.emote.isNotEmpty) {
|
|
||||||
if (content.emote.keys.contains(matchStr)) {
|
if (content.emote.keys.contains(matchStr)) {
|
||||||
spanChilds.add(
|
spanChilds.add(
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
@ -452,6 +485,9 @@ InlineSpan buildContent(BuildContext context, content) {
|
|||||||
spanChilds.add(TextSpan(text: matchStr));
|
spanChilds.add(TextSpan(text: matchStr));
|
||||||
return matchStr;
|
return matchStr;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
spanChilds.add(TextSpan(text: matchStr));
|
||||||
|
return matchStr;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user