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 { class ReplyContent {
ReplyContent( ReplyContent({
{this.message, this.message,
this.atNameToMid, // @的用户的mid null this.atNameToMid, // @的用户的mid null
this.memebers, // 被@的用户List 如果有的话 [] this.memebers, // 被@的用户List 如果有的话 []
this.emote, // 表情包 如果有的话 null this.emote, // 表情包 如果有的话 null
this.jumpUrl, // {} this.jumpUrl, // {}
this.pictures, // {} this.pictures, // {}
this.vote, this.vote,
this.richText}); this.richText,
this.isText,
});
String? message; String? message;
Map? atNameToMid; Map? atNameToMid;
@ -17,6 +19,7 @@ class ReplyContent {
List? pictures; List? pictures;
Map? vote; Map? vote;
Map? richText; Map? richText;
bool? isText;
ReplyContent.fromJson(Map<String, dynamic> json) { ReplyContent.fromJson(Map<String, dynamic> json) {
message = json['message'] message = json['message']
@ -30,5 +33,10 @@ class ReplyContent {
pictures = json['pictures'] ?? []; pictures = json['pictures'] ?? [];
vote = json['vote'] ?? {}; vote = json['vote'] ?? {};
richText = json['rich_text'] ?? {}; 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:get/get.dart';
import 'package:pilipala/common/skeleton/video_reply.dart'; import 'package:pilipala/common/skeleton/video_reply.dart';
import 'package:pilipala/common/widgets/http_error.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/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/replyNew/index.dart'; import 'package:pilipala/pages/video/detail/replyNew/index.dart';
@ -181,6 +182,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
replyLevel: replyLevel, replyLevel: replyLevel,
replyReply: (replyItem) => replyReply: (replyItem) =>
replyReply(replyItem), replyReply(replyItem),
replyType: ReplyType.video,
); );
} }
}, },
@ -233,12 +235,13 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
oid: IdUtils.bv2av(Get.parameters['bvid']!), oid: IdUtils.bv2av(Get.parameters['bvid']!),
root: 0, root: 0,
parent: 0, parent: 0,
replyType: ReplyType.video,
); );
}, },
).then( ).then(
(value) => { (value) => {
// 完成评论,数据添加 // 完成评论,数据添加
if (value != null && value['data']) if (value != null && value['data'] != null)
{_videoReplyController.replyList.add(value['data'])} {_videoReplyController.replyList.add(value['data'])}
}, },
); );

View File

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

View File

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

View File

@ -117,12 +117,14 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
const SliverToBoxAdapter(child: SizedBox(height: 10)), const SliverToBoxAdapter(child: SizedBox(height: 10)),
SliverToBoxAdapter( SliverToBoxAdapter(
child: ReplyItem( child: ReplyItem(
replyItem: widget.firstFloor, replyItem: widget.firstFloor,
replyLevel: '1', replyLevel: '2',
showReplyRow: false, showReplyRow: false,
addReply: (replyItem) { addReply: (replyItem) {
_videoReplyReplyController.replyList.add(replyItem); _videoReplyReplyController.replyList.add(replyItem);
}), },
replyType: ReplyType.video,
),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
child: Divider( child: Divider(