chore: deprecate prev reply, videopage

Closes #579

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-01 12:41:03 +08:00
parent e4f3203351
commit cdb2718aeb
24 changed files with 399 additions and 823 deletions

View File

@@ -142,21 +142,15 @@ class _ListSheetContentState extends CommonSlidePageState<ListSheetContent>
}(); }();
} }
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
if (GStorage.collapsibleVideoPage) { if (mounted) {
if (mounted) { setState(() {
setState(() { _isInit = false;
_isInit = false; });
}); WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) { try {
try { itemScrollController[_index].jumpTo(index: currentIndex);
itemScrollController[_index].jumpTo(index: currentIndex); } catch (_) {}
} catch (_) {} });
});
}
} else {
try {
itemScrollController[_index].jumpTo(index: currentIndex);
} catch (_) {}
} }
}); });
} }
@@ -295,7 +289,7 @@ class _ListSheetContentState extends CommonSlidePageState<ListSheetContent>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (GStorage.collapsibleVideoPage && _isInit) { if (_isInit) {
return CustomScrollView( return CustomScrollView(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
); );

View File

@@ -1,5 +1,4 @@
import 'package:PiliPlus/common/widgets/http_error.dart'; import 'package:PiliPlus/common/widgets/http_error.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
Widget get loadingWidget => Center(child: CircularProgressIndicator()); Widget get loadingWidget => Center(child: CircularProgressIndicator());
@@ -19,27 +18,3 @@ Widget scrollErrorWidget({errMsg, callback}) => CustomScrollView(
) )
], ],
); );
Widget replyErrorWidget(context, isSliver, errMsg, onReload) => HttpError(
isSliver: isSliver,
errMsg:
'${errMsg.startsWith('gRPC Error') ? '如无法加载评论:\n关闭代理\n或设置中关闭使用gRPC加载评论\n\n' : ''}$errMsg',
callback: onReload,
extraWidget: errMsg.startsWith('gRPC Error') && GlobalData().grpcReply
? FilledButton.tonal(
onPressed: () {
GlobalData().grpcReply = false;
onReload();
},
style: ButtonStyle(
backgroundColor: WidgetStateProperty.resolveWith((states) {
return Theme.of(context).colorScheme.primary.withAlpha(20);
}),
),
child: Text(
'暂时关闭gRPC加载评论',
style: TextStyle(color: Theme.of(context).colorScheme.primary),
),
)
: null,
);

View File

