diff --git a/lib/models/video/reply/content.dart b/lib/models/video/reply/content.dart index 7fcea857..68b59768 100644 --- a/lib/models/video/reply/content.dart +++ b/lib/models/video/reply/content.dart @@ -1,13 +1,15 @@ class ReplyContent { - ReplyContent( - {this.message, - this.atNameToMid, // @的用户的mid null - this.memebers, // 被@的用户List 如果有的话 [] - this.emote, // 表情包 如果有的话 null - this.jumpUrl, // {} - this.pictures, // {} - this.vote, - this.richText}); + ReplyContent({ + this.message, + this.atNameToMid, // @的用户的mid null + this.memebers, // 被@的用户List 如果有的话 [] + this.emote, // 表情包 如果有的话 null + this.jumpUrl, // {} + this.pictures, // {} + this.vote, + 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 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; } } diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 00e0ffc2..506e0f66 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -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 replyLevel: replyLevel, replyReply: (replyItem) => replyReply(replyItem), + replyType: ReplyType.video, ); } }, @@ -233,12 +235,13 @@ class _VideoReplyPanelState extends State 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'])} }, ); diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 0ffce7d3..e690effc 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -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 spanChilds = []; diff --git a/lib/pages/video/detail/replyNew/view.dart b/lib/pages/video/detail/replyNew/view.dart index 7faeb596..60fe93d0 100644 --- a/lib/pages/video/detail/replyNew/view.dart +++ b/lib/pages/video/detail/replyNew/view.dart @@ -70,7 +70,7 @@ class _VideoReplyNewDialogState extends State 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!, diff --git a/lib/pages/video/detail/replyReply/view.dart b/lib/pages/video/detail/replyReply/view.dart index 5f3034c9..5c3f99c1 100644 --- a/lib/pages/video/detail/replyReply/view.dart +++ b/lib/pages/video/detail/replyReply/view.dart @@ -117,12 +117,14 @@ class _VideoReplyReplyPanelState extends State { const SliverToBoxAdapter(child: SizedBox(height: 10)), SliverToBoxAdapter( child: ReplyItem( - replyItem: widget.firstFloor, - replyLevel: '1', - showReplyRow: false, - addReply: (replyItem) { - _videoReplyReplyController.replyList.add(replyItem); - }), + replyItem: widget.firstFloor, + replyLevel: '2', + showReplyRow: false, + addReply: (replyItem) { + _videoReplyReplyController.replyList.add(replyItem); + }, + replyType: ReplyType.video, + ), ), SliverToBoxAdapter( child: Divider(