mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
chore: deprecate prev reply, videopage
Closes #579 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -13,20 +13,18 @@ abstract class CommonCollapseSlidePageState<T extends CommonCollapseSlidePage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (GStorage.collapsibleVideoPage) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isInit = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isInit = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (GStorage.collapsibleVideoPage && _isInit) {
|
||||
if (_isInit) {
|
||||
return CustomScrollView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
);
|
||||
|
||||
@@ -69,57 +69,24 @@ abstract class ReplyController extends CommonController {
|
||||
|
||||
@override
|
||||
bool customHandleResponse(Success response) {
|
||||
if (GlobalData().grpcReply) {
|
||||
MainListReply replies = response.response;
|
||||
if (cursor == null) {
|
||||
count.value = replies.subjectControl.count.toInt();
|
||||
hasUpTop = replies.hasUpTop();
|
||||
if (replies.hasUpTop()) {
|
||||
replies.replies.insert(0, replies.upTop);
|
||||
}
|
||||
MainListReply replies = response.response;
|
||||
if (cursor == null) {
|
||||
count.value = replies.subjectControl.count.toInt();
|
||||
hasUpTop = replies.hasUpTop();
|
||||
if (replies.hasUpTop()) {
|
||||
replies.replies.insert(0, replies.upTop);
|
||||
}
|
||||
cursor = replies.cursor;
|
||||
if (currentPage != 1 && loadingState.value is Success) {
|
||||
replies.replies
|
||||
.insertAll(0, (loadingState.value as Success).response.replies);
|
||||
}
|
||||
isEnd = replies.replies.isEmpty ||
|
||||
replies.cursor.isEnd ||
|
||||
replies.replies.length >= count.value;
|
||||
loadingState.value = LoadingState.success(replies);
|
||||
} else {
|
||||
List<ReplyItemModel> replies = response.response.replies;
|
||||
if (isLogin.not) {
|
||||
nextOffset = response.response.cursor.paginationReply.nextOffset ?? '';
|
||||
}
|
||||
count.value = isLogin.not
|
||||
? response.response.cursor.allCount
|
||||
: response.response.page.count ?? 0;
|
||||
if (replies.isEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
if (currentPage == 1) {
|
||||
if (response.response.upper.top != null) {
|
||||
final bool flag = response.response.topReplies.any(
|
||||
(ReplyItemModel reply) =>
|
||||
reply.rpid != response.response.upper.top.rpid) as bool;
|
||||
if (flag) {
|
||||
replies.insert(0, response.response.upper.top);
|
||||
hasUpTop = true;
|
||||
}
|
||||
}
|
||||
if ((response.response.topReplies as List?)?.isNotEmpty == true) {
|
||||
replies.insertAll(0, response.response.topReplies);
|
||||
hasUpTop = true;
|
||||
}
|
||||
} else if (loadingState.value is Success) {
|
||||
replies.insertAll(0, (loadingState.value as Success).response.replies);
|
||||
}
|
||||
if (isEnd.not && replies.length >= count.value) {
|
||||
isEnd = true;
|
||||
}
|
||||
loadingState.value = LoadingState.success(response.response);
|
||||
}
|
||||
cursor = replies.cursor;
|
||||
if (currentPage != 1 && loadingState.value is Success) {
|
||||
replies.replies
|
||||
.insertAll(0, (loadingState.value as Success).response.replies);
|
||||
}
|
||||
isEnd = replies.replies.isEmpty ||
|
||||
replies.cursor.isEnd ||
|
||||
replies.replies.length >= count.value;
|
||||
loadingState.value = LoadingState.success(replies);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -149,40 +116,24 @@ abstract class ReplyController extends CommonController {
|
||||
int index = 0,
|
||||
ReplyType? replyType,
|
||||
}) {
|
||||
dynamic key = oid ??
|
||||
replyItem.oid +
|
||||
(GlobalData().grpcReply ? replyItem.id : replyItem.rpid);
|
||||
dynamic key = oid ?? replyItem.oid + replyItem.id;
|
||||
Navigator.of(context)
|
||||
.push(
|
||||
GetDialogRoute(
|
||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
||||
return GlobalData().grpcReply
|
||||
? ReplyPage(
|
||||
oid: oid ?? replyItem.oid.toInt(),
|
||||
root: oid != null ? 0 : replyItem.id.toInt(),
|
||||
parent: oid != null ? 0 : replyItem.id.toInt(),
|
||||
replyType: replyItem != null
|
||||
? ReplyType.values[replyItem.type.toInt()]
|
||||
: replyType,
|
||||
replyItem: replyItem,
|
||||
initialValue: savedReplies[key],
|
||||
onSave: (reply) {
|
||||
savedReplies[key] = reply;
|
||||
},
|
||||
)
|
||||
: ReplyPage(
|
||||
oid: oid ?? replyItem.oid,
|
||||
root: oid != null ? 0 : replyItem.rpid,
|
||||
parent: oid != null ? 0 : replyItem.rpid,
|
||||
replyType: replyItem != null
|
||||
? ReplyType.values[replyItem.type.toInt()]
|
||||
: replyType,
|
||||
replyItem: replyItem,
|
||||
initialValue: savedReplies[key],
|
||||
onSave: (reply) {
|
||||
savedReplies[key] = reply;
|
||||
},
|
||||
);
|
||||
return ReplyPage(
|
||||
oid: oid ?? replyItem.oid.toInt(),
|
||||
root: oid != null ? 0 : replyItem.id.toInt(),
|
||||
parent: oid != null ? 0 : replyItem.id.toInt(),
|
||||
replyType: replyItem != null
|
||||
? ReplyType.values[replyItem.type.toInt()]
|
||||
: replyType,
|
||||
replyItem: replyItem,
|
||||
initialValue: savedReplies[key],
|
||||
onSave: (reply) {
|
||||
savedReplies[key] = reply;
|
||||
},
|
||||
);
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 500),
|
||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||
@@ -204,70 +155,36 @@ abstract class ReplyController extends CommonController {
|
||||
(res) {
|
||||
if (res != null) {
|
||||
savedReplies[key] = null;
|
||||
if (GlobalData().grpcReply) {
|
||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||
MainListReply response = loadingState.value is Success
|
||||
? (loadingState.value as Success).response
|
||||
: MainListReply();
|
||||
if (oid != null) {
|
||||
response.replies.insert(hasUpTop ? 1 : 0, replyInfo);
|
||||
} else {
|
||||
response.replies[index].replies.add(replyInfo);
|
||||
}
|
||||
count.value += 1;
|
||||
loadingState.value = LoadingState.success(response);
|
||||
if (enableCommAntifraud && context.mounted) {
|
||||
checkReply(
|
||||
context: context,
|
||||
oid: oid ?? replyItem.oid.toInt(),
|
||||
rpid: replyItem?.id.toInt(),
|
||||
replyType: replyItem?.type.toInt() ??
|
||||
replyType?.index ??
|
||||
ReplyType.video.index,
|
||||
replyId: replyInfo.id.toInt(),
|
||||
message: replyInfo.content.message,
|
||||
//
|
||||
root: replyInfo.root.toInt(),
|
||||
parent: replyInfo.parent.toInt(),
|
||||
ctime: replyInfo.ctime.toInt(),
|
||||
pictures: replyInfo.content.pictures
|
||||
.map((item) => item.toProto3Json())
|
||||
.toList(),
|
||||
mid: replyInfo.mid.toInt(),
|
||||
);
|
||||
}
|
||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||
MainListReply response = loadingState.value is Success
|
||||
? (loadingState.value as Success).response
|
||||
: MainListReply();
|
||||
if (oid != null) {
|
||||
response.replies.insert(hasUpTop ? 1 : 0, replyInfo);
|
||||
} else {
|
||||
ReplyData response = loadingState.value is Success
|
||||
? (loadingState.value as Success).response
|
||||
: ReplyData();
|
||||
response.replies ??= <ReplyItemModel>[];
|
||||
ReplyItemModel replyInfo = ReplyItemModel.fromJson(res, '');
|
||||
if (oid != null) {
|
||||
response.replies?.insert(hasUpTop ? 1 : 0, replyInfo);
|
||||
} else {
|
||||
response.replies?[index].replies ??= <ReplyItemModel>[];
|
||||
response.replies?[index].replies?.add(replyInfo);
|
||||
}
|
||||
count.value += 1;
|
||||
loadingState.value = LoadingState.success(response);
|
||||
if (enableCommAntifraud && context.mounted) {
|
||||
checkReply(
|
||||
context: context,
|
||||
oid: oid ?? replyItem.oid,
|
||||
rpid: replyItem?.rpid,
|
||||
replyType: replyItem?.type.toInt() ??
|
||||
replyType?.index ??
|
||||
ReplyType.video.index,
|
||||
replyId: replyInfo.rpid ?? 0,
|
||||
message: replyInfo.content?.message ?? '',
|
||||
//
|
||||
root: replyInfo.root,
|
||||
parent: replyInfo.parent,
|
||||
ctime: replyInfo.ctime,
|
||||
pictures: replyInfo.content?.pictures,
|
||||
mid: replyInfo.mid,
|
||||
);
|
||||
}
|
||||
response.replies[index].replies.add(replyInfo);
|
||||
}
|
||||
count.value += 1;
|
||||
loadingState.value = LoadingState.success(response);
|
||||
if (enableCommAntifraud && context.mounted) {
|
||||
checkReply(
|
||||
context: context,
|
||||
oid: oid ?? replyItem.oid.toInt(),
|
||||
rpid: replyItem?.id.toInt(),
|
||||
replyType: replyItem?.type.toInt() ??
|
||||
replyType?.index ??
|
||||
ReplyType.video.index,
|
||||
replyId: replyInfo.id.toInt(),
|
||||
message: replyInfo.content.message,
|
||||
//
|
||||
root: replyInfo.root.toInt(),
|
||||
parent: replyInfo.parent.toInt(),
|
||||
ctime: replyInfo.ctime.toInt(),
|
||||
pictures: replyInfo.content.pictures
|
||||
.map((item) => item.toProto3Json())
|
||||
.toList(),
|
||||
mid: replyInfo.mid.toInt(),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -275,41 +192,22 @@ abstract class ReplyController extends CommonController {
|
||||
}
|
||||
|
||||
onMDelete(rpid, frpid) {
|
||||
if (GlobalData().grpcReply) {
|
||||
MainListReply response = (loadingState.value as Success).response;
|
||||
if (frpid == null) {
|
||||
response.replies.removeWhere((item) {
|
||||
return item.id.toInt() == rpid;
|
||||
});
|
||||
} else {
|
||||
response.replies.map((item) {
|
||||
if (item.id == frpid) {
|
||||
return item
|
||||
..replies.removeWhere((reply) => reply.id.toInt() == rpid);
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
count.value -= 1;
|
||||
loadingState.value = LoadingState.success(response);
|
||||
MainListReply response = (loadingState.value as Success).response;
|
||||
if (frpid == null) {
|
||||
response.replies.removeWhere((item) {
|
||||
return item.id.toInt() == rpid;
|
||||
});
|
||||
} else {
|
||||
ReplyData response = (loadingState.value as Success).response;
|
||||
response.replies = frpid == null
|
||||
? response.replies?.where((item) => item.rpid != rpid).toList()
|
||||
: response.replies?.map((item) {
|
||||
if (item.rpid == frpid) {
|
||||
return item
|
||||
..replies = item.replies
|
||||
?.where((reply) => reply.rpid != rpid)
|
||||
.toList();
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}).toList();
|
||||
count.value -= 1;
|
||||
loadingState.value = LoadingState.success(response);
|
||||
response.replies.map((item) {
|
||||
if (item.id == frpid) {
|
||||
return item..replies.removeWhere((reply) => reply.id.toInt() == rpid);
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
count.value -= 1;
|
||||
loadingState.value = LoadingState.success(response);
|
||||
}
|
||||
|
||||
void onCheckReply(context, item) {
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/reply_type.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -47,23 +46,13 @@ class DynamicDetailController extends ReplyController {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() => GlobalData().grpcReply
|
||||
? ReplyHttp.replyListGrpc(
|
||||
type: type,
|
||||
oid: oid,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
)
|
||||
: ReplyHttp.replyList(
|
||||
isLogin: isLogin,
|
||||
oid: oid,
|
||||
nextOffset: nextOffset,
|
||||
type: type,
|
||||
sort: sortType.value.index,
|
||||
page: currentPage,
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
|
||||
type: type,
|
||||
oid: oid,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
@@ -170,7 +168,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
void replyReply(context, replyItem, id, isTop) {
|
||||
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||
int oid = replyItem.oid.toInt();
|
||||
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
|
||||
int rpid = replyItem.id.toInt();
|
||||
Widget replyReplyPage(
|
||||
[bool automaticallyImplyLeading = true,
|
||||
VoidCallback? onDispose]) =>
|
||||
@@ -813,48 +811,27 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return GlobalData().grpcReply
|
||||
? ReplyItemGrpc(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem, id, isTop) =>
|
||||
replyReply(context, replyItem, id, isTop),
|
||||
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,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) => _dynamicDetailController
|
||||
.onCheckReply(context, item),
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem, id, isTop) =>
|
||||
replyReply(context, replyItem, id, isTop),
|
||||
replyType: ReplyType.values[replyType],
|
||||
onReply: () {
|
||||
_dynamicDetailController.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _dynamicDetailController.onMDelete,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) => _dynamicDetailController
|
||||
.onCheckReply(context, item),
|
||||
);
|
||||
return ReplyItemGrpc(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem, id, isTop) =>
|
||||
replyReply(context, replyItem, id, isTop),
|
||||
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,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_dynamicDetailController.onCheckReply(context, item),
|
||||
);
|
||||
}
|
||||
},
|
||||
childCount: loadingState.response.replies.length + 1,
|
||||
@@ -863,11 +840,9 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
: HttpError(
|
||||
callback: _dynamicDetailController.onReload,
|
||||
),
|
||||
Error() => replyErrorWidget(
|
||||
context,
|
||||
true,
|
||||
loadingState.errMsg,
|
||||
_dynamicDetailController.onReload,
|
||||
Error() => errorWidget(
|
||||
errMsg: loadingState.errMsg,
|
||||
callback: _dynamicDetailController.onReload,
|
||||
),
|
||||
LoadingState() => throw UnimplementedError(),
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/url_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -88,24 +87,14 @@ class HtmlRenderController extends ReplyController {
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() {
|
||||
return GlobalData().grpcReply
|
||||
? ReplyHttp.replyListGrpc(
|
||||
type: type,
|
||||
oid: oid.value,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
)
|
||||
: ReplyHttp.replyList(
|
||||
isLogin: isLogin,
|
||||
oid: oid.value,
|
||||
nextOffset: nextOffset,
|
||||
type: type,
|
||||
sort: sortType.value.index,
|
||||
page: currentPage,
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
return ReplyHttp.replyListGrpc(
|
||||
type: type,
|
||||
oid: oid.value,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,8 @@ import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
@@ -167,7 +165,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
void replyReply(context, replyItem, id, isTop) {
|
||||
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
|
||||
int oid = replyItem.oid.toInt();
|
||||
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid;
|
||||
int rpid = replyItem.id.toInt();
|
||||
Widget replyReplyPage(
|
||||
[bool automaticallyImplyLeading = true,
|
||||
VoidCallback? onDispose]) =>
|
||||
@@ -786,58 +784,36 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return GlobalData().grpcReply
|
||||
? ReplyItemGrpc(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem, id, isTop) =>
|
||||
replyReply(context, replyItem, id, isTop),
|
||||
replyType: ReplyType.values[type],
|
||||
onReply: () {
|
||||
_htmlRenderCtr.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _htmlRenderCtr.onMDelete,
|
||||
isTop: _htmlRenderCtr.hasUpTop && index == 0,
|
||||
upMid: loadingState.response.subjectControl.upMid,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_htmlRenderCtr.onCheckReply(context, item),
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem, id, isTop) =>
|
||||
replyReply(context, replyItem, id, isTop),
|
||||
replyType: ReplyType.values[type],
|
||||
onReply: () {
|
||||
_htmlRenderCtr.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _htmlRenderCtr.onMDelete,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_htmlRenderCtr.onCheckReply(context, item),
|
||||
);
|
||||
return ReplyItemGrpc(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
showReplyRow: true,
|
||||
replyLevel: '1',
|
||||
replyReply: (replyItem, id, isTop) =>
|
||||
replyReply(context, replyItem, id, isTop),
|
||||
replyType: ReplyType.values[type],
|
||||
onReply: () {
|
||||
_htmlRenderCtr.onReply(
|
||||
context,
|
||||
replyItem: loadingState.response.replies[index],
|
||||
index: index,
|
||||
);
|
||||
},
|
||||
onDelete: _htmlRenderCtr.onMDelete,
|
||||
isTop: _htmlRenderCtr.hasUpTop && index == 0,
|
||||
upMid: loadingState.response.subjectControl.upMid,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_htmlRenderCtr.onCheckReply(context, item),
|
||||
);
|
||||
}
|
||||
},
|
||||
)
|
||||
: HttpError(
|
||||
callback: _htmlRenderCtr.onReload,
|
||||
),
|
||||
Error() => replyErrorWidget(
|
||||
context,
|
||||
true,
|
||||
loadingState.errMsg,
|
||||
_htmlRenderCtr.onReload,
|
||||
Error() => errorWidget(
|
||||
errMsg: loadingState.errMsg,
|
||||
callback: _htmlRenderCtr.onReload,
|
||||
),
|
||||
LoadingState() => throw UnimplementedError(),
|
||||
};
|
||||
|
||||
@@ -2,13 +2,11 @@ import 'dart:async';
|
||||
|
||||
import 'package:PiliPlus/grpc/grpc_repo.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/common.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/view.dart';
|
||||
import 'package:PiliPlus/pages/home/view.dart';
|
||||
import 'package:PiliPlus/pages/media/view.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -165,19 +163,11 @@ class MainController extends GetxController {
|
||||
if (!isLogin.value || dynIndex == -1) {
|
||||
return;
|
||||
}
|
||||
if (GlobalData().grpcReply) {
|
||||
await GrpcRepo.dynRed().then((res) {
|
||||
if (res['status']) {
|
||||
setCount(res['data']);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await CommonHttp.unReadDynamic().then((res) {
|
||||
if (res['status']) {
|
||||
setCount(res['data']);
|
||||
}
|
||||
});
|
||||
}
|
||||
await GrpcRepo.dynRed().then((res) {
|
||||
if (res['status']) {
|
||||
setCount(res['data']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void setCount([int count = 0]) async {
|
||||
|
||||
@@ -1515,21 +1515,6 @@ List<SettingsModel> get extraSettings => [
|
||||
);
|
||||
},
|
||||
),
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '使用gRPC加载评论',
|
||||
subtitle: '如无法加载评论,可关闭\n非gRPC楼中楼无法定位评论、按热度/时间排序、查看对话',
|
||||
leading: SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: Icon(MdiIcons.google, size: 20),
|
||||
),
|
||||
setKey: SettingBoxKey.grpcReply,
|
||||
defaultVal: true,
|
||||
onChanged: (value) {
|
||||
GlobalData().grpcReply = value;
|
||||
},
|
||||
),
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '显示视频分段信息',
|
||||
@@ -2072,16 +2057,6 @@ List<SettingsModel> get extraSettings => [
|
||||
setKey: SettingBoxKey.antiGoodsReply,
|
||||
defaultVal: false,
|
||||
),
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '使用可折叠的播放页面',
|
||||
leading: const Icon(Icons.video_settings),
|
||||
setKey: SettingBoxKey.collapsibleVideoPage,
|
||||
defaultVal: true,
|
||||
onChanged: (value) {
|
||||
GStorage.collapsibleVideoPage = value;
|
||||
},
|
||||
),
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '侧滑关闭二级评论页面',
|
||||
|
||||
@@ -146,10 +146,6 @@ class VideoDetailController extends GetxController
|
||||
? 'horizontal'
|
||||
: 'vertical'
|
||||
: 'horizontal';
|
||||
if (GStorage.collapsibleVideoPage.not) {
|
||||
this.direction.value = direction;
|
||||
return;
|
||||
}
|
||||
if (scrollCtr.hasClients.not) {
|
||||
videoHeight = direction == 'vertical' ? maxVideoHeight : minVideoHeight;
|
||||
this.direction.value = direction;
|
||||
@@ -1548,11 +1544,9 @@ class VideoDetailController extends GetxController
|
||||
@override
|
||||
void onClose() {
|
||||
tabCtr.dispose();
|
||||
if (GStorage.collapsibleVideoPage) {
|
||||
scrollCtr.removeListener(scrollListener);
|
||||
scrollCtr.dispose;
|
||||
animationController.dispose();
|
||||
}
|
||||
scrollCtr.removeListener(scrollListener);
|
||||
scrollCtr.dispose;
|
||||
animationController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@@ -1561,7 +1555,7 @@ class VideoDetailController extends GetxController
|
||||
videoUrl = null;
|
||||
audioUrl = null;
|
||||
|
||||
if (GStorage.collapsibleVideoPage && scrollRatio.value != 0) {
|
||||
if (scrollRatio.value != 0) {
|
||||
scrollRatio.refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/reply_type.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -38,24 +36,14 @@ class VideoReplyController extends ReplyController
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() => GlobalData().grpcReply
|
||||
? ReplyHttp.replyListGrpc(
|
||||
oid: aid,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
)
|
||||
: ReplyHttp.replyList(
|
||||
isLogin: isLogin,
|
||||
oid: aid,
|
||||
nextOffset: nextOffset,
|
||||
type: ReplyType.video.index,
|
||||
sort: sortType.value.index,
|
||||
page: currentPage,
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
|
||||
oid: aid,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next ?? $fixnum.Int64(0),
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
|
||||
@@ -4,11 +4,8 @@ import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -75,13 +72,11 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
@override
|
||||
void didUpdateWidget(VideoReplyPanel oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (GStorage.collapsibleVideoPage) {
|
||||
_videoReplyController.showFab();
|
||||
if (widget.needController != false) {
|
||||
_videoReplyController.scrollController.addListener(listener);
|
||||
} else {
|
||||
_videoReplyController.scrollController.removeListener(listener);
|
||||
}
|
||||
_videoReplyController.showFab();
|
||||
if (widget.needController != false) {
|
||||
_videoReplyController.scrollController.addListener(listener);
|
||||
} else {
|
||||
_videoReplyController.scrollController.removeListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,51 +235,29 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
),
|
||||
);
|
||||
} else {
|
||||
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,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: widget.callback,
|
||||
onCheckReply: (item) => _videoReplyController
|
||||
.onCheckReply(context, item),
|
||||
)
|
||||
: 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,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
getTag: () => heroTag,
|
||||
callback: widget.callback,
|
||||
onCheckReply: (item) => _videoReplyController
|
||||
.onCheckReply(context, item),
|
||||
);
|
||||
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,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: widget.callback,
|
||||
onCheckReply: (item) =>
|
||||
_videoReplyController.onCheckReply(context, item),
|
||||
);
|
||||
}
|
||||
},
|
||||
childCount: loadingState.response.replies.length + 1,
|
||||
@@ -294,11 +267,9 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
errMsg: '还没有评论',
|
||||
callback: _videoReplyController.onReload,
|
||||
),
|
||||
Error() => replyErrorWidget(
|
||||
context,
|
||||
true,
|
||||
loadingState.errMsg,
|
||||
_videoReplyController.onReload,
|
||||
Error() => errorWidget(
|
||||
errMsg: loadingState.errMsg,
|
||||
callback: _videoReplyController.onReload,
|
||||
),
|
||||
LoadingState() => throw UnimplementedError(),
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'zan.dart';
|
||||
import 'package:html/parser.dart' show parse;
|
||||
|
||||
@Deprecated('Use ReplyItemGrpc instead')
|
||||
class ReplyItem extends StatelessWidget {
|
||||
const ReplyItem({
|
||||
super.key,
|
||||
|
||||
@@ -5,7 +5,6 @@ import 'package:PiliPlus/main.dart';
|
||||
import 'package:PiliPlus/pages/common/common_publish_page.dart';
|
||||
import 'package:PiliPlus/pages/emote/view.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply_new/toolbar_icon_button.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -275,7 +274,7 @@ class _ReplyPageState extends CommonPublishPageState<ReplyPage> {
|
||||
root: widget.root!,
|
||||
parent: widget.parent!,
|
||||
message: widget.replyItem != null && widget.replyItem.root != 0
|
||||
? ' 回复 @${GlobalData().grpcReply ? widget.replyItem.member.name : widget.replyItem.member.uname} : $message'
|
||||
? ' 回复 @${widget.replyItem.member.name} : $message'
|
||||
: message,
|
||||
pictures: pictures,
|
||||
syncToDynamic: _syncToDynamic.value,
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/video/reply/item.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -61,97 +59,78 @@ class VideoReplyReplyController extends ReplyController
|
||||
|
||||
@override
|
||||
bool customHandleResponse(Success response) {
|
||||
if (GlobalData().grpcReply) {
|
||||
dynamic replies = response.response;
|
||||
// reply2Reply // isDialogue.not
|
||||
if (replies is DetailListReply) {
|
||||
count.value = replies.root.count.toInt();
|
||||
if (cursor == null && firstFloor == null) {
|
||||
firstFloor = replies.root;
|
||||
}
|
||||
if (id != null) {
|
||||
index = replies.root.replies
|
||||
.map((item) => item.id.toInt())
|
||||
.toList()
|
||||
.indexOf(id!);
|
||||
if (index == -1) {
|
||||
index = null;
|
||||
} else {
|
||||
controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (index != null) {
|
||||
try {
|
||||
itemScrollCtr.jumpTo(
|
||||
index: hasRoot ? index! + 3 : index! + 1,
|
||||
alignment: 0.25,
|
||||
);
|
||||
} catch (_) {}
|
||||
await Future.delayed(const Duration(milliseconds: 800));
|
||||
await controller?.forward();
|
||||
index = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
id = null;
|
||||
}
|
||||
dynamic replies = response.response;
|
||||
// reply2Reply // isDialogue.not
|
||||
if (replies is DetailListReply) {
|
||||
count.value = replies.root.count.toInt();
|
||||
if (cursor == null && firstFloor == null) {
|
||||
firstFloor = replies.root;
|
||||
}
|
||||
upMid ??= replies.subjectControl.upMid.toInt();
|
||||
cursor = replies.cursor;
|
||||
if (isDialogue) {
|
||||
if (replies.replies.isEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
if (id != null) {
|
||||
index = replies.root.replies
|
||||
.map((item) => item.id.toInt())
|
||||
.toList()
|
||||
.indexOf(id!);
|
||||
if (index == -1) {
|
||||
index = null;
|
||||
} else {
|
||||
replies.root.replies.insertAll(0, list);
|
||||
controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (index != null) {
|
||||
try {
|
||||
itemScrollCtr.jumpTo(
|
||||
index: hasRoot ? index! + 3 : index! + 1,
|
||||
alignment: 0.25,
|
||||
);
|
||||
} catch (_) {}
|
||||
await Future.delayed(const Duration(milliseconds: 800));
|
||||
await controller?.forward();
|
||||
index = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
id = null;
|
||||
}
|
||||
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);
|
||||
}
|
||||
upMid ??= replies.subjectControl.upMid.toInt();
|
||||
cursor = replies.cursor;
|
||||
if (isDialogue) {
|
||||
if (replies.replies.isEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
} else {
|
||||
if (response.response.root != null) {
|
||||
firstFloor = response.response.root;
|
||||
hasRoot = true;
|
||||
}
|
||||
List<ReplyItemModel> replies = response.response.replies;
|
||||
count.value = response.response.page.count;
|
||||
if (replies.isEmpty) {
|
||||
if (replies.root.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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -168,26 +147,17 @@ class VideoReplyReplyController extends ReplyController
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
)
|
||||
: GlobalData().grpcReply
|
||||
? ReplyHttp.replyReplyListGrpc(
|
||||
type: replyType.index,
|
||||
oid: oid,
|
||||
root: rpid,
|
||||
rpid: id ?? 0,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next,
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
)
|
||||
: ReplyHttp.replyReplyList(
|
||||
isLogin: isLogin,
|
||||
oid: oid,
|
||||
root: rpid,
|
||||
pageNum: currentPage,
|
||||
type: replyType.index,
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
: ReplyHttp.replyReplyListGrpc(
|
||||
type: replyType.index,
|
||||
oid: oid,
|
||||
root: rpid,
|
||||
rpid: id ?? 0,
|
||||
cursor: CursorReq(
|
||||
next: cursor?.next,
|
||||
mode: mode.value,
|
||||
),
|
||||
antiGoodsReply: antiGoodsReply,
|
||||
);
|
||||
|
||||
@override
|
||||
queryBySort() {
|
||||
|
||||
@@ -2,13 +2,10 @@ import 'package:PiliPlus/common/widgets/loading_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/video/reply/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_slide_page.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item_grpc.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply_new/reply_page.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -181,41 +178,23 @@ class _VideoReplyReplyPanelState
|
||||
_videoReplyReplyController.loadingState.value, index);
|
||||
} else if (firstFloor != null) {
|
||||
if (index == 0) {
|
||||
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,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_videoReplyReplyController.onCheckReply(
|
||||
context, item),
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: firstFloor,
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
needDivider: false,
|
||||
onReply: () {
|
||||
_onReply(firstFloor, -1);
|
||||
},
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_videoReplyReplyController.onCheckReply(
|
||||
context, item),
|
||||
);
|
||||
return ReplyItemGrpc(
|
||||
replyItem: firstFloor,
|
||||
replyLevel: '2',
|
||||
showReplyRow: false,
|
||||
replyType: widget.replyType,
|
||||
needDivider: false,
|
||||
onReply: () {
|
||||
_onReply(firstFloor, -1);
|
||||
},
|
||||
upMid: _videoReplyReplyController.upMid,
|
||||
isTop: widget.isTop,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) => _videoReplyReplyController
|
||||
.onCheckReply(context, item),
|
||||
);
|
||||
} else if (index == 1) {
|
||||
return Divider(
|
||||
height: 20,
|
||||
@@ -273,30 +252,28 @@ class _VideoReplyReplyPanelState
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
if (GlobalData().grpcReply)
|
||||
SizedBox(
|
||||
height: 35,
|
||||
child: TextButton.icon(
|
||||
onPressed: () => _videoReplyReplyController.queryBySort(),
|
||||
icon: Icon(
|
||||
Icons.sort,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
label: Obx(
|
||||
() => Text(
|
||||
_videoReplyReplyController.mode.value ==
|
||||
Mode.MAIN_LIST_HOT
|
||||
? '按热度'
|
||||
: '按时间',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
SizedBox(
|
||||
height: 35,
|
||||
child: TextButton.icon(
|
||||
onPressed: () => _videoReplyReplyController.queryBySort(),
|
||||
icon: Icon(
|
||||
Icons.sort,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
label: Obx(
|
||||
() => Text(
|
||||
_videoReplyReplyController.mode.value == Mode.MAIN_LIST_HOT
|
||||
? '按热度'
|
||||
: '按时间',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -333,7 +310,7 @@ class _VideoReplyReplyPanelState
|
||||
|
||||
void _onReply(dynamic item, int index) {
|
||||
dynamic oid = item?.oid.toInt();
|
||||
dynamic root = GlobalData().grpcReply ? item?.id.toInt() : item?.rpid;
|
||||
dynamic root = item?.id.toInt();
|
||||
dynamic key = oid + root;
|
||||
|
||||
Navigator.of(context)
|
||||
@@ -371,60 +348,32 @@ class _VideoReplyReplyPanelState
|
||||
.then((res) {
|
||||
if (res != null) {
|
||||
_savedReplies[key] = null;
|
||||
if (GlobalData().grpcReply) {
|
||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||
List list = _videoReplyReplyController.loadingState.value is Success
|
||||
? (_videoReplyReplyController.loadingState.value as Success)
|
||||
.response
|
||||
: <ReplyInfo>[];
|
||||
list.insert(index + 1, replyInfo);
|
||||
_videoReplyReplyController.count.value += 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
if (_videoReplyReplyController.enableCommAntifraud && mounted) {
|
||||
_videoReplyReplyController.checkReply(
|
||||
context: context,
|
||||
oid: oid,
|
||||
rpid: root,
|
||||
replyType: widget.replyType.index,
|
||||
replyId: replyInfo.id.toInt(),
|
||||
message: replyInfo.content.message,
|
||||
//
|
||||
root: replyInfo.root.toInt(),
|
||||
parent: replyInfo.parent.toInt(),
|
||||
ctime: replyInfo.ctime.toInt(),
|
||||
pictures: replyInfo.content.pictures
|
||||
.map((item) => item.toProto3Json())
|
||||
.toList(),
|
||||
mid: replyInfo.mid.toInt(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
List list = _videoReplyReplyController.loadingState.value is Success
|
||||
? (_videoReplyReplyController.loadingState.value as Success)
|
||||
.response
|
||||
: <ReplyItemModel>[];
|
||||
ReplyItemModel replyInfo = ReplyItemModel.fromJson(res, '');
|
||||
list.insert(index + 1, replyInfo);
|
||||
_videoReplyReplyController.count.value += 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
if (_videoReplyReplyController.enableCommAntifraud && mounted) {
|
||||
_videoReplyReplyController.checkReply(
|
||||
context: context,
|
||||
oid: oid,
|
||||
rpid: root,
|
||||
replyType: widget.replyType.index,
|
||||
replyId: replyInfo.rpid ?? 0,
|
||||
message: replyInfo.content?.message ?? '',
|
||||
//
|
||||
root: replyInfo.root,
|
||||
parent: replyInfo.parent,
|
||||
ctime: replyInfo.ctime,
|
||||
pictures: replyInfo.content?.pictures,
|
||||
mid: replyInfo.mid,
|
||||
);
|
||||
}
|
||||
ReplyInfo replyInfo = Utils.replyCast(res);
|
||||
List list = _videoReplyReplyController.loadingState.value is Success
|
||||
? (_videoReplyReplyController.loadingState.value as Success)
|
||||
.response
|
||||
: <ReplyInfo>[];
|
||||
list.insert(index + 1, replyInfo);
|
||||
_videoReplyReplyController.count.value += 1;
|
||||
_videoReplyReplyController.loadingState.value =
|
||||
LoadingState.success(list);
|
||||
if (_videoReplyReplyController.enableCommAntifraud && mounted) {
|
||||
_videoReplyReplyController.checkReply(
|
||||
context: context,
|
||||
oid: oid,
|
||||
rpid: root,
|
||||
replyType: widget.replyType.index,
|
||||
replyId: replyInfo.id.toInt(),
|
||||
message: replyInfo.content.message,
|
||||
//
|
||||
root: replyInfo.root.toInt(),
|
||||
parent: replyInfo.parent.toInt(),
|
||||
ctime: replyInfo.ctime.toInt(),
|
||||
pictures: replyInfo.content.pictures
|
||||
.map((item) => item.toProto3Json())
|
||||
.toList(),
|
||||
mid: replyInfo.mid.toInt(),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -489,78 +438,51 @@ class _VideoReplyReplyPanelState
|
||||
return _replyItem(loadingState.response[index], index);
|
||||
}
|
||||
}(),
|
||||
Error() => replyErrorWidget(
|
||||
context,
|
||||
false,
|
||||
loadingState.errMsg,
|
||||
_videoReplyReplyController.onReload,
|
||||
Error() => errorWidget(
|
||||
errMsg: loadingState.errMsg,
|
||||
callback: _videoReplyReplyController.onReload,
|
||||
),
|
||||
LoadingState() => throw UnimplementedError(),
|
||||
};
|
||||
}
|
||||
|
||||
Widget _replyItem(replyItem, index) {
|
||||
return GlobalData().grpcReply
|
||||
? ReplyItemGrpc(
|
||||
replyItem: replyItem,
|
||||
replyLevel: widget.isDialogue ? '3' : '2',
|
||||
showReplyRow: false,
|
||||
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(
|
||||
backgroundColor: Colors.transparent,
|
||||
(context) => VideoReplyReplyPanel(
|
||||
oid: replyItem.oid.toInt(),
|
||||
rpid: replyItem.root.toInt(),
|
||||
dialog: replyItem.dialog.toInt(),
|
||||
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(
|
||||
backgroundColor: Colors.transparent,
|
||||
(context) => VideoReplyReplyPanel(
|
||||
oid: replyItem.oid.toInt(),
|
||||
rpid: replyItem.root.toInt(),
|
||||
dialog: replyItem.dialog.toInt(),
|
||||
replyType: widget.replyType,
|
||||
source: 'videoDetail',
|
||||
isDialogue: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_videoReplyReplyController.onCheckReply(context, item),
|
||||
)
|
||||
: 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);
|
||||
},
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_videoReplyReplyController.onCheckReply(context, item),
|
||||
);
|
||||
source: 'videoDetail',
|
||||
isDialogue: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
onCheckReply: (item) =>
|
||||
_videoReplyReplyController.onCheckReply(context, item),
|
||||
);
|
||||
}
|
||||
|
||||
int _itemCount(LoadingState loadingState) {
|
||||
|
||||
@@ -6,12 +6,9 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/list_sheet.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/main.dart';
|
||||
import 'package:PiliPlus/models/bangumi/info.dart';
|
||||
import 'package:PiliPlus/models/common/reply_type.dart';
|
||||
import 'package:PiliPlus/pages/bangumi/introduction/widgets/intro_detail.dart'
|
||||
as bangumi;
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/intro_detail.dart'
|
||||
as video;
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/page.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/season.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/member/controller.dart';
|
||||
@@ -21,7 +18,6 @@ import 'package:PiliPlus/pages/video/detail/view_point/view_points_page.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/widgets/ai_detail.dart';
|
||||
import 'package:PiliPlus/utils/download.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:auto_orientation/auto_orientation.dart';
|
||||
@@ -53,6 +49,7 @@ import '../../../services/shutdown_timer_service.dart';
|
||||
import 'widgets/header_control.dart';
|
||||
import 'package:PiliPlus/common/widgets/spring_physics.dart';
|
||||
|
||||
@Deprecated('Use VideoDetailPageV instead')
|
||||
class VideoDetailPage extends StatefulWidget {
|
||||
const VideoDetailPage({super.key});
|
||||
|
||||
@@ -1755,7 +1752,7 @@ 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;
|
||||
int rpid = replyItem.id.toInt();
|
||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||
backgroundColor: Colors.transparent,
|
||||
(context) => VideoReplyReplyPanel(
|
||||
@@ -1785,15 +1782,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||
shape: const RoundedRectangleBorder(),
|
||||
backgroundColor: themeData.colorScheme.surface,
|
||||
(context) => videoDetail is BangumiInfoModel
|
||||
? bangumi.IntroDetail(
|
||||
bangumiDetail: videoDetail,
|
||||
videoTags: videoTags,
|
||||
)
|
||||
: video.IntroDetail(
|
||||
videoDetail: videoDetail,
|
||||
videoTags: videoTags,
|
||||
),
|
||||
(context) => bangumi.IntroDetail(
|
||||
bangumiDetail: videoDetail,
|
||||
videoTags: videoTags,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,9 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/list_sheet.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/main.dart';
|
||||
import 'package:PiliPlus/models/bangumi/info.dart';
|
||||
import 'package:PiliPlus/models/common/reply_type.dart';
|
||||
import 'package:PiliPlus/pages/bangumi/introduction/widgets/intro_detail.dart'
|
||||
as bangumi;
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/intro_detail.dart'
|
||||
as video;
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/page.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/introduction/widgets/season.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/member/controller.dart';
|
||||
@@ -22,7 +19,6 @@ import 'package:PiliPlus/pages/video/detail/view_point/view_points_page.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/widgets/ai_detail.dart';
|
||||
import 'package:PiliPlus/utils/download.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:auto_orientation/auto_orientation.dart';
|
||||
@@ -2206,7 +2202,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
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;
|
||||
int rpid = replyItem.id.toInt();
|
||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||
backgroundColor: Colors.transparent,
|
||||
(context) => VideoReplyReplyPanel(
|
||||
@@ -2235,15 +2231,10 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
showIntroDetail(videoDetail, videoTags) {
|
||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||
backgroundColor: Colors.transparent,
|
||||
(context) => videoDetail is BangumiInfoModel
|
||||
? bangumi.IntroDetail(
|
||||
bangumiDetail: videoDetail,
|
||||
videoTags: videoTags,
|
||||
)
|
||||
: video.IntroDetail(
|
||||
videoDetail: videoDetail,
|
||||
videoTags: videoTags,
|
||||
),
|
||||
(context) => bangumi.IntroDetail(
|
||||
bangumiDetail: videoDetail,
|
||||
videoTags: videoTags,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user