From 8ddf42fff1207e6f78d82054e7a2c9e561dfaee7 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sun, 23 Mar 2025 23:18:41 +0800 Subject: [PATCH] opt: switch btn Signed-off-by: bggRGjQaUbCoE --- lib/common/widgets/list_sheet.dart | 4 +- .../common/common_collapse_slide_page.dart | 4 +- lib/pages/video/detail/controller.dart | 143 ++++++++---------- lib/pages/video/detail/view.dart | 6 +- lib/pages/video/detail/view_v.dart | 6 +- lib/plugin/pl_player/view.dart | 22 +-- lib/utils/utils.dart | 110 +++++++------- 7 files changed, 143 insertions(+), 152 deletions(-) diff --git a/lib/common/widgets/list_sheet.dart b/lib/common/widgets/list_sheet.dart index ac018314..f6bf5046 100644 --- a/lib/common/widgets/list_sheet.dart +++ b/lib/common/widgets/list_sheet.dart @@ -142,7 +142,7 @@ class _ListSheetContentState extends CommonSlidePageState }(); } WidgetsBinding.instance.addPostFrameCallback((_) { - if (enableSlide && GStorage.collapsibleVideoPage) { + if (GStorage.collapsibleVideoPage) { if (mounted) { setState(() { _isInit = false; @@ -295,7 +295,7 @@ class _ListSheetContentState extends CommonSlidePageState @override Widget build(BuildContext context) { - if (enableSlide && GStorage.collapsibleVideoPage && _isInit) { + if (GStorage.collapsibleVideoPage && _isInit) { return CustomScrollView( physics: const NeverScrollableScrollPhysics(), ); diff --git a/lib/pages/common/common_collapse_slide_page.dart b/lib/pages/common/common_collapse_slide_page.dart index 1c002b27..6d70243b 100644 --- a/lib/pages/common/common_collapse_slide_page.dart +++ b/lib/pages/common/common_collapse_slide_page.dart @@ -13,7 +13,7 @@ abstract class CommonCollapseSlidePageState @override void initState() { super.initState(); - if (enableSlide && GStorage.collapsibleVideoPage) { + if (GStorage.collapsibleVideoPage) { WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { setState(() { @@ -26,7 +26,7 @@ abstract class CommonCollapseSlidePageState @override Widget build(BuildContext context) { - if (enableSlide && GStorage.collapsibleVideoPage && _isInit) { + if (GStorage.collapsibleVideoPage && _isInit) { return CustomScrollView( physics: const NeverScrollableScrollPhysics(), ); diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 5ddc01d6..0e33c73c 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -20,8 +20,6 @@ import 'package:PiliPlus/pages/search/widgets/search_text.dart'; import 'package:PiliPlus/pages/video/detail/introduction/controller.dart'; import 'package:PiliPlus/pages/video/detail/note/note_list_page.dart'; import 'package:PiliPlus/pages/video/detail/post_panel/post_panel.dart'; -import 'package:PiliPlus/pages/video/detail/related/controller.dart'; -import 'package:PiliPlus/pages/video/detail/reply/controller.dart'; import 'package:PiliPlus/pages/video/detail/widgets/send_danmaku_panel.dart'; import 'package:PiliPlus/pages/video/detail/widgets/media_list_panel.dart'; import 'package:PiliPlus/utils/extension.dart'; @@ -388,92 +386,77 @@ class VideoDetailController extends GetxController // 稍后再看面板展开 showMediaListPanel(context) { if (mediaList.isNotEmpty) { - childKey.currentState?.showBottomSheet( - backgroundColor: Colors.transparent, - (context) => MediaListPanel( - mediaList: mediaList, - changeMediaList: (bvid, cid, aid, cover) { - try { - Get.find(tag: heroTag) - .changeSeasonOrbangu(null, bvid, cid, aid, cover); - } catch (_) {} - }, - panelTitle: watchLaterTitle, - getBvId: () => bvid, - count: Get.arguments['count'], - loadMoreMedia: getMediaList, - desc: _mediaDesc, - onReverse: () { - _mediaDesc = !_mediaDesc; - getMediaList(isReverse: true); - }, - loadPrevious: Get.arguments['isContinuePlaying'] == true - ? () { - getMediaList(isLoadPrevious: true); - } - : null, - onDelete: sourceType == 'watchLater' || - (sourceType == 'fav' && Get.arguments?['isOwner'] == true) - ? (index) async { - if (sourceType == 'watchLater') { - var res = await UserHttp.toViewDel( - aids: [mediaList[index].aid], - ); - if (res['status']) { - mediaList.removeAt(index); - } - SmartDialog.showToast(res['msg']); - } else { - final item = mediaList[index]; - var res = await VideoHttp.delFav( - ids: ['${item.aid}:${item.type}'], - delIds: '${Get.arguments?['mediaId']}', - ); - if (res['status']) { - mediaList.removeAt(index); - SmartDialog.showToast('取消收藏'); - } else { + Widget panel() => MediaListPanel( + mediaList: mediaList, + changeMediaList: (bvid, cid, aid, cover) { + try { + Get.find(tag: heroTag) + .changeSeasonOrbangu(null, bvid, cid, aid, cover); + } catch (_) {} + }, + panelTitle: watchLaterTitle, + getBvId: () => bvid, + count: Get.arguments['count'], + loadMoreMedia: getMediaList, + desc: _mediaDesc, + onReverse: () { + _mediaDesc = !_mediaDesc; + getMediaList(isReverse: true); + }, + loadPrevious: Get.arguments['isContinuePlaying'] == true + ? () { + getMediaList(isLoadPrevious: true); + } + : null, + onDelete: sourceType == 'watchLater' || + (sourceType == 'fav' && Get.arguments?['isOwner'] == true) + ? (index) async { + if (sourceType == 'watchLater') { + var res = await UserHttp.toViewDel( + aids: [mediaList[index].aid], + ); + if (res['status']) { + mediaList.removeAt(index); + } SmartDialog.showToast(res['msg']); + } else { + final item = mediaList[index]; + var res = await VideoHttp.delFav( + ids: ['${item.aid}:${item.type}'], + delIds: '${Get.arguments?['mediaId']}', + ); + if (res['status']) { + mediaList.removeAt(index); + SmartDialog.showToast('取消收藏'); + } else { + SmartDialog.showToast(res['msg']); + } } } - } - : null, - ), - ); + : null, + ); + if (plPlayerController.isFullScreen.value) { + Utils.showFSSheet( + context, + child: plPlayerController.darkVideoPage && MyApp.darkThemeData != null + ? Theme( + data: MyApp.darkThemeData!, + child: panel(), + ) + : panel(), + isFullScreen: () => plPlayerController.isFullScreen.value, + ); + } else { + childKey.currentState?.showBottomSheet( + backgroundColor: Colors.transparent, + (context) => panel(), + ); + } } else { getMediaList(); } } - // 切换稍后再看 - Future changeMediaList(bvid, cid, aid, cover) async { - try { - this.bvid = bvid; - oid.value = aid ?? IdUtils.bv2av(bvid); - this.cid.value = cid; - danmakuCid.value = cid; - videoItem['pic'] = cover; - queryVideoUrl(); - - if (showReply) { - Get.find(tag: heroTag) - ..aid = aid - ..onRefresh(); - } - - Get.find(tag: heroTag) - ..lastPlayCid.value = cid - ..bvid = bvid - ..queryVideoIntro(); - - if (showRelatedVideo) { - Get.find(tag: heroTag) - ..bvid = bvid - ..onRefresh(); - } - } catch (_) {} - } - int? _lastPos; double? _blockLimit; List>? _blockSettings; diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 2f7b6f8a..b5748419 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -1782,7 +1782,11 @@ class _VideoDetailPageState extends State ); } - showEpisodes(index, season, episodes, bvid, aid, cid) { + showEpisodes([index, season, episodes, bvid, aid, cid]) { + if (bvid == null) { + videoDetailController.showMediaListPanel(context); + return; + } Widget listSheetContent([bool? enableSlide]) => ListSheetContent( enableSlide: enableSlide, index: index, diff --git a/lib/pages/video/detail/view_v.dart b/lib/pages/video/detail/view_v.dart index 34a8345e..c36f0801 100644 --- a/lib/pages/video/detail/view_v.dart +++ b/lib/pages/video/detail/view_v.dart @@ -2185,7 +2185,11 @@ class _VideoDetailPageVState extends State ); } - showEpisodes(index, season, episodes, bvid, aid, cid) { + showEpisodes([index, season, episodes, bvid, aid, cid]) { + if (bvid == null) { + videoDetailController.showMediaListPanel(context); + return; + } Widget listSheetContent([bool? enableSlide]) => ListSheetContent( enableSlide: enableSlide, index: index, diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index dedcd3c7..083b3ae4 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -262,10 +262,7 @@ class _PLVideoPlayerState extends State bool isPage = videoIntroController?.videoDetail.value.pages != null && videoIntroController!.videoDetail.value.pages!.length > 1; bool isBangumi = bangumiIntroController?.loadingState.value is Success; - bool anySeason = isSeason || - isPage || - isBangumi || - widget.videoDetailController?.isPlayAll == true; + bool anySeason = isSeason || isPage || isBangumi; double widgetWidth = isFullScreen && context.orientation == Orientation.landscape ? 42 : 35; Map videoProgressWidgets = { @@ -478,16 +475,18 @@ class _PLVideoPlayerState extends State color: Colors.white, ), onTap: () { + if (anySeason.not) { + widget.showEpisodes?.call(); + return; + } int? index; int currentCid = plPlayerController.cid; String bvid = plPlayerController.bvid; List episodes = []; - // late Function changeFucCall; if (isPage) { final List pages = videoIntroController!.videoDetail.value.pages!; episodes = pages; - // changeFucCall = videoIntroController!.changeSeasonOrbangu; } else if (isSeason) { final List sections = videoIntroController!.videoDetail.value.ugcSeason!.sections!; @@ -501,12 +500,10 @@ class _PLVideoPlayerState extends State } } } - // changeFucCall = videoIntroController!.changeSeasonOrbangu; } else if (isBangumi) { episodes = (bangumiIntroController!.loadingState.value as Success) .response .episodes!; - // changeFucCall = bangumiIntroController!.changeSeasonOrbangu; } widget.showEpisodes?.call( index, @@ -651,15 +648,18 @@ class _PLVideoPlayerState extends State List userSpecifyItemLeft = [ BottomControlType.playOrPause, BottomControlType.time, - if (anySeason) BottomControlType.pre, - if (anySeason) BottomControlType.next, + if (anySeason || widget.videoDetailController?.isPlayAll == true) ...[ + BottomControlType.pre, + BottomControlType.next, + ], ]; List userSpecifyItemRight = [ BottomControlType.dmChart, BottomControlType.superResolution, BottomControlType.viewPoints, - if (anySeason) BottomControlType.episode, + if (anySeason || widget.videoDetailController?.isPlayAll == true) + BottomControlType.episode, if (isFullScreen) BottomControlType.fit, BottomControlType.subtitle, BottomControlType.speed, diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index c87864fc..2e57da8b 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -41,7 +41,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; -import 'package:get/get_navigation/src/dialog/dialog_route.dart'; import 'package:share_plus/share_plus.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:html/dom.dart' as dom; @@ -277,62 +276,63 @@ class Utils { required Function isFullScreen, double? padding, }) { - Navigator.of(context).push( - GetDialogRoute( - pageBuilder: (buildContext, animation, secondaryAnimation) { - return MediaQuery.orientationOf(Get.context!) == Orientation.portrait - ? SafeArea( - child: Column( - children: [ - const Spacer(flex: 3), - Expanded( - flex: 7, - child: MediaQuery.removePadding( - context: context, - removeTop: true, - removeBottom: true, - removeLeft: true, - removeRight: true, - child: child, - ), + Get.generalDialog( + barrierLabel: '', + barrierDismissible: true, + pageBuilder: (buildContext, animation, secondaryAnimation) { + return MediaQuery.orientationOf(Get.context!) == Orientation.portrait + ? SafeArea( + child: Column( + children: [ + const Spacer(flex: 3), + Expanded( + flex: 7, + child: MediaQuery.removePadding( + context: context, + removeTop: true, + removeBottom: true, + removeLeft: true, + removeRight: true, + child: child, ), - if (isFullScreen() && padding != null) - SizedBox(height: padding), - ], - ), - ) - : SafeArea( - child: Row( - children: [ - const Spacer(), - Expanded( - child: MediaQuery.removePadding( - context: context, - removeTop: true, - removeBottom: true, - removeLeft: true, - removeRight: true, - child: child, - ), + ), + if (isFullScreen() && padding != null) + SizedBox(height: padding), + ], + ), + ) + : SafeArea( + child: Row( + children: [ + const Spacer(), + Expanded( + child: MediaQuery.removePadding( + context: context, + removeTop: true, + removeBottom: true, + removeLeft: true, + removeRight: true, + child: child, ), - ], - ), - ); - }, - transitionDuration: const Duration(milliseconds: 350), - transitionBuilder: (context, animation, secondaryAnimation, child) { - Offset begin = - MediaQuery.orientationOf(Get.context!) == Orientation.portrait - ? Offset(0.0, 1.0) - : Offset(1.0, 0.0); - var tween = Tween(begin: begin, end: Offset.zero) - .chain(CurveTween(curve: Curves.easeInOut)); - return SlideTransition( - position: animation.drive(tween), - child: child, - ); - }, - ), + ), + ], + ), + ); + }, + transitionDuration: const Duration(milliseconds: 350), + transitionBuilder: (context, animation, secondaryAnimation, child) { + Offset begin = + MediaQuery.orientationOf(Get.context!) == Orientation.portrait + ? Offset(0.0, 1.0) + : Offset(1.0, 0.0); + var tween = Tween(begin: begin, end: Offset.zero) + .chain(CurveTween(curve: Curves.easeInOut)); + return SlideTransition( + position: animation.drive(tween), + child: child, + ); + }, + routeSettings: RouteSettings(arguments: Get.arguments), ); }