mod: 更多回复展示逻辑

This commit is contained in:
guozhigq
2023-05-26 16:20:40 +08:00
parent bbba3083bc
commit bd8cf24fff
5 changed files with 42 additions and 62 deletions

View File

@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/replyReply/index.dart';
class VideoDetailController extends GetxController {
int tabInitialIndex = 0;
@ -20,12 +22,14 @@ class VideoDetailController extends GetxController {
String heroTag = '';
RxInt oid = 0.obs;
int oid = 0;
// 评论id 请求楼中楼评论使用
RxInt fRpid = 0.obs;
int fRpid = 0;
ReplyItemModel? firstFloor;
final scaffoldKey = GlobalKey<ScaffoldState>();
@override
void onInit() {
super.onInit();
@ -40,4 +44,21 @@ class VideoDetailController extends GetxController {
heroTag = Get.arguments['heroTag'];
}
}
showReplyReplyPanel() {
PersistentBottomSheetController<void>? ctr = scaffoldKey.currentState?.showBottomSheet<void>((BuildContext context) {
return
VideoReplyReplyPanel(
oid: oid,
rpid: fRpid,
closePanel: ()=> {
fRpid = 0,
},
firstFloor: firstFloor,
);
});
ctr?.closed.then((value) {
fRpid = 0;
});
}
}

View File

@ -7,6 +7,7 @@ import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/controller.dart';
import 'package:pilipala/pages/video/detail/reply/index.dart';
import 'package:pilipala/pages/video/detail/replyNew/index.dart';
import 'package:pilipala/pages/video/detail/replyReply/index.dart';
import 'package:pilipala/utils/utils.dart';
class ReplyItem extends StatelessWidget {
@ -248,9 +249,7 @@ class ReplyItem extends StatelessWidget {
parent: replyItem!.rpid,
);
},
).then((value) => {
print('showModalBottomSheet')
});
).then((value) => {print('showModalBottomSheet')});
},
),
),
@ -285,13 +284,12 @@ class ReplyItem extends StatelessWidget {
// ignore: must_be_immutable
class ReplyItemRow extends StatelessWidget {
ReplyItemRow({
super.key,
this.replies,
this.replyControl,
this.f_rpid,
this.replyItem
});
ReplyItemRow(
{super.key,
this.replies,
this.replyControl,
this.f_rpid,
this.replyItem});
List? replies;
ReplyControl? replyControl;
int? f_rpid;
@ -392,13 +390,12 @@ class ReplyItemRow extends StatelessWidget {
void replyReply(replyItem) {
// replyItem 楼主评论
Get.find<VideoDetailController>(tag: Get.arguments['heroTag'])
.oid
.value = replies!.first.oid;
Get.find<VideoDetailController>(tag: Get.arguments['heroTag'])
.fRpid
.value = f_rpid!;
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']).firstFloor = replyItem;
VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
videoDetailCtr.oid = replies!.first.oid;
videoDetailCtr.fRpid = f_rpid!;
videoDetailCtr.firstFloor = replyItem;
videoDetailCtr.showReplyReplyPanel();
}
}

View File

@ -35,6 +35,9 @@ class VideoReplyReplyController extends GetxController {
}
Future queryReplyList({type = 'init'}) async {
if(type == 'init'){
currentPage = 0;
}
isLoadingMore = true;
var res = await ReplyHttp.replyReplyList(
oid: aid!, root: rpid!, pageNum: currentPage + 1, type: 1);

View File

@ -80,6 +80,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
_videoReplyReplyController.currentPage = 0;
_videoReplyReplyController.rPid = 0;
widget.closePanel!();
Navigator.pop(context);
},
),
],

View File

@ -19,29 +19,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
with TickerProviderStateMixin {
final VideoDetailController videoDetailController =
Get.put(VideoDetailController(), tag: Get.arguments['heroTag']);
late AnimationController replyAnimationCtl;
@override
void initState() {
super.initState();
replyAnimationCtl = AnimationController(
vsync: this, duration: const Duration(milliseconds: 300));
videoDetailController.fRpid.listen((p0) {
if (p0 != 0) {
showReplyReplyPanel();
}
});
}
showReplyReplyPanel() {
replyAnimationCtl.forward();
}
hiddenReplyReplyPanel() {
replyAnimationCtl.reverse().then((value) {
videoDetailController.fRpid.value = 0;
});
}
@override
@ -59,6 +40,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
child: Stack(
children: [
Scaffold(
key: videoDetailController.scaffoldKey,
body: ExtendedNestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
@ -163,30 +145,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
),
),
Positioned(
bottom: 0,
left: 0,
right: 0,
child: SlideTransition(
position: Tween<Offset>(
begin: const Offset(0, 2),
end: const Offset(0, 0),
).animate(CurvedAnimation(
parent: replyAnimationCtl,
curve: Curves.easeInOut,
)),
child: Obx(
() => videoDetailController.fRpid.value != 0
? VideoReplyReplyPanel(
oid: videoDetailController.oid.value,
rpid: videoDetailController.fRpid.value,
closePanel: hiddenReplyReplyPanel,
firstFloor: videoDetailController.firstFloor,
)
: const SizedBox(),
),
),
),
],
),
),