@@ -20,6 +20,7 @@ class ReplyHttp {
static RegExp replyRegExp = static RegExp replyRegExp =
RegExp(GStorage.banWordForReply, caseSensitive: false); RegExp(GStorage.banWordForReply, caseSensitive: false);
@Deprecated('Use replyListGrpc instead')
static Future<LoadingState> replyList({ static Future<LoadingState> replyList({
required bool isLogin, required bool isLogin,
required int oid, required int oid,
@@ -214,6 +215,7 @@ class ReplyHttp {
return false; return false;
} }
@Deprecated('Use replyReplyListGrpc instead')
static Future<LoadingState> replyReplyList({ static Future<LoadingState> replyReplyList({
required bool isLogin, required bool isLogin,
required int oid, required int oid,

View File

@@ -16,7 +16,6 @@ import 'package:hive/hive.dart';
import 'package:PiliPlus/common/widgets/custom_toast.dart'; import 'package:PiliPlus/common/widgets/custom_toast.dart';
import 'package:PiliPlus/http/init.dart'; import 'package:PiliPlus/http/init.dart';
import 'package:PiliPlus/models/common/color_type.dart'; import 'package:PiliPlus/models/common/color_type.dart';
import 'package:PiliPlus/pages/video/detail/index.dart';
import 'package:PiliPlus/router/app_pages.dart'; import 'package:PiliPlus/router/app_pages.dart';
import 'package:PiliPlus/pages/main/view.dart'; import 'package:PiliPlus/pages/main/view.dart';
import 'package:PiliPlus/services/service_locator.dart'; import 'package:PiliPlus/services/service_locator.dart';
@@ -218,7 +217,6 @@ class MyApp extends StatelessWidget {
), ),
navigatorObservers: [ navigatorObservers: [
FlutterSmartDialog.observer, FlutterSmartDialog.observer,
VideoDetailPage.routeObserver,
VideoDetailPageV.routeObserver, VideoDetailPageV.routeObserver,
MainApp.routeObserver, MainApp.routeObserver,
], ],

View File

@@ -13,20 +13,18 @@ abstract class CommonCollapseSlidePageState<T extends CommonCollapseSlidePage>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
if (GStorage.collapsibleVideoPage) { WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) {
if (mounted) { setState(() {
setState(() { _isInit = false;
_isInit = false; });
}); }
} });
});
}
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (GStorage.collapsibleVideoPage && _isInit) { if (_isInit) {
return CustomScrollView( return CustomScrollView(
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
); );

View File

@@ -69,57 +69,24 @@ abstract class ReplyController extends CommonController {
@override @override
bool customHandleResponse(Success response) { bool customHandleResponse(Success response) {
if (GlobalData().grpcReply) { MainListReply replies = response.response;
MainListReply replies = response.response; if (cursor == null) {
if (cursor == null) { count.value = replies.subjectControl.count.toInt();
count.value = replies.subjectControl.count.toInt(); hasUpTop = replies.hasUpTop();
hasUpTop = replies.hasUpTop(); if (replies.hasUpTop()) {
if (replies.hasUpTop()) { replies.replies.insert(0, replies.upTop);
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; return true;
} }
@@ -149,40 +116,24 @@ abstract class ReplyController extends CommonController {
int index = 0, int index = 0,
ReplyType? replyType, ReplyType? replyType,
}) { }) {
dynamic key = oid ?? dynamic key = oid ?? replyItem.oid + replyItem.id;
replyItem.oid +
(GlobalData().grpcReply ? replyItem.id : replyItem.rpid);
Navigator.of(context) Navigator.of(context)
.push( .push(
GetDialogRoute( GetDialogRoute(
pageBuilder: (buildContext, animation, secondaryAnimation) { pageBuilder: (buildContext, animation, secondaryAnimation) {
return GlobalData().grpcReply return ReplyPage(
? ReplyPage( oid: oid ?? replyItem.oid.toInt(),
oid: oid ?? replyItem.oid.toInt(), root: oid != null ? 0 : replyItem.id.toInt(),
root: oid != null ? 0 : replyItem.id.toInt(), parent: oid != null ? 0 : replyItem.id.toInt(),
parent: oid != null ? 0 : replyItem.id.toInt(), replyType: replyItem != null
replyType: replyItem != null ? ReplyType.values[replyItem.type.toInt()]
? ReplyType.values[replyItem.type.toInt()] : replyType,
: replyType, replyItem: replyItem,
replyItem: replyItem, initialValue: savedReplies[key],
initialValue: savedReplies[key], onSave: (reply) {
onSave: (reply) { savedReplies[key] = 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;
},
);
}, },
transitionDuration: const Duration(milliseconds: 500), transitionDuration: const Duration(milliseconds: 500),
transitionBuilder: (context, animation, secondaryAnimation, child) { transitionBuilder: (context, animation, secondaryAnimation, child) {
@@ -204,70 +155,36 @@ abstract class ReplyController extends CommonController {
(res) { (res) {
if (res != null) { if (res != null) {
savedReplies[key] = null; savedReplies[key] = null;
if (GlobalData().grpcReply) { ReplyInfo replyInfo = Utils.replyCast(res);
ReplyInfo replyInfo = Utils.replyCast(res); MainListReply response = loadingState.value is Success
MainListReply response = loadingState.value is Success ? (loadingState.value as Success).response
? (loadingState.value as Success).response : MainListReply();
: MainListReply(); if (oid != null) {
if (oid != null) { response.replies.insert(hasUpTop ? 1 : 0, replyInfo);
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(),
);
}
} else { } else {
ReplyData response = loadingState.value is Success response.replies[index].replies.add(replyInfo);
? (loadingState.value as Success).response }
: ReplyData(); count.value += 1;
response.replies ??= <ReplyItemModel>[]; loadingState.value = LoadingState.success(response);
ReplyItemModel replyInfo = ReplyItemModel.fromJson(res, ''); if (enableCommAntifraud && context.mounted) {
if (oid != null) { checkReply(
response.replies?.insert(hasUpTop ? 1 : 0, replyInfo); context: context,
} else { oid: oid ?? replyItem.oid.toInt(),
response.replies?[index].replies ??= <ReplyItemModel>[]; rpid: replyItem?.id.toInt(),
response.replies?[index].replies?.add(replyInfo); replyType: replyItem?.type.toInt() ??
} replyType?.index ??
count.value += 1; ReplyType.video.index,
loadingState.value = LoadingState.success(response); replyId: replyInfo.id.toInt(),
if (enableCommAntifraud && context.mounted) { message: replyInfo.content.message,
checkReply( //
context: context, root: replyInfo.root.toInt(),
oid: oid ?? replyItem.oid, parent: replyInfo.parent.toInt(),
rpid: replyItem?.rpid, ctime: replyInfo.ctime.toInt(),
replyType: replyItem?.type.toInt() ?? pictures: replyInfo.content.pictures
replyType?.index ?? .map((item) => item.toProto3Json())
ReplyType.video.index, .toList(),
replyId: replyInfo.rpid ?? 0, mid: replyInfo.mid.toInt(),
message: replyInfo.content?.message ?? '', );
//
root: replyInfo.root,
parent: replyInfo.parent,
ctime: replyInfo.ctime,
pictures: replyInfo.content?.pictures,
mid: replyInfo.mid,
);
}
} }
} }
}, },
@@ -275,41 +192,22 @@ abstract class ReplyController extends CommonController {
} }
onMDelete(rpid, frpid) { onMDelete(rpid, frpid) {
if (GlobalData().grpcReply) { MainListReply response = (loadingState.value as Success).response;
MainListReply response = (loadingState.value as Success).response; if (frpid == null) {
if (frpid == null) { response.replies.removeWhere((item) {
response.replies.removeWhere((item) { return item.id.toInt() == rpid;
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);
} else { } else {
ReplyData response = (loadingState.value as Success).response; response.replies.map((item) {
response.replies = frpid == null if (item.id == frpid) {
? response.replies?.where((item) => item.rpid != rpid).toList() return item..replies.removeWhere((reply) => reply.id.toInt() == rpid);
: response.replies?.map((item) { } else {
if (item.rpid == frpid) { return item;
return item }
..replies = item.replies }).toList();
?.where((reply) => reply.rpid != rpid)
.toList();
} else {
return item;
}
}).toList();
count.value -= 1;
loadingState.value = LoadingState.success(response);
} }
count.value -= 1;
loadingState.value = LoadingState.success(response);
} }
void onCheckReply(context, item) { void onCheckReply(context, item) {

View File

@@ -3,7 +3,6 @@ import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/common/reply_type.dart'; import 'package:PiliPlus/models/common/reply_type.dart';
import 'package:PiliPlus/models/dynamics/result.dart'; import 'package:PiliPlus/models/dynamics/result.dart';
import 'package:PiliPlus/pages/common/reply_controller.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/id_utils.dart';
import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -47,23 +46,13 @@ class DynamicDetailController extends ReplyController {
} }
@override @override
Future<LoadingState> customGetData() => GlobalData().grpcReply Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
? ReplyHttp.replyListGrpc( type: type,
type: type, oid: oid,
oid: oid, cursor: CursorReq(
cursor: CursorReq( next: cursor?.next ?? $fixnum.Int64(0),
next: cursor?.next ?? $fixnum.Int64(0), mode: mode.value,
mode: mode.value, ),
), antiGoodsReply: antiGoodsReply,
antiGoodsReply: antiGoodsReply, );
)
: ReplyHttp.replyList(
isLogin: isLogin,
oid: oid,
nextOffset: nextOffset,
type: type,
sort: sortType.value.index,
page: currentPage,
antiGoodsReply: antiGoodsReply,
);
} }

View File

@@ -8,10 +8,8 @@ import 'package:PiliPlus/http/constants.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/common/reply_sort_type.dart'; import 'package:PiliPlus/models/common/reply_sort_type.dart';
import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.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/pages/video/detail/reply/widgets/reply_item_grpc.dart';
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:easy_debounce/easy_throttle.dart'; import 'package:easy_debounce/easy_throttle.dart';
@@ -170,7 +168,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
void replyReply(context, replyItem, id, isTop) { void replyReply(context, replyItem, id, isTop) {
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
int oid = replyItem.oid.toInt(); int oid = replyItem.oid.toInt();
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; int rpid = replyItem.id.toInt();
Widget replyReplyPage( Widget replyReplyPage(
[bool automaticallyImplyLeading = true, [bool automaticallyImplyLeading = true,
VoidCallback? onDispose]) => VoidCallback? onDispose]) =>
@@ -813,48 +811,27 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
), ),
); );
} else { } else {
return GlobalData().grpcReply return ReplyItemGrpc(
? ReplyItemGrpc( replyItem: loadingState.response.replies[index],
replyItem: loadingState.response.replies[index], showReplyRow: true,
showReplyRow: true, replyLevel: '1',
replyLevel: '1', replyReply: (replyItem, id, isTop) =>
replyReply: (replyItem, id, isTop) => replyReply(context, replyItem, id, isTop),
replyReply(context, replyItem, id, isTop), replyType: ReplyType.values[replyType],
replyType: ReplyType.values[replyType], onReply: () {
onReply: () { _dynamicDetailController.onReply(
_dynamicDetailController.onReply( context,
context, replyItem: loadingState.response.replies[index],
replyItem: loadingState.response.replies[index], index: index,
index: index, );
); },
}, onDelete: _dynamicDetailController.onMDelete,
onDelete: _dynamicDetailController.onMDelete, isTop: _dynamicDetailController.hasUpTop && index == 0,
isTop: upMid: loadingState.response.subjectControl.upMid,
_dynamicDetailController.hasUpTop && index == 0, callback: _getImageCallback,
upMid: loadingState.response.subjectControl.upMid, onCheckReply: (item) =>
callback: _getImageCallback, _dynamicDetailController.onCheckReply(context, item),
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),
);
} }
}, },
childCount: loadingState.response.replies.length + 1, childCount: loadingState.response.replies.length + 1,
@@ -863,11 +840,9 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
: HttpError( : HttpError(
callback: _dynamicDetailController.onReload, callback: _dynamicDetailController.onReload,
), ),
Error() => replyErrorWidget( Error() => errorWidget(
context, errMsg: loadingState.errMsg,
true, callback: _dynamicDetailController.onReload,
loadingState.errMsg,
_dynamicDetailController.onReload,
), ),
LoadingState() => throw UnimplementedError(), LoadingState() => throw UnimplementedError(),
}; };

View File

@@ -5,7 +5,6 @@ import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/models/dynamics/result.dart'; import 'package:PiliPlus/models/dynamics/result.dart';
import 'package:PiliPlus/pages/common/reply_controller.dart'; import 'package:PiliPlus/pages/common/reply_controller.dart';
import 'package:PiliPlus/pages/mine/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/storage.dart';
import 'package:PiliPlus/utils/url_utils.dart'; import 'package:PiliPlus/utils/url_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -88,24 +87,14 @@ class HtmlRenderController extends ReplyController {
@override @override
Future<LoadingState> customGetData() { Future<LoadingState> customGetData() {
return GlobalData().grpcReply return ReplyHttp.replyListGrpc(
? ReplyHttp.replyListGrpc( type: type,
type: type, oid: oid.value,
oid: oid.value, cursor: CursorReq(
cursor: CursorReq( next: cursor?.next ?? $fixnum.Int64(0),
next: cursor?.next ?? $fixnum.Int64(0), mode: mode.value,
mode: mode.value, ),
), antiGoodsReply: antiGoodsReply,
antiGoodsReply: antiGoodsReply, );
)
: ReplyHttp.replyList(
isLogin: isLogin,
oid: oid.value,
nextOffset: nextOffset,
type: type,
sort: sortType.value.index,
page: currentPage,
antiGoodsReply: antiGoodsReply,
);
} }
} }

View File

@@ -8,10 +8,8 @@ import 'package:PiliPlus/http/constants.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/common/reply_sort_type.dart'; import 'package:PiliPlus/models/common/reply_sort_type.dart';
import 'package:PiliPlus/pages/dynamics/repost_dyn_panel.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/pages/video/detail/reply/widgets/reply_item_grpc.dart';
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:easy_debounce/easy_throttle.dart'; import 'package:easy_debounce/easy_throttle.dart';
@@ -167,7 +165,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
void replyReply(context, replyItem, id, isTop) { void replyReply(context, replyItem, id, isTop) {
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
int oid = replyItem.oid.toInt(); int oid = replyItem.oid.toInt();
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; int rpid = replyItem.id.toInt();
Widget replyReplyPage( Widget replyReplyPage(
[bool automaticallyImplyLeading = true, [bool automaticallyImplyLeading = true,
VoidCallback? onDispose]) => VoidCallback? onDispose]) =>
@@ -786,58 +784,36 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
), ),
); );
} else { } else {
return GlobalData().grpcReply return ReplyItemGrpc(
? ReplyItemGrpc( replyItem: loadingState.response.replies[index],
replyItem: loadingState.response.replies[index], showReplyRow: true,
showReplyRow: true, replyLevel: '1',
replyLevel: '1', replyReply: (replyItem, id, isTop) =>
replyReply: (replyItem, id, isTop) => replyReply(context, replyItem, id, isTop),
replyReply(context, replyItem, id, isTop), replyType: ReplyType.values[type],
replyType: ReplyType.values[type], onReply: () {
onReply: () { _htmlRenderCtr.onReply(
_htmlRenderCtr.onReply( context,
context, replyItem: loadingState.response.replies[index],
replyItem: loadingState.response.replies[index], index: index,
index: index, );
); },
}, onDelete: _htmlRenderCtr.onMDelete,
onDelete: _htmlRenderCtr.onMDelete, isTop: _htmlRenderCtr.hasUpTop && index == 0,
isTop: _htmlRenderCtr.hasUpTop && index == 0, upMid: loadingState.response.subjectControl.upMid,
upMid: loadingState.response.subjectControl.upMid, callback: _getImageCallback,
callback: _getImageCallback, onCheckReply: (item) =>
onCheckReply: (item) => _htmlRenderCtr.onCheckReply(context, 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),
);
} }
}, },
) )
: HttpError( : HttpError(
callback: _htmlRenderCtr.onReload, callback: _htmlRenderCtr.onReload,
), ),
Error() => replyErrorWidget( Error() => errorWidget(
context, errMsg: loadingState.errMsg,
true, callback: _htmlRenderCtr.onReload,
loadingState.errMsg,
_htmlRenderCtr.onReload,
), ),
LoadingState() => throw UnimplementedError(), LoadingState() => throw UnimplementedError(),
}; };

