opt: save reply

This commit is contained in:
bggRGjQaUbCoE
2024-09-05 15:25:27 +08:00
parent c1a95a4519
commit d5fbde70fa
3 changed files with 61 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/common/constants.dart';
import 'package:PiliPalaX/common/widgets/network_img_layer.dart'; import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
import 'package:PiliPalaX/models/bangumi/info.dart' as bangumi; import 'package:PiliPalaX/models/bangumi/info.dart' as bangumi;
import 'package:PiliPalaX/models/video_detail_res.dart' as video; import 'package:PiliPalaX/models/video_detail_res.dart' as video;
@@ -130,6 +131,7 @@ class _ListSheetContentState extends State<ListSheetContent> {
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
border: Border.all( border: Border.all(
width: 1.8, width: 1.8,
strokeAlign: BorderSide.strokeAlignOutside,
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
), ),
) )
@@ -142,7 +144,7 @@ class _ListSheetContentState extends State<ListSheetContent> {
: episode is bangumi.EpisodeItem : episode is bangumi.EpisodeItem
? episode.cover ? episode.cover
: episode.firstFrame, : episode.firstFrame,
width: constraints.maxHeight * 16 / 9, width: constraints.maxHeight * StyleString.aspectRatio,
height: constraints.maxHeight, height: constraints.maxHeight,
), ),
), ),

View File

@@ -8,7 +8,6 @@ import 'package:PiliPalaX/common/constants.dart';
import 'package:PiliPalaX/common/skeleton/video_card_v.dart'; import 'package:PiliPalaX/common/skeleton/video_card_v.dart';
import 'package:PiliPalaX/common/widgets/animated_dialog.dart'; import 'package:PiliPalaX/common/widgets/animated_dialog.dart';
import 'package:PiliPalaX/common/widgets/http_error.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/common/widgets/video_card_v.dart';
import 'package:PiliPalaX/pages/home/index.dart'; import 'package:PiliPalaX/pages/home/index.dart';
import 'package:PiliPalaX/pages/main/index.dart'; import 'package:PiliPalaX/pages/main/index.dart';

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
import 'package:easy_debounce/easy_throttle.dart'; import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.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/common/reply_type.dart';
import 'package:PiliPalaX/models/video/reply/item.dart'; import 'package:PiliPalaX/models/video/reply/item.dart';
import 'package:PiliPalaX/pages/video/detail/reply/widgets/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 '../../../../utils/utils.dart';
import 'controller.dart'; import 'controller.dart';
@@ -34,6 +36,7 @@ class VideoReplyReplyPanel extends StatefulWidget {
class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> { class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
late VideoReplyReplyController _videoReplyReplyController; late VideoReplyReplyController _videoReplyReplyController;
Future? _futureBuilderFuture; Future? _futureBuilderFuture;
late final _savedReplies = {};
@override @override
void initState() { void initState() {
@@ -126,6 +129,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
replyType: widget.replyType, replyType: widget.replyType,
replyReply: (replyItem) => replyReply(replyItem), replyReply: (replyItem) => replyReply(replyItem),
needDivider: false, needDivider: false,
onReply: () {
_onReply(widget.firstFloor);
},
), ),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
@@ -160,6 +166,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
replyType: widget.replyType, replyType: widget.replyType,
replyReply: (replyItem) => replyReply: (replyItem) =>
replyReply(replyItem), replyReply(replyItem),
onReply: () {
_onReply(_videoReplyReplyController.root);
},
), ),
), ),
SliverToBoxAdapter( SliverToBoxAdapter(
@@ -214,6 +223,10 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
.add(replyItem); .add(replyItem);
}, },
replyType: widget.replyType, replyType: widget.replyType,
onReply: () {
_onReply(_videoReplyReplyController
.replyList[index]);
},
); );
} }
}, },
@@ -251,4 +264,49 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
), ),
); );
} }
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;
}
});
}
} }