mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom grpc reply (#25)
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/models/common/reply_type.dart';
|
||||
import 'package:PiliPalaX/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPalaX/http/reply.dart';
|
||||
import 'package:PiliPalaX/utils/global_data.dart';
|
||||
import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||
|
||||
class VideoReplyController extends ReplyController {
|
||||
@@ -18,11 +20,20 @@ class VideoReplyController extends ReplyController {
|
||||
String? rpid;
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
|
||||
oid: aid!,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode,
|
||||
),
|
||||
);
|
||||
Future<LoadingState> customGetData() => GlobalData().grpcReply
|
||||
? ReplyHttp.replyListGrpc(
|
||||
oid: aid!,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode,
|
||||
),
|
||||
)
|
||||
: ReplyHttp.replyList(
|
||||
isLogin: isLogin,
|
||||
oid: aid!,
|
||||
nextOffset: nextOffset,
|
||||
type: ReplyType.video.index,
|
||||
sort: sortType.index,
|
||||
page: currentPage,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPalaX/common/widgets/http_error.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:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -228,24 +230,43 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ReplyItemGrpc(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: replyLevel,
|
||||
replyReply: widget.replyReply,
|
||||
replyType: ReplyType.video,
|
||||
onReply: () {
|
||||
_videoReplyController.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _videoReplyController.onMDelete,
|
||||
isTop: _videoReplyController.hasUpTop && index == 0,
|
||||
upMid: loadingState.response.subjectControl.upMid,
|
||||
getTag: () => heroTag,
|
||||
);
|
||||
return GlobalData().grpcReply
|
||||
? ReplyItemGrpc(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: replyLevel,
|
||||
replyReply: widget.replyReply,
|
||||
replyType: ReplyType.video,
|
||||
onReply: () {
|
||||
_videoReplyController.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _videoReplyController.onMDelete,
|
||||
isTop: _videoReplyController.hasUpTop && index == 0,
|
||||
upMid: loadingState.response.subjectControl.upMid,
|
||||
getTag: () => heroTag,
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: replyLevel,
|
||||
replyReply: widget.replyReply,
|
||||
replyType: ReplyType.video,
|
||||
onReply: () {
|
||||
_videoReplyController.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _videoReplyController.onMDelete,
|
||||
// isTop: _videoReplyController.hasUpTop && index == 0,
|
||||
// upMid: loadingState.response.subjectControl.upMid,
|
||||
// getTag: () => heroTag,
|
||||
);
|
||||
}
|
||||
},
|
||||
childCount: loadingState.response.replies.length + 1,
|
||||
@@ -256,7 +277,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
callback: _videoReplyController.onReload,
|
||||
),
|
||||
Error() => HttpError(
|
||||
errMsg: loadingState.errMsg,
|
||||
errMsg:
|
||||
'如无法加载评论:\n1.关闭代理\n2.设置中关闭使用gRPC加载评论\n\n${loadingState.errMsg}',
|
||||
callback: _videoReplyController.onReload,
|
||||
),
|
||||
LoadingState() => throw UnimplementedError(),
|
||||
|
||||
@@ -48,7 +48,7 @@ class ReplyItem extends StatelessWidget {
|
||||
// 点击整个评论区 评论详情/回复
|
||||
onTap: () {
|
||||
feedBack();
|
||||
replyReply?.call(replyItem);
|
||||
replyReply?.call(replyItem, null, null);
|
||||
},
|
||||
onLongPress: () {
|
||||
feedBack();
|
||||
@@ -425,7 +425,7 @@ class ReplyItemRow extends StatelessWidget {
|
||||
for (int i = 0; i < replies!.length; i++) ...[
|
||||
InkWell(
|
||||
// 一楼点击评论展开评论详情
|
||||
onTap: () => replyReply?.call(replyItem),
|
||||
onTap: () => replyReply?.call(replyItem, null, null),
|
||||
onLongPress: () {
|
||||
feedBack();
|
||||
showModalBottomSheet(
|
||||
@@ -525,7 +525,7 @@ class ReplyItemRow extends StatelessWidget {
|
||||
if (extraRow == 1)
|
||||
InkWell(
|
||||
// 一楼点击【共xx条回复】展开评论详情
|
||||
onTap: () => replyReply?.call(replyItem),
|
||||
onTap: () => replyReply?.call(replyItem, null, null),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.fromLTRB(8, 5, 8, 8),
|
||||
|
||||
@@ -2,9 +2,8 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart'
|
||||
as reply;
|
||||
import 'package:PiliPalaX/http/msg.dart';
|
||||
import 'package:PiliPalaX/utils/global_data.dart';
|
||||
import 'package:chat_bottom_container/chat_bottom_container.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -26,7 +25,7 @@ class ReplyPage extends StatefulWidget {
|
||||
final int? root;
|
||||
final int? parent;
|
||||
final ReplyType? replyType;
|
||||
final reply.ReplyInfo? replyItem;
|
||||
final dynamic replyItem;
|
||||
final String? savedReply;
|
||||
final Function(String reply)? onSaveReply;
|
||||
|
||||
@@ -507,8 +506,8 @@ class _ReplyPageState extends State<ReplyPage>
|
||||
oid: widget.oid!,
|
||||
root: widget.root!,
|
||||
parent: widget.parent!,
|
||||
message: widget.replyItem != null && widget.replyItem!.root != 0
|
||||
? ' 回复 @${widget.replyItem!.member.name} : $message'
|
||||
message: widget.replyItem != null && widget.replyItem.root != 0
|
||||
? ' 回复 @${GlobalData().grpcReply ? widget.replyItem.member.name : widget.replyItem.member.uname} : $message'
|
||||
: message,
|
||||
pictures: pictures,
|
||||
);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPalaX/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/models/video/reply/item.dart';
|
||||
import 'package:PiliPalaX/pages/common/common_controller.dart';
|
||||
import 'package:PiliPalaX/utils/global_data.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/http/reply.dart';
|
||||
@@ -29,8 +31,6 @@ class VideoReplyReplyController extends CommonController
|
||||
// rpid 请求楼中楼回复
|
||||
int? rpid;
|
||||
ReplyType replyType; // = ReplyType.video;
|
||||
// 当前回复的回复
|
||||
ReplyInfo? currentReplyItem;
|
||||
|
||||
CursorReply? cursor;
|
||||
Rx<Mode> mode = Mode.MAIN_LIST_TIME.obs;
|
||||
@@ -41,7 +41,7 @@ class VideoReplyReplyController extends CommonController
|
||||
AnimationController? controller;
|
||||
Animation<Color?>? colorAnimation;
|
||||
|
||||
ReplyInfo? firstFloor;
|
||||
dynamic firstFloor;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -49,34 +49,6 @@ class VideoReplyReplyController extends CommonController
|
||||
queryData();
|
||||
}
|
||||
|
||||
// @override
|
||||
// bool customHandleResponse(Success response) {
|
||||
// if (response.response.root != null) root = response.response.root;
|
||||
// List<ReplyItemModel> replies = response.response.replies;
|
||||
// if (replies.isNotEmpty) {
|
||||
// noMore.value = '加载中...';
|
||||
// if (replies.length == response.response.page.count) {
|
||||
// noMore.value = '没有更多了';
|
||||
// }
|
||||
// } else {
|
||||
// // 未登录状态replies可能返回null
|
||||
// noMore.value = currentPage == 1 ? '还没有评论' : '没有更多了';
|
||||
// }
|
||||
// if (currentPage != 1) {
|
||||
// List<ReplyItemModel> list = loadingState.value is Success
|
||||
// ? (loadingState.value as Success).response
|
||||
// : <ReplyItemModel>[];
|
||||
// // 每次回复之后,翻页请求有且只有相同的一条回复数据
|
||||
// if (replies.length == 1 && replies.last.rpid == list.last.rpid) {
|
||||
// return true;
|
||||
// } else {
|
||||
// replies.insertAll(0, list);
|
||||
// }
|
||||
// }
|
||||
// loadingState.value = LoadingState.success(replies);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
@override
|
||||
Future queryData([bool isRefresh = true]) async {
|
||||
if (!isDialogue &&
|
||||
@@ -95,14 +67,6 @@ class VideoReplyReplyController extends CommonController
|
||||
return super.queryData(isRefresh);
|
||||
}
|
||||
|
||||
// @override
|
||||
// Future<LoadingState> customGetData() => ReplyHttp.replyReplyList(
|
||||
// oid: aid!,
|
||||
// root: rpid!,
|
||||
// pageNum: currentPage,
|
||||
// type: replyType.index,
|
||||
// );
|
||||
|
||||
@override
|
||||
Future onRefresh() {
|
||||
cursor = null;
|
||||
@@ -111,61 +75,89 @@ class VideoReplyReplyController extends CommonController
|
||||
|
||||
@override
|
||||
bool customHandleResponse(Success response) {
|
||||
dynamic replies = response.response;
|
||||
if (replies is DetailListReply && cursor == null) {
|
||||
count.value = replies.root.count.toInt();
|
||||
if (id != null) {
|
||||
index = replies.root.replies
|
||||
.map((item) => item.id.toInt())
|
||||
.toList()
|
||||
.indexOf(id!);
|
||||
if (index != -1) {
|
||||
controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
);
|
||||
colorAnimation = ColorTween(
|
||||
begin: Theme.of(Get.context!).colorScheme.onInverseSurface,
|
||||
end: Theme.of(Get.context!).colorScheme.surface,
|
||||
).animate(controller!);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
itemScrollCtr.jumpTo(
|
||||
index: hasRoot ? index! + 3 : index! + 1,
|
||||
alignment: 0.25,
|
||||
if (GlobalData().grpcReply) {
|
||||
dynamic replies = response.response;
|
||||
if (replies is DetailListReply && cursor == null) {
|
||||
count.value = replies.root.count.toInt();
|
||||
if (id != null) {
|
||||
index = replies.root.replies
|
||||
.map((item) => item.id.toInt())
|
||||
.toList()
|
||||
.indexOf(id!);
|
||||
if (index != -1) {
|
||||
controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
);
|
||||
await Future.delayed(const Duration(milliseconds: 800));
|
||||
await controller?.forward();
|
||||
index = null;
|
||||
});
|
||||
colorAnimation = ColorTween(
|
||||
begin: Theme.of(Get.context!).colorScheme.onInverseSurface,
|
||||
end: Theme.of(Get.context!).colorScheme.surface,
|
||||
).animate(controller!);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
itemScrollCtr.jumpTo(
|
||||
index: hasRoot ? index! + 3 : index! + 1,
|
||||
alignment: 0.25,
|
||||
);
|
||||
await Future.delayed(const Duration(milliseconds: 800));
|
||||
await controller?.forward();
|
||||
index = null;
|
||||
});
|
||||
}
|
||||
id = null;
|
||||
}
|
||||
id = null;
|
||||
}
|
||||
}
|
||||
upMid ??= replies.subjectControl.upMid.toInt();
|
||||
cursor = replies.cursor;
|
||||
if (currentPage != 1) {
|
||||
List<ReplyInfo> list = loadingState.value is Success
|
||||
? (loadingState.value as Success).response
|
||||
: <ReplyInfo>[];
|
||||
upMid ??= replies.subjectControl.upMid.toInt();
|
||||
cursor = replies.cursor;
|
||||
if (isDialogue) {
|
||||
replies.replies.insertAll(0, list);
|
||||
if (replies.replies.isEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
} else {
|
||||
replies.root.replies.insertAll(0, list);
|
||||
if (replies.root.replies.isEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
if (currentPage != 1) {
|
||||
List<ReplyInfo> list = loadingState.value is Success
|
||||
? (loadingState.value as Success).response
|
||||
: <ReplyInfo>[];
|
||||
if (isDialogue) {
|
||||
replies.replies.insertAll(0, list);
|
||||
} else {
|
||||
replies.root.replies.insertAll(0, list);
|
||||
}
|
||||
}
|
||||
if (isDialogue) {
|
||||
if (replies.cursor.isEnd || replies.replies.length >= count.value) {
|
||||
isEnd = true;
|
||||
}
|
||||
} else {
|
||||
if (replies.cursor.isEnd ||
|
||||
replies.root.replies.length >= count.value) {
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
if (isDialogue) {
|
||||
loadingState.value = LoadingState.success(replies.replies);
|
||||
} else {
|
||||
loadingState.value = LoadingState.success(replies.root.replies);
|
||||
}
|
||||
}
|
||||
if (isDialogue) {
|
||||
isEnd = replies.replies.isEmpty ||
|
||||
replies.cursor.isEnd ||
|
||||
replies.replies.length >= count.value;
|
||||
} else {
|
||||
isEnd = replies.root.replies.isEmpty ||
|
||||
replies.cursor.isEnd ||
|
||||
replies.root.replies.length >= count.value;
|
||||
}
|
||||
if (isDialogue) {
|
||||
loadingState.value = LoadingState.success(replies.replies);
|
||||
} else {
|
||||
loadingState.value = LoadingState.success(replies.root.replies);
|
||||
if (response.response.root != null) {
|
||||
firstFloor = response.response.root;
|
||||
}
|
||||
List<ReplyItemModel> replies = response.response.replies;
|
||||
count.value = response.response.page.count;
|
||||
if (replies.isEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
if (currentPage != 1 && loadingState.value is Success) {
|
||||
replies.insertAll(0, (loadingState.value as Success).response);
|
||||
}
|
||||
if (replies.length >= response.response.page.count) {
|
||||
isEnd = true;
|
||||
}
|
||||
loadingState.value = LoadingState.success(replies);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -182,16 +174,23 @@ class VideoReplyReplyController extends CommonController
|
||||
mode: mode.value,
|
||||
),
|
||||
)
|
||||
: ReplyHttp.replyReplyListGrpc(
|
||||
type: replyType.index,
|
||||
oid: oid!,
|
||||
root: rpid!,
|
||||
rpid: id ?? 0,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next,
|
||||
mode: mode.value,
|
||||
),
|
||||
);
|
||||
: GlobalData().grpcReply
|
||||
? ReplyHttp.replyReplyListGrpc(
|
||||
type: replyType.index,
|
||||
oid: oid!,
|
||||
root: rpid!,
|
||||
rpid: id ?? 0,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next,
|
||||
mode: mode.value,
|
||||
),
|
||||
)
|
||||
: ReplyHttp.replyReplyList(
|
||||
oid: oid!,
|
||||
root: rpid!,
|
||||
pageNum: currentPage,
|
||||
type: replyType.index,
|
||||
);
|
||||
|
||||
queryBySort() {
|
||||
mode.value = mode.value == Mode.MAIN_LIST_HOT
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import 'package:PiliPalaX/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/models/video/reply/item.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/pages/video/detail/reply_new/reply_page.dart';
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:PiliPalaX/utils/global_data.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -17,7 +20,6 @@ import 'controller.dart';
|
||||
|
||||
class VideoReplyReplyPanel extends StatefulWidget {
|
||||
const VideoReplyReplyPanel({
|
||||
// this.rcount,
|
||||
this.id,
|
||||
this.oid,
|
||||
this.rpid,
|
||||
@@ -29,12 +31,11 @@ class VideoReplyReplyPanel extends StatefulWidget {
|
||||
this.isTop = false,
|
||||
super.key,
|
||||
});
|
||||
// final dynamic rcount;
|
||||
final int? id;
|
||||
final int? oid;
|
||||
final int? rpid;
|
||||
final int? dialog;
|
||||
final ReplyInfo? firstFloor;
|
||||
final dynamic firstFloor;
|
||||
final String? source;
|
||||
final ReplyType? replyType;
|
||||
final bool isDialogue;
|
||||
@@ -50,7 +51,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
late final itemPositionsListener = ItemPositionsListener.create();
|
||||
late final _key = GlobalKey<ScaffoldState>();
|
||||
|
||||
ReplyInfo? get firstFloor =>
|
||||
dynamic get firstFloor =>
|
||||
widget.firstFloor ?? _videoReplyReplyController.firstFloor;
|
||||
|
||||
@override
|
||||
@@ -155,18 +156,29 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
index);
|
||||
} else if (firstFloor != null) {
|
||||
if (index == 0) {
|
||||
return ReplyItemGrpc(
|
||||
replyItem: firstFloor!,
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
needDivider: false,
|
||||
onReply: () {
|
||||
_onReply(firstFloor!, -1);
|
||||
},
|
||||
upMid: _videoReplyReplyController.upMid,
|
||||
isTop: widget.isTop,
|
||||
);
|
||||
return GlobalData().grpcReply
|
||||
? ReplyItemGrpc(
|
||||
replyItem: firstFloor,
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
needDivider: false,
|
||||
onReply: () {
|
||||
_onReply(firstFloor, -1);
|
||||
},
|
||||
upMid: _videoReplyReplyController.upMid,
|
||||
isTop: widget.isTop,
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: firstFloor,
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
needDivider: false,
|
||||
onReply: () {
|
||||
_onReply(firstFloor, -1);
|
||||
},
|
||||
);
|
||||
} else if (index == 1) {
|
||||
return Divider(
|
||||
height: 20,
|
||||
@@ -223,30 +235,32 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
SizedBox(
|
||||
height: 35,
|
||||
child: TextButton.icon(
|
||||
onPressed: () => _videoReplyReplyController.queryBySort(),
|
||||
icon: const Icon(Icons.sort, size: 16),
|
||||
label: Obx(
|
||||
() => Text(
|
||||
_videoReplyReplyController.mode.value == Mode.MAIN_LIST_HOT
|
||||
? '按热度'
|
||||
: '按时间',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
if (GlobalData().grpcReply)
|
||||
SizedBox(
|
||||
height: 35,
|
||||
child: TextButton.icon(
|
||||
onPressed: () => _videoReplyReplyController.queryBySort(),
|
||||
icon: const Icon(Icons.sort, size: 16),
|
||||
label: Obx(
|
||||
() => Text(
|
||||
_videoReplyReplyController.mode.value ==
|
||||
Mode.MAIN_LIST_HOT
|
||||
? '按热度'
|
||||
: '按时间',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
void _onReply(ReplyInfo? item, int index) {
|
||||
void _onReply(dynamic item, int index) {
|
||||
dynamic oid = item?.oid.toInt();
|
||||
dynamic root = item?.id.toInt();
|
||||
dynamic parent = item?.id.toInt();
|
||||
dynamic key = oid + root + parent;
|
||||
dynamic root = GlobalData().grpcReply ? item?.id.toInt() : item?.rpid;
|
||||
dynamic key = oid + root;
|
||||
|
||||
Navigator.of(context)
|
||||
.push(
|
||||
GetDialogRoute(
|
||||
@@ -254,7 +268,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
return ReplyPage(
|
||||
oid: oid,
|
||||
root: root,
|
||||
parent: parent,
|
||||
parent: root,
|
||||
replyType: widget.replyType,
|
||||
replyItem: item,
|
||||
savedReply: _savedReplies[key],
|
||||
@@ -282,14 +296,26 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
.then((res) {
|
||||
if (res != null) {
|
||||
_savedReplies[key] = null;
|
||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||
List list = (_videoReplyReplyController.loadingState.value as Success?)
|
||||
?.response ??
|
||||
<ReplyInfo>[];
|
||||
list.insert(index + 1, replyInfo);
|
||||
_videoReplyReplyController.count.value += 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
if (GlobalData().grpcReply) {
|
||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||
List list =
|
||||
(_videoReplyReplyController.loadingState.value as Success?)
|
||||
?.response ??
|
||||
<ReplyInfo>[];
|
||||
list.insert(index + 1, replyInfo);
|
||||
_videoReplyReplyController.count.value += 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
} else {
|
||||
List list =
|
||||
(_videoReplyReplyController.loadingState.value as Success?)
|
||||
?.response ??
|
||||
<ReplyItemModel>[];
|
||||
list.insert(index + 1, ReplyItemModel.fromJson(res, ''));
|
||||
_videoReplyReplyController.count.value += 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -361,36 +387,56 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
}
|
||||
|
||||
Widget _replyItem(replyItem, index) {
|
||||
return ReplyItemGrpc(
|
||||
replyItem: replyItem,
|
||||
replyLevel: widget.isDialogue ? '3' : '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
onReply: () {
|
||||
_onReply(replyItem, index);
|
||||
},
|
||||
onDelete: (rpid, frpid) {
|
||||
List list =
|
||||
(_videoReplyReplyController.loadingState.value as Success).response;
|
||||
list = list.where((item) => item.id != rpid).toList();
|
||||
_videoReplyReplyController.count.value -= 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
},
|
||||
upMid: _videoReplyReplyController.upMid,
|
||||
showDialogue: () {
|
||||
_key.currentState?.showBottomSheet(
|
||||
(context) => VideoReplyReplyPanel(
|
||||
oid: replyItem.oid.toInt(),
|
||||
rpid: replyItem.root.toInt(),
|
||||
dialog: replyItem.dialog.toInt(),
|
||||
return GlobalData().grpcReply
|
||||
? ReplyItemGrpc(
|
||||
replyItem: replyItem,
|
||||
replyLevel: widget.isDialogue ? '3' : '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
source: 'videoDetail',
|
||||
isDialogue: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
onReply: () {
|
||||
_onReply(replyItem, index);
|
||||
},
|
||||
onDelete: (rpid, frpid) {
|
||||
List list =
|
||||
(_videoReplyReplyController.loadingState.value as Success)
|
||||
.response;
|
||||
list = list.where((item) => item.id != rpid).toList();
|
||||
_videoReplyReplyController.count.value -= 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
},
|
||||
upMid: _videoReplyReplyController.upMid,
|
||||
showDialogue: () {
|
||||
_key.currentState?.showBottomSheet(
|
||||
(context) => VideoReplyReplyPanel(
|
||||
oid: replyItem.oid.toInt(),
|
||||
rpid: replyItem.root.toInt(),
|
||||
dialog: replyItem.dialog.toInt(),
|
||||
replyType: widget.replyType,
|
||||
source: 'videoDetail',
|
||||
isDialogue: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: replyItem,
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
onReply: () {
|
||||
_onReply(replyItem, index);
|
||||
},
|
||||
onDelete: (rpid, frpid) {
|
||||
List list =
|
||||
(_videoReplyReplyController.loadingState.value as Success)
|
||||
.response;
|
||||
list.removeWhere((item) => item.rpid == rpid);
|
||||
_videoReplyReplyController.count.value -= 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
int _itemCount(LoadingState loadingState) {
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:PiliPalaX/pages/video/detail/introduction/widgets/intro_detail.d
|
||||
import 'package:PiliPalaX/pages/video/detail/reply_reply/view.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/widgets/ai_detail.dart';
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:PiliPalaX/utils/global_data.dart';
|
||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||
import 'package:auto_orientation/auto_orientation.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
@@ -1314,16 +1315,17 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
// 展示二级回复
|
||||
void replyReply(replyItem, id, isTop) {
|
||||
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||
int oid = replyItem.oid.toInt();
|
||||
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
|
||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||
(context) => VideoReplyReplyPanel(
|
||||
id: id,
|
||||
// rcount: replyItem.rcount,
|
||||
oid: replyItem.oid.toInt(),
|
||||
rpid: replyItem.id.toInt(),
|
||||
oid: oid,
|
||||
rpid: rpid,
|
||||
firstFloor: replyItem,
|
||||
replyType: ReplyType.video,
|
||||
source: 'videoDetail',
|
||||
isTop: isTop,
|
||||
isTop: isTop ?? false,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user