feat: custom grpc reply (#25)

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-29 22:03:02 +08:00
committed by GitHub
parent 9b9e28dcb8
commit be4dfd99c6
28 changed files with 637 additions and 400 deletions

View File

@@ -1,6 +1,7 @@
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
import 'package:PiliPalaX/http/loading_state.dart';
import 'package:PiliPalaX/pages/common/reply_controller.dart';
import 'package:PiliPalaX/utils/global_data.dart';
import 'package:get/get.dart';
import 'package:PiliPalaX/http/html.dart';
import 'package:PiliPalaX/http/reply.dart';
@@ -34,23 +35,22 @@ class DynamicDetailController extends ReplyController {
queryData();
}
// @override
// Future<LoadingState> customGetData() => ReplyHttp.replyList(
// isLogin: isLogin,
// oid: oid!,
// nextOffset: nextOffset,
// type: type!,
// sort: sortType.index,
// page: currentPage,
// );
@override
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
type: type ?? 1,
oid: oid!,
cursor: CursorReq(
next: cursor?.next ?? $fixnum.Int64(0),
mode: mode,
),
);
Future<LoadingState> customGetData() => GlobalData().grpcReply
? ReplyHttp.replyListGrpc(
type: type ?? 1,
oid: oid!,
cursor: CursorReq(
next: cursor?.next ?? $fixnum.Int64(0),
mode: mode,
),
)
: ReplyHttp.replyList(
isLogin: isLogin,
oid: oid!,
nextOffset: nextOffset,
type: type!,
sort: sortType.index,
page: currentPage,
);
}

View File

@@ -3,9 +3,12 @@ import 'dart:math';
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
import 'package:PiliPalaX/http/loading_state.dart';
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item.dart';
import 'package:PiliPalaX/pages/video/detail/reply/widgets/reply_item_grpc.dart';
import 'package:PiliPalaX/utils/extension.dart';
import 'package:PiliPalaX/utils/global_data.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:get/get.dart';
@@ -110,23 +113,25 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
// 查看二级评论
void replyReply(replyItem, id, isTop) {
int oid = replyItem.oid.toInt();
int rpid = replyItem.id.toInt()!;
Get.to(
() => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(title: Text('评论详情')),
body: VideoReplyReplyPanel(
id: id,
oid: oid,
rpid: rpid,
source: 'dynamic',
replyType: ReplyType.values[replyType],
firstFloor: replyItem,
isTop: isTop,
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
int oid = replyItem.oid.toInt();
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
Get.to(
() => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(title: Text('评论详情')),
body: VideoReplyReplyPanel(
id: id,
oid: oid,
rpid: rpid,
source: 'dynamic',
replyType: ReplyType.values[replyType],
firstFloor: replyItem,
isTop: isTop ?? false,
),
),
),
);
);
});
}
// 滑动事件监听
@@ -386,23 +391,40 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
),
);
} else {
return ReplyItemGrpc(
replyItem: loadingState.response.replies[index],
showReplyRow: true,
replyLevel: '1',
replyReply: replyReply,
replyType: ReplyType.values[replyType],
onReply: () {
_dynamicDetailController.onReply(
context,
replyItem: loadingState.response.replies[index],
index: index,
);
},
onDelete: _dynamicDetailController.onMDelete,
isTop: _dynamicDetailController.hasUpTop && index == 0,
upMid: loadingState.response.subjectControl.upMid,
);
return GlobalData().grpcReply
? ReplyItemGrpc(
replyItem: loadingState.response.replies[index],
showReplyRow: true,
replyLevel: '1',
replyReply: replyReply,
replyType: ReplyType.values[replyType],
onReply: () {
_dynamicDetailController.onReply(
context,
replyItem: loadingState.response.replies[index],
index: index,
);
},
onDelete: _dynamicDetailController.onMDelete,
isTop:
_dynamicDetailController.hasUpTop && index == 0,
upMid: loadingState.response.subjectControl.upMid,
)
: ReplyItem(
replyItem: loadingState.response.replies[index],
showReplyRow: true,
replyLevel: '1',
replyReply: replyReply,
replyType: ReplyType.values[replyType],
onReply: () {
_dynamicDetailController.onReply(
context,
replyItem: loadingState.response.replies[index],
index: index,
);
},
onDelete: _dynamicDetailController.onMDelete,
);
}
},
childCount: loadingState.response.replies.length + 1,