From d5fbde70fa06fcd1503d942aafcfbe216041f240 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Thu, 5 Sep 2024 15:25:27 +0800 Subject: [PATCH] opt: save reply --- lib/common/widgets/list_sheet.dart | 4 +- lib/pages/rcmd/view.dart | 1 - lib/pages/video/detail/reply_reply/view.dart | 58 ++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/lib/common/widgets/list_sheet.dart b/lib/common/widgets/list_sheet.dart index d5c3b209..690acd93 100644 --- a/lib/common/widgets/list_sheet.dart +++ b/lib/common/widgets/list_sheet.dart @@ -1,3 +1,4 @@ +import 'package:PiliPalaX/common/constants.dart'; import 'package:PiliPalaX/common/widgets/network_img_layer.dart'; import 'package:PiliPalaX/models/bangumi/info.dart' as bangumi; import 'package:PiliPalaX/models/video_detail_res.dart' as video; @@ -130,6 +131,7 @@ class _ListSheetContentState extends State { borderRadius: BorderRadius.circular(6), border: Border.all( width: 1.8, + strokeAlign: BorderSide.strokeAlignOutside, color: Theme.of(context).colorScheme.primary, ), ) @@ -142,7 +144,7 @@ class _ListSheetContentState extends State { : episode is bangumi.EpisodeItem ? episode.cover : episode.firstFrame, - width: constraints.maxHeight * 16 / 9, + width: constraints.maxHeight * StyleString.aspectRatio, height: constraints.maxHeight, ), ), diff --git a/lib/pages/rcmd/view.dart b/lib/pages/rcmd/view.dart index 037778c6..e4f18ea8 100644 --- a/lib/pages/rcmd/view.dart +++ b/lib/pages/rcmd/view.dart @@ -8,7 +8,6 @@ import 'package:PiliPalaX/common/constants.dart'; import 'package:PiliPalaX/common/skeleton/video_card_v.dart'; import 'package:PiliPalaX/common/widgets/animated_dialog.dart'; import 'package:PiliPalaX/common/widgets/http_error.dart'; -import 'package:PiliPalaX/common/widgets/overlay_pop.dart'; import 'package:PiliPalaX/common/widgets/video_card_v.dart'; import 'package:PiliPalaX/pages/home/index.dart'; import 'package:PiliPalaX/pages/main/index.dart'; diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 475d0c6a..b9971c0f 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -1,3 +1,4 @@ +import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart'; import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -6,6 +7,7 @@ import 'package:PiliPalaX/common/widgets/http_error.dart'; import 'package:PiliPalaX/models/common/reply_type.dart'; import 'package:PiliPalaX/models/video/reply/item.dart'; import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item.dart'; +import 'package:get/get_navigation/src/dialog/dialog_route.dart'; import '../../../../utils/utils.dart'; import 'controller.dart'; @@ -34,6 +36,7 @@ class VideoReplyReplyPanel extends StatefulWidget { class _VideoReplyReplyPanelState extends State { late VideoReplyReplyController _videoReplyReplyController; Future? _futureBuilderFuture; + late final _savedReplies = {}; @override void initState() { @@ -126,6 +129,9 @@ class _VideoReplyReplyPanelState extends State { replyType: widget.replyType, replyReply: (replyItem) => replyReply(replyItem), needDivider: false, + onReply: () { + _onReply(widget.firstFloor); + }, ), ), SliverToBoxAdapter( @@ -160,6 +166,9 @@ class _VideoReplyReplyPanelState extends State { replyType: widget.replyType, replyReply: (replyItem) => replyReply(replyItem), + onReply: () { + _onReply(_videoReplyReplyController.root); + }, ), ), SliverToBoxAdapter( @@ -214,6 +223,10 @@ class _VideoReplyReplyPanelState extends State { .add(replyItem); }, replyType: widget.replyType, + onReply: () { + _onReply(_videoReplyReplyController + .replyList[index]); + }, ); } }, @@ -251,4 +264,49 @@ class _VideoReplyReplyPanelState extends State { ), ); } + + void _onReply(ReplyItemModel? item) { + dynamic oid = item?.oid; + dynamic root = item?.rpid; + dynamic parent = item?.rpid; + dynamic key = oid + root + parent; + Navigator.of(context) + .push( + GetDialogRoute( + pageBuilder: (buildContext, animation, secondaryAnimation) { + return ReplyPage( + oid: oid, + root: root, + parent: parent, + replyType: ReplyType.video, + replyItem: item, + savedReply: _savedReplies[key], + onSaveReply: (reply) { + _savedReplies[key] = reply; + }, + ); + }, + transitionDuration: const Duration(milliseconds: 500), + transitionBuilder: (context, animation, secondaryAnimation, child) { + const begin = Offset(0.0, 1.0); + const end = Offset.zero; + const curve = Curves.linear; + + var tween = + Tween(begin: begin, end: end).chain(CurveTween(curve: curve)); + + return SlideTransition( + position: animation.drive(tween), + child: child, + ); + }, + ), + ) + .then((value) { + // 完成评论,数据添加 + if (value != null && value['data'] != null) { + _savedReplies[key] = null; + } + }); + } }