mod: 评论表情渲染

This commit is contained in:
guozhigq
2023-04-26 22:09:39 +08:00
parent 1d97d1848d
commit 0ec926839c
9 changed files with 503 additions and 276 deletions

View File

@ -1,10 +1,11 @@
class ReplyContent {
ReplyContent({
this.message,
this.atNameToMid, // @的用户的mid
this.memebers, // 被@的用户List 如果有的话
this.emote, // 表情包 如果有的话
this.jumpUrl,
this.atNameToMid, // @的用户的mid null
this.memebers, // 被@的用户List 如果有的话 []
this.emote, // 表情包 如果有的话 null
this.jumpUrl, // {}
this.pictures, // {}
});
String? message;
@ -12,12 +13,14 @@ class ReplyContent {
List? memebers;
Map? emote;
Map? jumpUrl;
List? pictures;
ReplyContent.fromJson(Map<String, dynamic> json) {
message = json['message'];
atNameToMid = json['at_name_to_mid'];
memebers = json['memebers'];
emote = json['emote'];
jumpUrl = json['jumpUrl'];
atNameToMid = json['at_name_to_mid'] ?? {};
memebers = json['memebers'] ?? [];
emote = json['emote'] ?? {};
jumpUrl = json['jumpUrl'] ?? {};
pictures = json['pictures'] ?? [];
}
}

View File

@ -15,18 +15,22 @@ class ReplyData {
ReplyPage? page;
ReplyConfig? config;
late List? replies;
late List? topReplies;
late List<ReplyItemModel>? replies;
late List<ReplyItemModel>? topReplies;
ReplyUpper? upper;
ReplyData.fromJson(Map<String, dynamic> json) {
page = ReplyPage.fromJson(json['page']);
config = ReplyConfig.fromJson(json['config']);
replies =
json['replies'].map((item) => ReplyItemModel.fromJson(item)).toList();
replies = json['replies']
.map<ReplyItemModel>(
(item) => ReplyItemModel.fromJson(item, json['upper']['mid']))
.toList();
topReplies = json['top_replies'] != null
? json['top_replies']
.map((item) => ReplyItemModel.fromJson(item))
.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
item, json['upper']['mid'],
isTopStatus: true))
.toList()
: [];
upper = ReplyUpper.fromJson(json['upper']);

View File

@ -28,6 +28,8 @@ class ReplyItemModel {
this.upAction,
this.invisible,
this.replyControl,
this.isUp,
this.isTop,
});
int? rpid;
@ -55,8 +57,11 @@ class ReplyItemModel {
UpAction? upAction;
bool? invisible;
ReplyControl? replyControl;
bool? isUp;
bool? isTop = false;
ReplyItemModel.fromJson(Map<String, dynamic> json) {
ReplyItemModel.fromJson(Map<String, dynamic> json, upperMid,
{isTopStatus = false}) {
rpid = json['rpid'];
oid = json['oid'];
type = json['type'];
@ -78,7 +83,9 @@ class ReplyItemModel {
member = ReplyMember.fromJson(json['member']);
content = ReplyContent.fromJson(json['content']);
replies = json['replies'] != null
? json['replies'].map((item) => ReplyItemModel.fromJson(item)).toList()
? json['replies']
.map((item) => ReplyItemModel.fromJson(item, upperMid))
.toList()
: [];
assist = json['assist'];
upAction = UpAction.fromJson(json['up_action']);
@ -86,6 +93,8 @@ class ReplyItemModel {
replyControl = json['reply_control'] == null
? null
: ReplyControl.fromJson(json['reply_control']);
isUp = upperMid.toString() == json['member']['mid'];
isTop = isTopStatus;
}
}
@ -126,7 +135,7 @@ class ReplyControl {
upReply = json['up_reply'] ?? false;
isUpTop = json['is_up_top'] ?? false;
upLike = json['up_like'] ?? false;
if (json['sub_reply_entry_text'] == null) {
if (json['sub_reply_entry_text'] != null) {
final RegExp regex = RegExp(r"\d+");
final RegExpMatch match = regex.firstMatch(
json['sub_reply_entry_text'] == null

View File

@ -12,7 +12,7 @@ class ReplyUpper {
ReplyUpper.fromJson(Map<String, dynamic> json) {
mid = json['mid'];
top = json['top'] != null
? ReplyItemModel.fromJson(json['top'])
? ReplyItemModel.fromJson(json['top'], json['mid'])
: ReplyItemModel();
}
}