View File

@@ -2,13 +2,11 @@ import 'dart:async';
import 'package:PiliPlus/grpc/grpc_repo.dart'; import 'package:PiliPlus/grpc/grpc_repo.dart';
import 'package:PiliPlus/http/api.dart'; import 'package:PiliPlus/http/api.dart';
import 'package:PiliPlus/http/common.dart';
import 'package:PiliPlus/http/init.dart'; import 'package:PiliPlus/http/init.dart';
import 'package:PiliPlus/pages/dynamics/view.dart'; import 'package:PiliPlus/pages/dynamics/view.dart';
import 'package:PiliPlus/pages/home/view.dart'; import 'package:PiliPlus/pages/home/view.dart';
import 'package:PiliPlus/pages/media/view.dart'; import 'package:PiliPlus/pages/media/view.dart';
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -165,19 +163,11 @@ class MainController extends GetxController {
if (!isLogin.value || dynIndex == -1) { if (!isLogin.value || dynIndex == -1) {
return; return;
} }
if (GlobalData().grpcReply) { await GrpcRepo.dynRed().then((res) {
await GrpcRepo.dynRed().then((res) { if (res['status']) {
if (res['status']) { setCount(res['data']);
setCount(res['data']); }
} });
});
} else {
await CommonHttp.unReadDynamic().then((res) {
if (res['status']) {
setCount(res['data']);
}
});
}
} }
void setCount([int count = 0]) async { void setCount([int count = 0]) async {

View File

@@ -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( SettingsModel(
settingsType: SettingsType.sw1tch, settingsType: SettingsType.sw1tch,
title: '显示视频分段信息', title: '显示视频分段信息',
@@ -2072,16 +2057,6 @@ List<SettingsModel> get extraSettings => [
setKey: SettingBoxKey.antiGoodsReply, setKey: SettingBoxKey.antiGoodsReply,
defaultVal: false, defaultVal: false,
), ),
SettingsModel(
settingsType: SettingsType.sw1tch,
title: '使用可折叠的播放页面',
leading: const Icon(Icons.video_settings),
setKey: SettingBoxKey.collapsibleVideoPage,
defaultVal: true,
onChanged: (value) {
GStorage.collapsibleVideoPage = value;
},
),
SettingsModel( SettingsModel(
settingsType: SettingsType.sw1tch, settingsType: SettingsType.sw1tch,
title: '侧滑关闭二级评论页面', title: '侧滑关闭二级评论页面',

View File

@@ -146,10 +146,6 @@ class VideoDetailController extends GetxController
? 'horizontal' ? 'horizontal'
: 'vertical' : 'vertical'
: 'horizontal'; : 'horizontal';
if (GStorage.collapsibleVideoPage.not) {
this.direction.value = direction;
return;
}
if (scrollCtr.hasClients.not) { if (scrollCtr.hasClients.not) {
videoHeight = direction == 'vertical' ? maxVideoHeight : minVideoHeight; videoHeight = direction == 'vertical' ? maxVideoHeight : minVideoHeight;
this.direction.value = direction; this.direction.value = direction;
@@ -1548,11 +1544,9 @@ class VideoDetailController extends GetxController
@override @override
void onClose() { void onClose() {
tabCtr.dispose(); tabCtr.dispose();
if (GStorage.collapsibleVideoPage) { scrollCtr.removeListener(scrollListener);
scrollCtr.removeListener(scrollListener); scrollCtr.dispose;
scrollCtr.dispose; animationController.dispose();
animationController.dispose();
}
super.onClose(); super.onClose();
} }
@@ -1561,7 +1555,7 @@ class VideoDetailController extends GetxController
videoUrl = null; videoUrl = null;
audioUrl = null; audioUrl = null;
if (GStorage.collapsibleVideoPage && scrollRatio.value != 0) { if (scrollRatio.value != 0) {
scrollRatio.refresh(); scrollRatio.refresh();
} }

View File

@@ -1,9 +1,7 @@
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart'; import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
import 'package:PiliPlus/http/loading_state.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/pages/common/reply_controller.dart';
import 'package:PiliPlus/http/reply.dart'; import 'package:PiliPlus/http/reply.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/id_utils.dart';
import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:fixnum/fixnum.dart' as $fixnum;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -38,24 +36,14 @@ class VideoReplyController extends ReplyController
} }
@override @override
Future<LoadingState> customGetData() => GlobalData().grpcReply Future<LoadingState> customGetData() => ReplyHttp.replyListGrpc(
? ReplyHttp.replyListGrpc( oid: aid,
oid: aid, cursor: CursorReq(
cursor: CursorReq( next: cursor?.next ?? $fixnum.Int64(0),
next: cursor?.next ?? $fixnum.Int64(0), mode: mode.value,
mode: mode.value, ),
), antiGoodsReply: antiGoodsReply,
antiGoodsReply: antiGoodsReply, );
)
: ReplyHttp.replyList(
isLogin: isLogin,
oid: aid,
nextOffset: nextOffset,
type: ReplyType.video.index,
sort: sortType.value.index,
page: currentPage,
antiGoodsReply: antiGoodsReply,
);
@override @override
void onClose() { void onClose() {

View File

@@ -4,11 +4,8 @@ import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/common/widgets/http_error.dart'; import 'package:PiliPlus/common/widgets/http_error.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/common/reply_sort_type.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/pages/video/detail/reply/widgets/reply_item_grpc.dart';
import 'package:PiliPlus/utils/extension.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/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -75,13 +72,11 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
@override @override
void didUpdateWidget(VideoReplyPanel oldWidget) { void didUpdateWidget(VideoReplyPanel oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (GStorage.collapsibleVideoPage) { _videoReplyController.showFab();
_videoReplyController.showFab(); if (widget.needController != false) {
if (widget.needController != false) { _videoReplyController.scrollController.addListener(listener);
_videoReplyController.scrollController.addListener(listener); } else {
} else { _videoReplyController.scrollController.removeListener(listener);
_videoReplyController.scrollController.removeListener(listener);
}
} }
} }
@@ -240,51 +235,29 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
), ),
); );
} else { } else {
return GlobalData().grpcReply return ReplyItemGrpc(
? ReplyItemGrpc( replyItem: loadingState.response.replies[index],
replyItem: loadingState.response.replies[index], showReplyRow: true,
showReplyRow: true, replyLevel: replyLevel,
replyLevel: replyLevel, replyReply: widget.replyReply,
replyReply: widget.replyReply, replyType: ReplyType.video,
replyType: ReplyType.video, onReply: () {
onReply: () { _videoReplyController.onReply(
_videoReplyController.onReply( context,
context, replyItem: loadingState.response.replies[index],
replyItem: loadingState.response.replies[index], index: index,
index: index, );
); },
}, onDelete: _videoReplyController.onMDelete,
onDelete: _videoReplyController.onMDelete, isTop: _videoReplyController.hasUpTop && index == 0,
isTop: _videoReplyController.hasUpTop && index == 0, upMid: loadingState.response.subjectControl.upMid,
upMid: loadingState.response.subjectControl.upMid, getTag: () => heroTag,
getTag: () => heroTag, onViewImage: widget.onViewImage,
onViewImage: widget.onViewImage, onDismissed: widget.onDismissed,
onDismissed: widget.onDismissed, callback: widget.callback,
callback: widget.callback, onCheckReply: (item) =>
onCheckReply: (item) => _videoReplyController _videoReplyController.onCheckReply(context, item),
.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),
);
} }
}, },
childCount: loadingState.response.replies.length + 1, childCount: loadingState.response.replies.length + 1,
@@ -294,11 +267,9 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
errMsg: '还没有评论', errMsg: '还没有评论',
callback: _videoReplyController.onReload, callback: _videoReplyController.onReload,
), ),
Error() => replyErrorWidget( Error() => errorWidget(
context, errMsg: loadingState.errMsg,
true, callback: _videoReplyController.onReload,
loadingState.errMsg,
_videoReplyController.onReload,
), ),
LoadingState() => throw UnimplementedError(), LoadingState() => throw UnimplementedError(),
}; };

