mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: reply page
This commit is contained in:
@@ -37,6 +37,8 @@ class VideoReplyController extends GetxController {
|
|||||||
|
|
||||||
Box setting = GStorage.setting;
|
Box setting = GStorage.setting;
|
||||||
|
|
||||||
|
Future? futureBuilderFuture;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -98,6 +100,7 @@ class VideoReplyController extends GetxController {
|
|||||||
replyList.addAll(replies);
|
replyList.addAll(replies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上拉加载
|
// 上拉加载
|
||||||
|
|||||||
@@ -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: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';
|
||||||
@@ -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.isLoadingMore &&
|
||||||
_videoReplyController.replyList.isEmpty &&
|
_videoReplyController.replyList.isEmpty
|
||||||
(_videoReplyController.noMore.value == '' ||
|
|
||||||
_videoReplyController.noMore.value == '加载中...')
|
|
||||||
? SliverList(
|
? SliverList(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(BuildContext context, index) {
|
(BuildContext context, index) {
|
||||||
@@ -197,14 +203,17 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
double bottom =
|
double bottom =
|
||||||
MediaQuery.of(context).padding.bottom;
|
MediaQuery.of(context).padding.bottom;
|
||||||
if (index ==
|
if (index ==
|
||||||
_videoReplyController.replyList.length) {
|
_videoReplyController
|
||||||
|
.replyList.length) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(bottom: bottom),
|
padding:
|
||||||
|
EdgeInsets.only(bottom: bottom),
|
||||||
height: bottom + 100,
|
height: bottom + 100,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => Text(
|
() => Text(
|
||||||
_videoReplyController.noMore.value,
|
_videoReplyController
|
||||||
|
.noMore.value,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
@@ -217,8 +226,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return ReplyItem(
|
return ReplyItem(
|
||||||
replyItem:
|
replyItem: _videoReplyController
|
||||||
_videoReplyController.replyList[index],
|
.replyList[index],
|
||||||
showReplyRow: true,
|
showReplyRow: true,
|
||||||
replyLevel: replyLevel,
|
replyLevel: replyLevel,
|
||||||
replyReply: (replyItem) =>
|
replyReply: (replyItem) =>
|
||||||
@@ -235,35 +244,43 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.push(
|
.push(
|
||||||
GetDialogRoute(
|
GetDialogRoute(
|
||||||
pageBuilder: (buildContext, animation,
|
pageBuilder: (buildContext,
|
||||||
|
animation,
|
||||||
secondaryAnimation) {
|
secondaryAnimation) {
|
||||||
return ReplyPage(
|
return ReplyPage(
|
||||||
oid: oid,
|
oid: oid,
|
||||||
root: root,
|
root: root,
|
||||||
parent: parent,
|
parent: parent,
|
||||||
replyType: ReplyType.video,
|
replyType: ReplyType.video,
|
||||||
replyItem: _videoReplyController
|
replyItem:
|
||||||
|
_videoReplyController
|
||||||
.replyList[index],
|
.replyList[index],
|
||||||
savedReply: _savedReplies[key],
|
savedReply:
|
||||||
|
_savedReplies[key],
|
||||||
onSaveReply: (reply) {
|
onSaveReply: (reply) {
|
||||||
_savedReplies[key] = reply;
|
_savedReplies[key] = reply;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
transitionDuration:
|
transitionDuration:
|
||||||
const Duration(milliseconds: 500),
|
const Duration(
|
||||||
transitionBuilder: (context, animation,
|
milliseconds: 500),
|
||||||
secondaryAnimation, child) {
|
transitionBuilder: (context,
|
||||||
|
animation,
|
||||||
|
secondaryAnimation,
|
||||||
|
child) {
|
||||||
const begin = Offset(0.0, 1.0);
|
const begin = Offset(0.0, 1.0);
|
||||||
const end = Offset.zero;
|
const end = Offset.zero;
|
||||||
const curve = Curves.linear;
|
const curve = Curves.linear;
|
||||||
|
|
||||||
var tween = Tween(
|
var tween = Tween(
|
||||||
begin: begin, end: end)
|
begin: begin, end: end)
|
||||||
.chain(CurveTween(curve: curve));
|
.chain(CurveTween(
|
||||||
|
curve: curve));
|
||||||
|
|
||||||
return SlideTransition(
|
return SlideTransition(
|
||||||
position: animation.drive(tween),
|
position:
|
||||||
|
animation.drive(tween),
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -278,19 +295,23 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onDelete: (rpid, frpid) {
|
onDelete: (rpid, frpid) {
|
||||||
|
_videoReplyController.replyList.value =
|
||||||
frpid == null
|
frpid == null
|
||||||
? _videoReplyController.replyList.value =
|
? _videoReplyController
|
||||||
_videoReplyController.replyList
|
.replyList
|
||||||
.where(
|
.where((item) =>
|
||||||
(item) => item.rpid != rpid)
|
item.rpid != rpid)
|
||||||
.toList()
|
.toList()
|
||||||
: _videoReplyController.replyList
|
: _videoReplyController
|
||||||
|
.replyList
|
||||||
.map((item) {
|
.map((item) {
|
||||||
if (item.rpid == frpid) {
|
if (item.rpid == frpid) {
|
||||||
return item
|
return item
|
||||||
..replies = item.replies
|
..replies = item
|
||||||
|
.replies
|
||||||
?.where((reply) =>
|
?.where((reply) =>
|
||||||
reply.rpid != rpid)
|
reply.rpid !=
|
||||||
|
rpid)
|
||||||
.toList();
|
.toList();
|
||||||
} else {
|
} else {
|
||||||
return item;
|
return item;
|
||||||
@@ -301,9 +322,33 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
childCount:
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
// 获取视频资源,初始化播放器
|
// 获取视频资源,初始化播放器
|
||||||
Future<void> videoSourceInit() async {
|
Future<void> videoSourceInit() async {
|
||||||
_futureBuilderFuture = videoDetailController.queryVideoUrl();
|
_futureBuilderFuture = videoDetailController.queryVideoUrl();
|
||||||
|
_videoReplyController.futureBuilderFuture =
|
||||||
_videoReplyController.queryReplyList(type: 'init');
|
_videoReplyController.queryReplyList(type: 'init');
|
||||||
if (videoDetailController.autoPlay.value) {
|
if (videoDetailController.autoPlay.value) {
|
||||||
plPlayerController = videoDetailController.plPlayerController;
|
plPlayerController = videoDetailController.plPlayerController;
|
||||||
|
|||||||
Reference in New Issue
Block a user