opt: reply page

This commit is contained in:
bggRGjQaUbCoE
2024-09-06 11:36:03 +08:00
parent c37f6835f8
commit 6029d409e7
3 changed files with 171 additions and 122 deletions

View File

@@ -37,6 +37,8 @@ class VideoReplyController extends GetxController {
Box setting = GStorage.setting;
Future? futureBuilderFuture;
@override
void onInit() {
super.onInit();
@@ -98,6 +100,7 @@ class VideoReplyController extends GetxController {
replyList.addAll(replies);
}
}
return res;
}
// 上拉加载

View File

@@ -1,3 +1,4 @@
import 'package:PiliPalaX/common/widgets/http_error.dart';
import 'package:PiliPalaX/pages/video/detail/reply_new/reply_page.dart';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
@@ -180,11 +181,16 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
),
),
),
Obx(
FutureBuilder(
future: _videoReplyController.futureBuilderFuture,
builder: (BuildContext context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
var data = snapshot.data;
if (data['status']) {
// 请求成功
return Obx(
() => _videoReplyController.isLoadingMore &&
_videoReplyController.replyList.isEmpty &&
(_videoReplyController.noMore.value == '' ||
_videoReplyController.noMore.value == '加载中...')
_videoReplyController.replyList.isEmpty
? SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
@@ -197,14 +203,17 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
double bottom =
MediaQuery.of(context).padding.bottom;
if (index ==
_videoReplyController.replyList.length) {
_videoReplyController
.replyList.length) {
return Container(
padding: EdgeInsets.only(bottom: bottom),
padding:
EdgeInsets.only(bottom: bottom),
height: bottom + 100,
child: Center(
child: Obx(
() => Text(
_videoReplyController.noMore.value,
_videoReplyController
.noMore.value,
style: TextStyle(
fontSize: 12,
color: Theme.of(context)
@@ -217,8 +226,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
);
} else {
return ReplyItem(
replyItem:
_videoReplyController.replyList[index],
replyItem: _videoReplyController
.replyList[index],
showReplyRow: true,
replyLevel: replyLevel,
replyReply: (replyItem) =>
@@ -235,35 +244,43 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
Navigator.of(context)
.push(
GetDialogRoute(
pageBuilder: (buildContext, animation,
pageBuilder: (buildContext,
animation,
secondaryAnimation) {
return ReplyPage(
oid: oid,
root: root,
parent: parent,
replyType: ReplyType.video,
replyItem: _videoReplyController
replyItem:
_videoReplyController
.replyList[index],
savedReply: _savedReplies[key],
savedReply:
_savedReplies[key],
onSaveReply: (reply) {
_savedReplies[key] = reply;
},
);
},
transitionDuration:
const Duration(milliseconds: 500),
transitionBuilder: (context, animation,
secondaryAnimation, child) {
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));
.chain(CurveTween(
curve: curve));
return SlideTransition(
position: animation.drive(tween),
position:
animation.drive(tween),
child: child,
);
},
@@ -278,19 +295,23 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
});
},
onDelete: (rpid, frpid) {
_videoReplyController.replyList.value =
frpid == null
? _videoReplyController.replyList.value =
_videoReplyController.replyList
.where(
(item) => item.rpid != rpid)
? _videoReplyController
.replyList
.where((item) =>
item.rpid != rpid)
.toList()
: _videoReplyController.replyList
: _videoReplyController
.replyList
.map((item) {
if (item.rpid == frpid) {
return item
..replies = item.replies
..replies = item
.replies
?.where((reply) =>
reply.rpid != rpid)
reply.rpid !=
rpid)
.toList();
} else {
return item;
@@ -301,9 +322,33 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
}
},
childCount:
_videoReplyController.replyList.length + 1,
_videoReplyController.replyList.length +
1,
),
),
);
} else {
// 请求错误
return HttpError(
errMsg: data['msg'],
fn: () {
setState(() {
_videoReplyController.futureBuilderFuture =
_videoReplyController.queryReplyList();
});
},
);
}
} else {
// 骨架屏
return SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, index) {
return const VideoReplySkeleton();
}, childCount: 5),
);
}
},
),
],
),

View File

@@ -148,6 +148,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
// 获取视频资源,初始化播放器
Future<void> videoSourceInit() async {
_futureBuilderFuture = videoDetailController.queryVideoUrl();
_videoReplyController.futureBuilderFuture =
_videoReplyController.queryReplyList(type: 'init');
if (videoDetailController.autoPlay.value) {
plPlayerController = videoDetailController.plPlayerController;