mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
refa: query data (#659)
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -7,7 +7,7 @@ import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get_state_manager/src/rx_flutter/rx_ticket_provider_mixin.dart';
|
||||
|
||||
class VideoReplyController extends ReplyController
|
||||
class VideoReplyController extends ReplyController<MainListReply>
|
||||
with GetTickerProviderStateMixin {
|
||||
VideoReplyController({required this.aid});
|
||||
// 视频aid 请求时使用的oid
|
||||
@@ -36,7 +36,13 @@ class VideoReplyController extends ReplyController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
|
||||
List<ReplyInfo>? getDataList(MainListReply response) {
|
||||
return response.replies;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<MainListReply>> customGetData() =>
|
||||
ReplyHttp.replyListGrpc(
|
||||
oid: aid,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
|
||||
@@ -45,7 +45,7 @@ class VideoReplyPanel extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
with AutomaticKeepAliveClientMixin, TickerProviderStateMixin {
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
late VideoReplyController _videoReplyController;
|
||||
|
||||
String get heroTag => widget.heroTag;
|
||||
@@ -202,12 +202,12 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
childCount: 5,
|
||||
),
|
||||
),
|
||||
Success() => (loadingState.response.replies as List?)?.isNotEmpty == true
|
||||
Success() => loadingState.response?.isNotEmpty == true
|
||||
? SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, index) {
|
||||
double bottom = MediaQuery.of(context).padding.bottom;
|
||||
if (index == loadingState.response.replies.length) {
|
||||
if (index == loadingState.response.length) {
|
||||
_videoReplyController.onLoadMore();
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
@@ -216,7 +216,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
child: Text(
|
||||
_videoReplyController.isEnd.not
|
||||
? '加载中...'
|
||||
: loadingState.response.replies.isEmpty
|
||||
: loadingState.response.isEmpty
|
||||
? '还没有评论'
|
||||
: '没有更多了',
|
||||
style: TextStyle(
|
||||
@@ -227,18 +227,19 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
);
|
||||
} else {
|
||||
return ReplyItemGrpc(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
replyItem: loadingState.response[index],
|
||||
replyLevel: widget.replyLevel,
|
||||
replyReply: widget.replyReply,
|
||||
onReply: () {
|
||||
_videoReplyController.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
replyItem: loadingState.response[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _videoReplyController.onMDelete,
|
||||
upMid: loadingState.response.subjectControl.upMid,
|
||||
onDelete: (subIndex) =>
|
||||
_videoReplyController.onRemove(index, subIndex),
|
||||
upMid: _videoReplyController.upMid,
|
||||
getTag: () => heroTag,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
@@ -256,7 +257,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
);
|
||||
}
|
||||
},
|
||||
childCount: loadingState.response.replies.length + 1,
|
||||
childCount: loadingState.response.length + 1,
|
||||
),
|
||||
)
|
||||
: HttpError(
|
||||
|
||||
@@ -49,7 +49,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
final Function(ReplyInfo replyItem, int? rpid)? replyReply;
|
||||
final bool needDivider;
|
||||
final VoidCallback? onReply;
|
||||
final Function(dynamic rpid, dynamic frpid)? onDelete;
|
||||
final ValueChanged<int?>? onDelete;
|
||||
final dynamic upMid;
|
||||
final VoidCallback? showDialogue;
|
||||
final Function? getTag;
|
||||
@@ -88,8 +88,8 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
return morePanel(
|
||||
context: context,
|
||||
item: replyItem,
|
||||
onDelete: (rpid) {
|
||||
onDelete?.call(rpid, null);
|
||||
onDelete: () {
|
||||
onDelete?.call(null);
|
||||
},
|
||||
isSubReply: false,
|
||||
);
|
||||
@@ -549,8 +549,8 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
return morePanel(
|
||||
context: context,
|
||||
item: replyItem.replies[i],
|
||||
onDelete: (rpid) {
|
||||
onDelete?.call(rpid, replyItem.id.toInt());
|
||||
onDelete: () {
|
||||
onDelete?.call(i);
|
||||
},
|
||||
isSubReply: true,
|
||||
);
|
||||
@@ -1116,7 +1116,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
Options(contentType: Headers.formUrlEncodedContentType),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
onDelete?.call(item.id.toInt());
|
||||
onDelete?.call();
|
||||
}
|
||||
return res.data as Map;
|
||||
},
|
||||
@@ -1199,7 +1199,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
SmartDialog.dismiss();
|
||||
if (result['status']) {
|
||||
SmartDialog.showToast('删除成功');
|
||||
onDelete?.call(item.id.toInt());
|
||||
onDelete?.call();
|
||||
} else {
|
||||
SmartDialog.showToast('删除失败, ${result["msg"]}');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user