View File

@@ -26,6 +26,7 @@ import 'package:PiliPlus/utils/utils.dart';
import 'zan.dart'; import 'zan.dart';
import 'package:html/parser.dart' show parse; import 'package:html/parser.dart' show parse;
@Deprecated('Use ReplyItemGrpc instead')
class ReplyItem extends StatelessWidget { class ReplyItem extends StatelessWidget {
const ReplyItem({ const ReplyItem({
super.key, super.key,

View File

@@ -5,7 +5,6 @@ import 'package:PiliPlus/main.dart';
import 'package:PiliPlus/pages/common/common_publish_page.dart'; import 'package:PiliPlus/pages/common/common_publish_page.dart';
import 'package:PiliPlus/pages/emote/view.dart'; import 'package:PiliPlus/pages/emote/view.dart';
import 'package:PiliPlus/pages/video/detail/reply_new/toolbar_icon_button.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:PiliPlus/utils/storage.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -275,7 +274,7 @@ class _ReplyPageState extends CommonPublishPageState<ReplyPage> {
root: widget.root!, root: widget.root!,
parent: widget.parent!, parent: widget.parent!,
message: widget.replyItem != null && widget.replyItem.root != 0 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, : message,
pictures: pictures, pictures: pictures,
syncToDynamic: _syncToDynamic.value, syncToDynamic: _syncToDynamic.value,

View File

@@ -1,8 +1,6 @@
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart'; import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
import 'package:PiliPlus/http/loading_state.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/pages/common/reply_controller.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/id_utils.dart';
import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -61,97 +59,78 @@ class VideoReplyReplyController extends ReplyController
@override @override
bool customHandleResponse(Success response) { bool customHandleResponse(Success response) {
if (GlobalData().grpcReply) { dynamic replies = response.response;
dynamic replies = response.response; // reply2Reply // isDialogue.not
// reply2Reply // isDialogue.not if (replies is DetailListReply) {
if (replies is DetailListReply) { count.value = replies.root.count.toInt();
count.value = replies.root.count.toInt(); if (cursor == null && firstFloor == null) {
if (cursor == null && firstFloor == null) { firstFloor = replies.root;
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;
}
} }
upMid ??= replies.subjectControl.upMid.toInt(); if (id != null) {
cursor = replies.cursor; index = replies.root.replies
if (isDialogue) { .map((item) => item.id.toInt())
if (replies.replies.isEmpty) { .toList()
isEnd = true; .indexOf(id!);
} if (index == -1) {
} else { index = null;
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 { } 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) { upMid ??= replies.subjectControl.upMid.toInt();
isEnd = true; cursor = replies.cursor;
} if (isDialogue) {
} else { if (replies.replies.isEmpty) {
if (replies.cursor.isEnd || isEnd = true;
replies.root.replies.length >= count.value) {
isEnd = true;
}
}
if (isDialogue) {
loadingState.value = LoadingState.success(replies.replies);
} else {
loadingState.value = LoadingState.success(replies.root.replies);
} }
} else { } else {
if (response.response.root != null) { if (replies.root.replies.isEmpty) {
firstFloor = response.response.root;
hasRoot = true;
}
List<ReplyItemModel> replies = response.response.replies;
count.value = response.response.page.count;
if (replies.isEmpty) {
isEnd = true; 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; return true;
} }
@@ -168,26 +147,17 @@ class VideoReplyReplyController extends ReplyController
), ),
antiGoodsReply: antiGoodsReply, antiGoodsReply: antiGoodsReply,
) )
: GlobalData().grpcReply : ReplyHttp.replyReplyListGrpc(
? ReplyHttp.replyReplyListGrpc( type: replyType.index,
type: replyType.index, oid: oid,
oid: oid, root: rpid,
root: rpid, rpid: id ?? 0,
rpid: id ?? 0, cursor: CursorReq(
cursor: CursorReq( next: cursor?.next,
next: cursor?.next, mode: mode.value,
mode: mode.value, ),
), antiGoodsReply: antiGoodsReply,
antiGoodsReply: antiGoodsReply, );
)
: ReplyHttp.replyReplyList(
isLogin: isLogin,
oid: oid,
root: rpid,
pageNum: currentPage,
type: replyType.index,
antiGoodsReply: antiGoodsReply,
);
@override @override
queryBySort() { queryBySort() {

View File

@@ -2,13 +2,10 @@ import 'package:PiliPlus/common/widgets/loading_widget.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart'; import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart'; import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
import 'package:PiliPlus/http/loading_state.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/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/widgets/reply_item_grpc.dart';
import 'package:PiliPlus/pages/video/detail/reply_new/reply_page.dart'; import 'package:PiliPlus/pages/video/detail/reply_new/reply_page.dart';
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
@@ -181,41 +178,23 @@ class _VideoReplyReplyPanelState
_videoReplyReplyController.loadingState.value, index); _videoReplyReplyController.loadingState.value, index);
} else if (firstFloor != null) { } else if (firstFloor != null) {
if (index == 0) { if (index == 0) {
return GlobalData().grpcReply return ReplyItemGrpc(
? ReplyItemGrpc( replyItem: firstFloor,
replyItem: firstFloor, replyLevel: '2',
replyLevel: '2', showReplyRow: false,
showReplyRow: false, replyType: widget.replyType,
replyType: widget.replyType, needDivider: false,
needDivider: false, onReply: () {
onReply: () { _onReply(firstFloor, -1);
_onReply(firstFloor, -1); },
}, upMid: _videoReplyReplyController.upMid,
upMid: _videoReplyReplyController.upMid, isTop: widget.isTop,
isTop: widget.isTop, onViewImage: widget.onViewImage,
onViewImage: widget.onViewImage, onDismissed: widget.onDismissed,
onDismissed: widget.onDismissed, callback: _getImageCallback,
callback: _getImageCallback, onCheckReply: (item) => _videoReplyReplyController
onCheckReply: (item) => .onCheckReply(context, 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),
);
} else if (index == 1) { } else if (index == 1) {
return Divider( return Divider(
height: 20, height: 20,
@@ -273,30 +252,28 @@ class _VideoReplyReplyPanelState
) )
: const SizedBox.shrink(), : const SizedBox.shrink(),
), ),
if (GlobalData().grpcReply) SizedBox(
SizedBox( height: 35,
height: 35, child: TextButton.icon(
child: TextButton.icon( onPressed: () => _videoReplyReplyController.queryBySort(),
onPressed: () => _videoReplyReplyController.queryBySort(), icon: Icon(
icon: Icon( Icons.sort,
Icons.sort, size: 16,
size: 16, color: Theme.of(context).colorScheme.secondary,
color: Theme.of(context).colorScheme.secondary, ),
), label: Obx(
label: Obx( () => Text(
() => Text( _videoReplyReplyController.mode.value == Mode.MAIN_LIST_HOT
_videoReplyReplyController.mode.value == ? '按热度'
Mode.MAIN_LIST_HOT : '按时间',
? '按热度' style: TextStyle(
: '按时间', fontSize: 13,
style: TextStyle( color: Theme.of(context).colorScheme.secondary,
fontSize: 13,
color: Theme.of(context).colorScheme.secondary,
),
), ),
), ),
), ),
) ),
)
], ],
), ),
); );
@@ -333,7 +310,7 @@ class _VideoReplyReplyPanelState
void _onReply(dynamic item, int index) { void _onReply(dynamic item, int index) {
dynamic oid = item?.oid.toInt(); dynamic oid = item?.oid.toInt();
dynamic root = GlobalData().grpcReply ? item?.id.toInt() : item?.rpid; dynamic root = item?.id.toInt();
dynamic key = oid + root; dynamic key = oid + root;
Navigator.of(context) Navigator.of(context)
@@ -371,60 +348,32 @@ class _VideoReplyReplyPanelState
.then((res) { .then((res) {
if (res != null) { if (res != null) {
_savedReplies[key] = null; _savedReplies[key] = null;
if (GlobalData().grpcReply) { ReplyInfo replyInfo = Utils.replyCast(res);
ReplyInfo replyInfo = Utils.replyCast(res); List list = _videoReplyReplyController.loadingState.value is Success
List list = _videoReplyReplyController.loadingState.value is Success ? (_videoReplyReplyController.loadingState.value as Success)
? (_videoReplyReplyController.loadingState.value as Success) .response
.response : <ReplyInfo>[];
: <ReplyInfo>[]; list.insert(index + 1, replyInfo);
list.insert(index + 1, replyInfo); _videoReplyReplyController.count.value += 1;
_videoReplyReplyController.count.value += 1; _videoReplyReplyController.loadingState.value =
_videoReplyReplyController.loadingState.value = LoadingState.success(list);
LoadingState.success(list); if (_videoReplyReplyController.enableCommAntifraud && mounted) {
if (_videoReplyReplyController.enableCommAntifraud && mounted) { _videoReplyReplyController.checkReply(
_videoReplyReplyController.checkReply( context: context,
context: context, oid: oid,
oid: oid, rpid: root,
rpid: root, replyType: widget.replyType.index,
replyType: widget.replyType.index, replyId: replyInfo.id.toInt(),
replyId: replyInfo.id.toInt(), message: replyInfo.content.message,
message: replyInfo.content.message, //
// root: replyInfo.root.toInt(),
root: replyInfo.root.toInt(), parent: replyInfo.parent.toInt(),
parent: replyInfo.parent.toInt(), ctime: replyInfo.ctime.toInt(),
ctime: replyInfo.ctime.toInt(), pictures: replyInfo.content.pictures
pictures: replyInfo.content.pictures .map((item) => item.toProto3Json())
.map((item) => item.toProto3Json()) .toList(),
.toList(), mid: replyInfo.mid.toInt(),
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,
);
}
} }
} }
}); });
@@ -489,78 +438,51 @@ class _VideoReplyReplyPanelState
return _replyItem(loadingState.response[index], index); return _replyItem(loadingState.response[index], index);
} }
}(), }(),
Error() => replyErrorWidget( Error() => errorWidget(
context, errMsg: loadingState.errMsg,
false, callback: _videoReplyReplyController.onReload,
loadingState.errMsg,
_videoReplyReplyController.onReload,
), ),
LoadingState() => throw UnimplementedError(), LoadingState() => throw UnimplementedError(),
}; };
} }
Widget _replyItem(replyItem, index) { Widget _replyItem(replyItem, index) {
return GlobalData().grpcReply return ReplyItemGrpc(
? ReplyItemGrpc( replyItem: replyItem,
replyItem: replyItem, replyLevel: widget.isDialogue ? '3' : '2',
replyLevel: widget.isDialogue ? '3' : '2', showReplyRow: false,
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, replyType: widget.replyType,
onReply: () { source: 'videoDetail',
_onReply(replyItem, index); isDialogue: true,
}, ),
onDelete: (rpid, frpid) { );
List list = },
(_videoReplyReplyController.loadingState.value as Success) onViewImage: widget.onViewImage,
.response; onDismissed: widget.onDismissed,
list = list.where((item) => item.id != rpid).toList(); callback: _getImageCallback,
_videoReplyReplyController.count.value -= 1; onCheckReply: (item) =>
_videoReplyReplyController.loadingState.value = _videoReplyReplyController.onCheckReply(context, item),
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),
);
} }
int _itemCount(LoadingState loadingState) { int _itemCount(LoadingState loadingState) {

View File

@@ -6,12 +6,9 @@ import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/list_sheet.dart'; import 'package:PiliPlus/common/widgets/list_sheet.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/main.dart'; import 'package:PiliPlus/main.dart';
import 'package:PiliPlus/models/bangumi/info.dart';
import 'package:PiliPlus/models/common/reply_type.dart'; import 'package:PiliPlus/models/common/reply_type.dart';
import 'package:PiliPlus/pages/bangumi/introduction/widgets/intro_detail.dart' import 'package:PiliPlus/pages/bangumi/introduction/widgets/intro_detail.dart'
as bangumi; 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/page.dart';
import 'package:PiliPlus/pages/video/detail/introduction/widgets/season.dart'; import 'package:PiliPlus/pages/video/detail/introduction/widgets/season.dart';
import 'package:PiliPlus/pages/video/detail/member/controller.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/pages/video/detail/widgets/ai_detail.dart';
import 'package:PiliPlus/utils/download.dart'; import 'package:PiliPlus/utils/download.dart';
import 'package:PiliPlus/utils/extension.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/id_utils.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:auto_orientation/auto_orientation.dart'; import 'package:auto_orientation/auto_orientation.dart';
@@ -53,6 +49,7 @@ import '../../../services/shutdown_timer_service.dart';
import 'widgets/header_control.dart'; import 'widgets/header_control.dart';
import 'package:PiliPlus/common/widgets/spring_physics.dart'; import 'package:PiliPlus/common/widgets/spring_physics.dart';
@Deprecated('Use VideoDetailPageV instead')
class VideoDetailPage extends StatefulWidget { class VideoDetailPage extends StatefulWidget {
const VideoDetailPage({super.key}); const VideoDetailPage({super.key});
@@ -1755,7 +1752,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
void replyReply(replyItem, id, isTop) { void replyReply(replyItem, id, isTop) {
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
int oid = replyItem.oid.toInt(); int oid = replyItem.oid.toInt();
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; int rpid = replyItem.id.toInt();
videoDetailController.childKey.currentState?.showBottomSheet( videoDetailController.childKey.currentState?.showBottomSheet(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
(context) => VideoReplyReplyPanel( (context) => VideoReplyReplyPanel(
@@ -1785,15 +1782,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
videoDetailController.childKey.currentState?.showBottomSheet( videoDetailController.childKey.currentState?.showBottomSheet(
shape: const RoundedRectangleBorder(), shape: const RoundedRectangleBorder(),
backgroundColor: themeData.colorScheme.surface, backgroundColor: themeData.colorScheme.surface,
(context) => videoDetail is BangumiInfoModel (context) => bangumi.IntroDetail(
? bangumi.IntroDetail( bangumiDetail: videoDetail,
bangumiDetail: videoDetail, videoTags: videoTags,
videoTags: videoTags, ),
)
: video.IntroDetail(
videoDetail: videoDetail,
videoTags: videoTags,
),
); );
} }

View File

@@ -7,12 +7,9 @@ import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/list_sheet.dart'; import 'package:PiliPlus/common/widgets/list_sheet.dart';
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/main.dart'; import 'package:PiliPlus/main.dart';
import 'package:PiliPlus/models/bangumi/info.dart';
import 'package:PiliPlus/models/common/reply_type.dart'; import 'package:PiliPlus/models/common/reply_type.dart';
import 'package:PiliPlus/pages/bangumi/introduction/widgets/intro_detail.dart' import 'package:PiliPlus/pages/bangumi/introduction/widgets/intro_detail.dart'
as bangumi; 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/page.dart';
import 'package:PiliPlus/pages/video/detail/introduction/widgets/season.dart'; import 'package:PiliPlus/pages/video/detail/introduction/widgets/season.dart';
import 'package:PiliPlus/pages/video/detail/member/controller.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/pages/video/detail/widgets/ai_detail.dart';
import 'package:PiliPlus/utils/download.dart'; import 'package:PiliPlus/utils/download.dart';
import 'package:PiliPlus/utils/extension.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/id_utils.dart';
import 'package:PiliPlus/utils/utils.dart'; import 'package:PiliPlus/utils/utils.dart';
import 'package:auto_orientation/auto_orientation.dart'; import 'package:auto_orientation/auto_orientation.dart';
@@ -2206,7 +2202,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
void replyReply(replyItem, id, isTop) { void replyReply(replyItem, id, isTop) {
EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () { EasyThrottle.throttle('replyReply', const Duration(milliseconds: 500), () {
int oid = replyItem.oid.toInt(); int oid = replyItem.oid.toInt();
int rpid = GlobalData().grpcReply ? replyItem.id.toInt() : replyItem.rpid; int rpid = replyItem.id.toInt();
videoDetailController.childKey.currentState?.showBottomSheet( videoDetailController.childKey.currentState?.showBottomSheet(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
(context) => VideoReplyReplyPanel( (context) => VideoReplyReplyPanel(
@@ -2235,15 +2231,10 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
showIntroDetail(videoDetail, videoTags) { showIntroDetail(videoDetail, videoTags) {
videoDetailController.childKey.currentState?.showBottomSheet( videoDetailController.childKey.currentState?.showBottomSheet(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
(context) => videoDetail is BangumiInfoModel (context) => bangumi.IntroDetail(
? bangumi.IntroDetail( bangumiDetail: videoDetail,
bangumiDetail: videoDetail, videoTags: videoTags,
videoTags: videoTags, ),
)
: video.IntroDetail(
videoDetail: videoDetail,
videoTags: videoTags,
),
); );
} }

View File

@@ -1,8 +1,6 @@
class GlobalData { class GlobalData {
int imgQuality = 10; int imgQuality = 10;
bool grpcReply = true;
int replyLengthLimit = 6; int replyLengthLimit = 6;
// 私有构造函数 // 私有构造函数

View File

@@ -264,9 +264,6 @@ class GStorage {
static double get subtitleFontScaleFS => static double get subtitleFontScaleFS =>
setting.get(SettingBoxKey.subtitleFontScaleFS, defaultValue: 1.5); setting.get(SettingBoxKey.subtitleFontScaleFS, defaultValue: 1.5);
static bool get grpcReply =>
setting.get(SettingBoxKey.grpcReply, defaultValue: true);
static bool get showViewPoints => static bool get showViewPoints =>
setting.get(SettingBoxKey.showViewPoints, defaultValue: true); setting.get(SettingBoxKey.showViewPoints, defaultValue: true);
@@ -402,9 +399,6 @@ class GStorage {
static bool get expandDynLivePanel => GStorage.setting static bool get expandDynLivePanel => GStorage.setting
.get(SettingBoxKey.expandDynLivePanel, defaultValue: false); .get(SettingBoxKey.expandDynLivePanel, defaultValue: false);
static bool collapsibleVideoPage = GStorage.setting
.get(SettingBoxKey.collapsibleVideoPage, defaultValue: true);
static bool slideDismissReplyPage = GStorage.setting static bool slideDismissReplyPage = GStorage.setting
.get(SettingBoxKey.slideDismissReplyPage, defaultValue: Platform.isIOS); .get(SettingBoxKey.slideDismissReplyPage, defaultValue: Platform.isIOS);
@@ -529,7 +523,6 @@ class GStorage {
// 设置全局变量 // 设置全局变量
GlobalData() GlobalData()
..imgQuality = defaultPicQa ..imgQuality = defaultPicQa
..grpcReply = grpcReply
..replyLengthLimit = replyLengthLimit; ..replyLengthLimit = replyLengthLimit;
} }
@@ -658,7 +651,6 @@ class SettingBoxKey {
checkDynamic = 'checkDynamic', checkDynamic = 'checkDynamic',
dynamicPeriod = 'dynamicPeriod', dynamicPeriod = 'dynamicPeriod',
schemeVariant = 'schemeVariant', schemeVariant = 'schemeVariant',
grpcReply = 'grpcReply',
showViewPoints = 'showViewPoints', showViewPoints = 'showViewPoints',
showRelatedVideo = 'showRelatedVideo', showRelatedVideo = 'showRelatedVideo',
showVideoReply = 'showVideoReply', showVideoReply = 'showVideoReply',
@@ -708,7 +700,6 @@ class SettingBoxKey {
antiGoodsReply = 'antiGoodsReply', antiGoodsReply = 'antiGoodsReply',
expandDynLivePanel = 'expandDynLivePanel', expandDynLivePanel = 'expandDynLivePanel',
springDescription = 'springDescription', springDescription = 'springDescription',
collapsibleVideoPage = 'collapsibleVideoPage',
enableHttp2 = 'enableHttp2', enableHttp2 = 'enableHttp2',
slideDismissReplyPage = 'slideDismissReplyPage', slideDismissReplyPage = 'slideDismissReplyPage',
showFSActionItem = 'showFSActionItem', showFSActionItem = 'showFSActionItem',

View File

@@ -233,7 +233,7 @@ class Utils {
}) { }) {
if (off) { if (off) {
Get.offNamed( Get.offNamed(
'${GStorage.collapsibleVideoPage ? '/videoV' : '/video'}?$page', '/videoV?$page',
arguments: arguments, arguments: arguments,
id: id, id: id,
preventDuplicates: preventDuplicates, preventDuplicates: preventDuplicates,
@@ -241,7 +241,7 @@ class Utils {
); );
} else { } else {
Get.toNamed( Get.toNamed(
'${GStorage.collapsibleVideoPage ? '/videoV' : '/video'}?$page', '/videoV?$page',
arguments: arguments, arguments: arguments,
id: id, id: id,
preventDuplicates: preventDuplicates, preventDuplicates: preventDuplicates,