refa: query data (#659)

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
dom
2025-04-10 21:43:01 +08:00
committed by GitHub
parent 99b19e7b03
commit e1b73f4766
128 changed files with 1493 additions and 1987 deletions

View File

@@ -13,7 +13,7 @@ import 'package:PiliPlus/http/html.dart';
import 'package:PiliPlus/http/reply.dart';
import 'package:fixnum/fixnum.dart' as $fixnum;
class HtmlRenderController extends ReplyController {
class HtmlRenderController extends ReplyController<MainListReply> {
late String id;
late String dynamicType;
late int type;
@@ -91,7 +91,12 @@ class HtmlRenderController extends ReplyController {
}
@override
Future<LoadingState> customGetData() {
List<ReplyInfo>? getDataList(MainListReply response) {
return response.replies;
}
@override
Future<LoadingState<MainListReply>> customGetData() {
return ReplyHttp.replyListGrpc(
type: type,
oid: oid.value,

View File

@@ -763,7 +763,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
);
}
Widget replyList(LoadingState loadingState) {
Widget replyList(LoadingState<List<ReplyInfo>?> loadingState) {
return switch (loadingState) {
Loading() => SliverList.builder(
itemCount: 5,
@@ -771,11 +771,11 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
return const VideoReplySkeleton();
},
),
Success() => (loadingState.response.replies as List?)?.isNotEmpty == true
Success() => loadingState.response?.isNotEmpty == true
? SliverList.builder(
itemCount: loadingState.response.replies.length + 1,
itemCount: loadingState.response!.length + 1,
itemBuilder: (context, index) {
if (index == loadingState.response.replies.length) {
if (index == loadingState.response!.length) {
_htmlRenderCtr.onLoadMore();
return Container(
alignment: Alignment.center,
@@ -785,7 +785,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
child: Text(
_htmlRenderCtr.isEnd.not
? '加载中...'
: loadingState.response.replies.isEmpty
: loadingState.response!.isEmpty
? '还没有评论'
: '没有更多了',
style: TextStyle(
@@ -796,19 +796,20 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response.replies[index],
replyItem: loadingState.response![index],
replyLevel: '1',
replyReply: (replyItem, id) =>
replyReply(context, replyItem, id),
onReply: () {
_htmlRenderCtr.onReply(
context,
replyItem: loadingState.response.replies[index],
replyItem: loadingState.response![index],
index: index,
);
},
onDelete: _htmlRenderCtr.onMDelete,
upMid: loadingState.response.subjectControl.upMid,
onDelete: (subIndex) =>
_htmlRenderCtr.onRemove(index, subIndex),
upMid: _htmlRenderCtr.upMid,
callback: _getImageCallback,
onCheckReply: (item) =>
_htmlRenderCtr.onCheckReply(context, item),