mod: 纯文本回复折叠、replyType传值

This commit is contained in:
guozhigq
2023-07-22 23:31:05 +08:00
parent 90f05931f1
commit 499dff5646
5 changed files with 38 additions and 21 deletions

View File

@ -1,13 +1,15 @@
class ReplyContent {
ReplyContent(
{this.message,
ReplyContent({
this.message,
this.atNameToMid, // @的用户的mid null
this.memebers, // 被@的用户List 如果有的话 []
this.emote, // 表情包 如果有的话 null
this.jumpUrl, // {}
this.pictures, // {}
this.vote,
this.richText});
this.richText,
this.isText,
});
String? message;
Map? atNameToMid;
@ -17,6 +19,7 @@ class ReplyContent {
List? pictures;
Map? vote;
Map? richText;
bool? isText;
ReplyContent.fromJson(Map<String, dynamic> json) {
message = json['message']
@ -30,5 +33,10 @@ class ReplyContent {
pictures = json['pictures'] ?? [];
vote = json['vote'] ?? {};
richText = json['rich_text'] ?? {};
isText = emote!.isEmpty &&
atNameToMid!.isEmpty &&
jumpUrl!.isEmpty &&
vote!.isEmpty &&
pictures!.isEmpty;
}
}

View File

@ -5,6 +5,7 @@ import 'package:flutter/rendering.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/skeleton/video_reply.dart';
import 'package:pilipala/common/widgets/http_error.dart';
import 'package:pilipala/models/common/reply_type.dart';
import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/replyNew/index.dart';
@ -181,6 +182,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
replyLevel: replyLevel,
replyReply: (replyItem) =>
replyReply(replyItem),
replyType: ReplyType.video,
);
}
},
@ -233,12 +235,13 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
oid: IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
replyType: ReplyType.video,
);
},
).then(
(value) => {
// 完成评论,数据添加
if (value != null && value['data'])
if (value != null && value['data'] != null)
{_videoReplyController.replyList.add(value['data'])}
},
);

View File

@ -197,11 +197,14 @@ class ReplyItem extends StatelessWidget {
selectionControls: MaterialTextSelectionControls(),
child: Text.rich(
style: const TextStyle(height: 1.65),
maxLines:
replyItem!.content!.isText! && replyLevel == '1' ? 6 : 999,
overflow: TextOverflow.ellipsis,
TextSpan(
children: [
if (replyItem!.isTop!)
WidgetSpan(child: UpTag(tagText: 'TOP')),
buildContent(context, replyItem!.content!),
buildContent(context, replyItem!, replyReply),
],
),
),
@ -398,7 +401,7 @@ class ReplyItemRow extends StatelessWidget {
WidgetSpan(
child: UpTag(),
),
buildContent(context, replies![i].content),
buildContent(context, replies![i], replyReply),
],
),
),
@ -438,7 +441,8 @@ class ReplyItemRow extends StatelessWidget {
}
}
InlineSpan buildContent(BuildContext context, content) {
InlineSpan buildContent(BuildContext context, replyItem, replyReply) {
var content = replyItem.content;
if (content.emote.isEmpty &&
content.atNameToMid.isEmpty &&
content.jumpUrl.isEmpty &&
@ -446,7 +450,7 @@ InlineSpan buildContent(BuildContext context, content) {
content.pictures.isEmpty) {
return TextSpan(
text: content.message,
// recognizer: TapGestureRecognizer()..onTap = () => {print('点击')},
recognizer: TapGestureRecognizer()..onTap = () => replyReply(replyItem),
);
}
List<InlineSpan> spanChilds = [];

View File

@ -70,7 +70,7 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
Future submitReplyAdd() async {
String message = _replyContentController.text;
var result = await VideoHttp.replyAdd(
type: widget.replyType!,
type: widget.replyType ?? ReplyType.video,
oid: widget.oid!,
root: widget.root!,
parent: widget.parent!,

View File

@ -118,11 +118,13 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
SliverToBoxAdapter(
child: ReplyItem(
replyItem: widget.firstFloor,
replyLevel: '1',
replyLevel: '2',
showReplyRow: false,
addReply: (replyItem) {
_videoReplyReplyController.replyList.add(replyItem);
}),
},
replyType: ReplyType.video,
),
),
SliverToBoxAdapter(
child: Divider(