diff --git a/lib/common/widgets/list_sheet.dart b/lib/common/widgets/list_sheet.dart index f6bf5046..838c2b29 100644 --- a/lib/common/widgets/list_sheet.dart +++ b/lib/common/widgets/list_sheet.dart @@ -142,21 +142,15 @@ class _ListSheetContentState extends CommonSlidePageState }(); } WidgetsBinding.instance.addPostFrameCallback((_) { - if (GStorage.collapsibleVideoPage) { - if (mounted) { - setState(() { - _isInit = false; - }); - WidgetsBinding.instance.addPostFrameCallback((_) { - try { - itemScrollController[_index].jumpTo(index: currentIndex); - } catch (_) {} - }); - } - } else { - try { - itemScrollController[_index].jumpTo(index: currentIndex); - } catch (_) {} + if (mounted) { + setState(() { + _isInit = false; + }); + WidgetsBinding.instance.addPostFrameCallback((_) { + try { + itemScrollController[_index].jumpTo(index: currentIndex); + } catch (_) {} + }); } }); } @@ -295,7 +289,7 @@ class _ListSheetContentState extends CommonSlidePageState @override Widget build(BuildContext context) { - if (GStorage.collapsibleVideoPage && _isInit) { + if (_isInit) { return CustomScrollView( physics: const NeverScrollableScrollPhysics(), ); diff --git a/lib/common/widgets/loading_widget.dart b/lib/common/widgets/loading_widget.dart index f9f5122e..4ce18970 100644 --- a/lib/common/widgets/loading_widget.dart +++ b/lib/common/widgets/loading_widget.dart @@ -1,5 +1,4 @@ import 'package:PiliPlus/common/widgets/http_error.dart'; -import 'package:PiliPlus/utils/global_data.dart'; import 'package:flutter/material.dart'; 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, - ); diff --git a/lib/http/reply.dart b/lib/http/reply.dart index 92ed1e3a..a58ce96f 100644 --- a/lib/http/reply.dart +++ b/lib/http/reply.dart @@ -20,6 +20,7 @@ class ReplyHttp { static RegExp replyRegExp = RegExp(GStorage.banWordForReply, caseSensitive: false); + @Deprecated('Use replyListGrpc instead') static Future replyList({ required bool isLogin, required int oid, @@ -214,6 +215,7 @@ class ReplyHttp { return false; } + @Deprecated('Use replyReplyListGrpc instead') static Future replyReplyList({ required bool isLogin, required int oid, diff --git a/lib/main.dart b/lib/main.dart index 9d217506..b2a45b8b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,7 +16,6 @@ import 'package:hive/hive.dart'; import 'package:PiliPlus/common/widgets/custom_toast.dart'; import 'package:PiliPlus/http/init.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/pages/main/view.dart'; import 'package:PiliPlus/services/service_locator.dart'; @@ -218,7 +217,6 @@ class MyApp extends StatelessWidget { ), navigatorObservers: [ FlutterSmartDialog.observer, - VideoDetailPage.routeObserver, VideoDetailPageV.routeObserver, MainApp.routeObserver, ], diff --git a/lib/pages/common/common_collapse_slide_page.dart b/lib/pages/common/common_collapse_slide_page.dart index 6d70243b..d0d3c195 100644 --- a/lib/pages/common/common_collapse_slide_page.dart +++ b/lib/pages/common/common_collapse_slide_page.dart @@ -13,20 +13,18 @@ abstract class CommonCollapseSlidePageState @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(), ); diff --git a/lib/pages/common/reply_controller.dart b/lib/pages/common/reply_controller.dart index a2c8a341..fcc1a391 100644 --- a/lib/pages/common/reply_controller.dart +++ b/lib/pages/common/reply_controller.dart @@ -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 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 replyInfo = ReplyItemModel.fromJson(res, ''); - if (oid != null) { - response.replies?.insert(hasUpTop ? 1 : 0, replyInfo); - } else { - response.replies?[index].replies ??= []; - 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) { diff --git a/lib/pages/dynamics/detail/controller.dart b/lib/pages/dynamics/detail/controller.dart index a545b459..83bd9b06 100644 --- a/lib/pages/dynamics/detail/controller.dart +++ b/lib/pages/dynamics/detail/controller.dart @@ -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 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 customGetData() => ReplyHttp.replyListGrpc( + type: type, + oid: oid, + cursor: CursorReq( + next: cursor?.next ?? $fixnum.Int64(0), + mode: mode.value, + ), + antiGoodsReply: antiGoodsReply, + ); } diff --git a/lib/pages/dynamics/detail/view.dart b/lib/pages/dynamics/detail/view.dart index eac6be5b..2a0a995c 100644 --- a/lib/pages/dynamics/detail/view.dart +++ b/lib/pages/dynamics/detail/view.dart @@ -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 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 ), ); } 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 : HttpError( callback: _dynamicDetailController.onReload, ), - Error() => replyErrorWidget( - context, - true, - loadingState.errMsg, - _dynamicDetailController.onReload, + Error() => errorWidget( + errMsg: loadingState.errMsg, + callback: _dynamicDetailController.onReload, ), LoadingState() => throw UnimplementedError(), }; diff --git a/lib/pages/html/controller.dart b/lib/pages/html/controller.dart index f99f287a..a127caef 100644 --- a/lib/pages/html/controller.dart +++ b/lib/pages/html/controller.dart @@ -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 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, + ); } } diff --git a/lib/pages/html/view.dart b/lib/pages/html/view.dart index bea617ad..bb772d91 100644 --- a/lib/pages/html/view.dart +++ b/lib/pages/html/view.dart @@ -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 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 ), ); } 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(), }; diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index f8dc6fc8..2362b52f 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -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 { diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index f244852e..850cea54 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -1515,21 +1515,6 @@ List 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 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: '侧滑关闭二级评论页面', diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 4bbcad38..b3ef6a5f 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -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(); } diff --git a/lib/pages/video/detail/reply/controller.dart b/lib/pages/video/detail/reply/controller.dart index 817e9518..6957191a 100644 --- a/lib/pages/video/detail/reply/controller.dart +++ b/lib/pages/video/detail/reply/controller.dart @@ -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 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 customGetData() => ReplyHttp.replyListGrpc( + oid: aid, + cursor: CursorReq( + next: cursor?.next ?? $fixnum.Int64(0), + mode: mode.value, + ), + antiGoodsReply: antiGoodsReply, + ); @override void onClose() { diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index 40831678..eb920101 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -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 @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 ), ); } 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 errMsg: '还没有评论', callback: _videoReplyController.onReload, ), - Error() => replyErrorWidget( - context, - true, - loadingState.errMsg, - _videoReplyController.onReload, + Error() => errorWidget( + errMsg: loadingState.errMsg, + callback: _videoReplyController.onReload, ), LoadingState() => throw UnimplementedError(), }; diff --git a/lib/pages/video/detail/reply/widgets/reply_item.dart b/lib/pages/video/detail/reply/widgets/reply_item.dart index 630a0aa3..b7c8e85c 100644 --- a/lib/pages/video/detail/reply/widgets/reply_item.dart +++ b/lib/pages/video/detail/reply/widgets/reply_item.dart @@ -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, diff --git a/lib/pages/video/detail/reply_new/reply_page.dart b/lib/pages/video/detail/reply_new/reply_page.dart index 01d0ceab..4fe4586e 100644 --- a/lib/pages/video/detail/reply_new/reply_page.dart +++ b/lib/pages/video/detail/reply_new/reply_page.dart @@ -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 { 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, diff --git a/lib/pages/video/detail/reply_reply/controller.dart b/lib/pages/video/detail/reply_reply/controller.dart index 3b630418..4eacd42e 100644 --- a/lib/pages/video/detail/reply_reply/controller.dart +++ b/lib/pages/video/detail/reply_reply/controller.dart @@ -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 list = loadingState.value is Success - ? (loadingState.value as Success).response - : []; - 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 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 list = loadingState.value is Success + ? (loadingState.value as Success).response + : []; + 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() { diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 56d6fb72..7afa2270 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -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 - : []; - 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 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 + : []; + 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) { diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index fdd978c8..87b9d534 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -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 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 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, + ), ); } diff --git a/lib/pages/video/detail/view_v.dart b/lib/pages/video/detail/view_v.dart index 34c0704b..a2ea5102 100644 --- a/lib/pages/video/detail/view_v.dart +++ b/lib/pages/video/detail/view_v.dart @@ -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 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 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, + ), ); } diff --git a/lib/utils/global_data.dart b/lib/utils/global_data.dart index 43791fda..f7c34f45 100644 --- a/lib/utils/global_data.dart +++ b/lib/utils/global_data.dart @@ -1,8 +1,6 @@ class GlobalData { int imgQuality = 10; - bool grpcReply = true; - int replyLengthLimit = 6; // 私有构造函数 diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 6fff204c..fee20520 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -264,9 +264,6 @@ class GStorage { static double get subtitleFontScaleFS => setting.get(SettingBoxKey.subtitleFontScaleFS, defaultValue: 1.5); - static bool get grpcReply => - setting.get(SettingBoxKey.grpcReply, defaultValue: true); - static bool get showViewPoints => setting.get(SettingBoxKey.showViewPoints, defaultValue: true); @@ -402,9 +399,6 @@ class GStorage { static bool get expandDynLivePanel => GStorage.setting .get(SettingBoxKey.expandDynLivePanel, defaultValue: false); - static bool collapsibleVideoPage = GStorage.setting - .get(SettingBoxKey.collapsibleVideoPage, defaultValue: true); - static bool slideDismissReplyPage = GStorage.setting .get(SettingBoxKey.slideDismissReplyPage, defaultValue: Platform.isIOS); @@ -529,7 +523,6 @@ class GStorage { // 设置全局变量 GlobalData() ..imgQuality = defaultPicQa - ..grpcReply = grpcReply ..replyLengthLimit = replyLengthLimit; } @@ -658,7 +651,6 @@ class SettingBoxKey { checkDynamic = 'checkDynamic', dynamicPeriod = 'dynamicPeriod', schemeVariant = 'schemeVariant', - grpcReply = 'grpcReply', showViewPoints = 'showViewPoints', showRelatedVideo = 'showRelatedVideo', showVideoReply = 'showVideoReply', @@ -708,7 +700,6 @@ class SettingBoxKey { antiGoodsReply = 'antiGoodsReply', expandDynLivePanel = 'expandDynLivePanel', springDescription = 'springDescription', - collapsibleVideoPage = 'collapsibleVideoPage', enableHttp2 = 'enableHttp2', slideDismissReplyPage = 'slideDismissReplyPage', showFSActionItem = 'showFSActionItem', diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 15af32c8..9d340353 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -233,7 +233,7 @@ class Utils { }) { if (off) { Get.offNamed( - '${GStorage.collapsibleVideoPage ? '/videoV' : '/video'}?$page', + '/videoV?$page', arguments: arguments, id: id, preventDuplicates: preventDuplicates, @@ -241,7 +241,7 @@ class Utils { ); } else { Get.toNamed( - '${GStorage.collapsibleVideoPage ? '/videoV' : '/video'}?$page', + '/videoV?$page', arguments: arguments, id: id, preventDuplicates: preventDuplicates,