diff --git a/lib/pages/bangumi/introduction/widgets/intro_detail.dart b/lib/pages/bangumi/introduction/widgets/intro_detail.dart index 87a069b9..28a5fedf 100644 --- a/lib/pages/bangumi/introduction/widgets/intro_detail.dart +++ b/lib/pages/bangumi/introduction/widgets/intro_detail.dart @@ -3,6 +3,8 @@ import 'package:get/get.dart'; import 'package:pilipala/common/widgets/stat/danmu.dart'; import 'package:pilipala/common/widgets/stat/view.dart'; +import '../../../../utils/utils.dart'; + class IntroDetail extends StatelessWidget { final dynamic bangumiDetail; @@ -21,7 +23,7 @@ class IntroDetail extends StatelessWidget { return Container( color: Theme.of(context).colorScheme.background, padding: const EdgeInsets.only(left: 14, right: 14), - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), child: Column( children: [ Container( diff --git a/lib/pages/bangumi/widgets/bangumi_panel.dart b/lib/pages/bangumi/widgets/bangumi_panel.dart index deaad526..afa6ff0d 100644 --- a/lib/pages/bangumi/widgets/bangumi_panel.dart +++ b/lib/pages/bangumi/widgets/bangumi_panel.dart @@ -7,6 +7,8 @@ import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; +import '../../../utils/utils.dart'; + class BangumiPanel extends StatefulWidget { const BangumiPanel({ super.key, @@ -78,7 +80,7 @@ class _BangumiPanelState extends State { }); // 在这里使用 setState 更新状态 return Container( - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), color: Theme.of(context).colorScheme.background, child: Column( children: [ diff --git a/lib/pages/setting/play_setting.dart b/lib/pages/setting/play_setting.dart index 768f576c..46f9d9ad 100644 --- a/lib/pages/setting/play_setting.dart +++ b/lib/pages/setting/play_setting.dart @@ -117,10 +117,10 @@ class _PlaySettingState extends State { defaultVal: false, ), const SetSwitchItem( - title: '恢复竖屏', - subTitle: '退出全屏视频时自动恢复竖屏,关闭可以保持横屏状态', - setKey: SettingBoxKey.exitFullscreenAutoVertical, - defaultVal: true, + title: '横屏适配(测试)', + subTitle: '开启该项在播放页启用横屏布局与逻辑', + setKey: SettingBoxKey.horizontalScreen, + defaultVal: false, ), const SetSwitchItem( title: '开启硬解', diff --git a/lib/pages/video/detail/introduction/widgets/fav_panel.dart b/lib/pages/video/detail/introduction/widgets/fav_panel.dart index 304cd982..6a87a0e8 100644 --- a/lib/pages/video/detail/introduction/widgets/fav_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/fav_panel.dart @@ -3,6 +3,8 @@ import 'package:get/get.dart'; import 'package:pilipala/common/widgets/http_error.dart'; import 'package:pilipala/utils/feed_back.dart'; +import '../../../../../utils/utils.dart'; + class FavPanel extends StatefulWidget { const FavPanel({super.key, this.ctr}); final dynamic ctr; @@ -23,7 +25,7 @@ class _FavPanelState extends State { @override Widget build(BuildContext context) { return Container( - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), color: Theme.of(context).colorScheme.background, child: Column( children: [ diff --git a/lib/pages/video/detail/introduction/widgets/group_panel.dart b/lib/pages/video/detail/introduction/widgets/group_panel.dart index 60cf7650..8b3f517b 100644 --- a/lib/pages/video/detail/introduction/widgets/group_panel.dart +++ b/lib/pages/video/detail/introduction/widgets/group_panel.dart @@ -6,6 +6,8 @@ import 'package:pilipala/http/member.dart'; import 'package:pilipala/models/member/tags.dart'; import 'package:pilipala/utils/feed_back.dart'; +import '../../../../../utils/utils.dart'; + class GroupPanel extends StatefulWidget { final int? mid; const GroupPanel({super.key, this.mid}); @@ -51,7 +53,7 @@ class _GroupPanelState extends State { @override Widget build(BuildContext context) { return Container( - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), color: Theme.of(context).colorScheme.background, child: Column( children: [ diff --git a/lib/pages/video/detail/introduction/widgets/intro_detail.dart b/lib/pages/video/detail/introduction/widgets/intro_detail.dart index fec06ad8..f01d62bd 100644 --- a/lib/pages/video/detail/introduction/widgets/intro_detail.dart +++ b/lib/pages/video/detail/introduction/widgets/intro_detail.dart @@ -18,7 +18,7 @@ class IntroDetail extends StatelessWidget { return Container( color: Theme.of(context).colorScheme.background, padding: const EdgeInsets.only(left: 14, right: 14), - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), child: Column( children: [ InkWell( diff --git a/lib/pages/video/detail/introduction/widgets/page.dart b/lib/pages/video/detail/introduction/widgets/page.dart index 6477ae3f..9ee8fa1e 100644 --- a/lib/pages/video/detail/introduction/widgets/page.dart +++ b/lib/pages/video/detail/introduction/widgets/page.dart @@ -3,6 +3,8 @@ import 'package:get/get.dart'; import 'package:pilipala/models/video_detail_res.dart'; import 'package:pilipala/pages/video/detail/index.dart'; +import '../../../../../utils/utils.dart'; + class PagesPanel extends StatefulWidget { const PagesPanel({ super.key, @@ -94,7 +96,7 @@ class _PagesPanelState extends State { _scrollController.jumpTo(currentIndex * 56); }); return Container( - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), color: Theme.of(context).colorScheme.background, child: Column( children: [ diff --git a/lib/pages/video/detail/introduction/widgets/season.dart b/lib/pages/video/detail/introduction/widgets/season.dart index ad62ee01..266bcff4 100644 --- a/lib/pages/video/detail/introduction/widgets/season.dart +++ b/lib/pages/video/detail/introduction/widgets/season.dart @@ -5,6 +5,8 @@ import 'package:pilipala/pages/video/detail/index.dart'; import 'package:pilipala/utils/id_utils.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; +import '../../../../../utils/utils.dart'; + class SeasonPanel extends StatefulWidget { const SeasonPanel({ super.key, @@ -102,7 +104,7 @@ class _SeasonPanelState extends State { itemScrollController.jumpTo(index: currentIndex); }); return Container( - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), color: Theme.of(context).colorScheme.background, child: Column( children: [ diff --git a/lib/pages/video/detail/reply/view.dart b/lib/pages/video/detail/reply/view.dart index b2c67b1e..7ddaf999 100644 --- a/lib/pages/video/detail/reply/view.dart +++ b/lib/pages/video/detail/reply/view.dart @@ -121,7 +121,7 @@ class _VideoReplyPanelState extends State void dispose() { scrollController.removeListener(() {}); fabAnimationCtr.dispose(); - scrollController.dispose(); + // scrollController.dispose(); super.dispose(); } diff --git a/lib/pages/video/detail/reply_reply/view.dart b/lib/pages/video/detail/reply_reply/view.dart index 67ae59f7..12f4607b 100644 --- a/lib/pages/video/detail/reply_reply/view.dart +++ b/lib/pages/video/detail/reply_reply/view.dart @@ -7,6 +7,7 @@ import 'package:pilipala/models/common/reply_type.dart'; import 'package:pilipala/models/video/reply/item.dart'; import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart'; +import '../../../../utils/utils.dart'; import 'controller.dart'; class VideoReplyReplyPanel extends StatefulWidget { @@ -71,7 +72,7 @@ class _VideoReplyReplyPanelState extends State { @override Widget build(BuildContext context) { return Container( - height: widget.source == 'videoDetail' ? context.height.abs() * 0.7 : null, + height: widget.source == 'videoDetail' ? Utils.getSheetHeight(context) : null, color: Theme.of(context).colorScheme.background, child: Column( children: [ diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 167ac707..3ea5a8e2 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -57,13 +57,13 @@ class _VideoDetailPageState extends State // 自动退出全屏 late bool autoExitFullcreen; late bool autoPlayEnable; - late bool exitFullscreenAutoVertical; + late bool horizontalScreen; late bool autoPiP; final Floating floating = Floating(); // 生命周期监听 late final AppLifecycleListener _lifecycleListener; bool isShowing = true; - bool isFullScreen = false; + RxBool isFullScreen = false.obs; @override void initState() { @@ -87,8 +87,8 @@ class _VideoDetailPageState extends State statusBarHeight = localCache.get('statusBarHeight'); autoExitFullcreen = setting.get(SettingBoxKey.enableAutoExit, defaultValue: false); - exitFullscreenAutoVertical = setting - .get(SettingBoxKey.exitFullscreenAutoVertical, defaultValue: true); + horizontalScreen = + setting.get(SettingBoxKey.horizontalScreen, defaultValue: false); autoPlayEnable = setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true); autoPiP = setting.get(SettingBoxKey.autoPiP, defaultValue: false); @@ -286,341 +286,287 @@ class _VideoDetailPageState extends State } void triggerFullScreenCallback({bool? status}) { - SmartDialog.showToast('triggerFullScreen $status $isFullScreen'); + // SmartDialog.showToast('triggerFullScreen $status $isFullScreen.value'); setState(() { - isFullScreen = status ?? !isFullScreen; + isFullScreen.value = status ?? !isFullScreen.value; }); } @override Widget build(BuildContext context) { - final double videoHeight = MediaQuery.sizeOf(context).width * 9 / 16; - final double pinnedHeaderHeight = - statusBarHeight + kToolbarHeight + videoHeight; Widget childWhenDisabled = SafeArea( top: MediaQuery.of(context).orientation == Orientation.portrait && - isFullScreen == true, + isFullScreen.value == true, bottom: MediaQuery.of(context).orientation == Orientation.portrait && - isFullScreen == true, + isFullScreen.value == true, left: false, //isFullScreen != true, right: false, //isFullScreen != true, child: Stack( children: [ Scaffold( - resizeToAvoidBottomInset: false, - key: videoDetailController.scaffoldKey, - backgroundColor: Colors.black, - appBar: PreferredSize( - preferredSize: const Size.fromHeight(0), - child: AppBar( - backgroundColor: Colors.transparent, - elevation: 0, + resizeToAvoidBottomInset: false, + key: videoDetailController.scaffoldKey, + backgroundColor: Colors.black, + appBar: PreferredSize( + preferredSize: const Size.fromHeight(0), + child: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + ), ), - ), - body: ExtendedNestedScrollView( - controller: _extendNestCtr, - headerSliverBuilder: - (BuildContext context2, bool innerBoxIsScrolled) { - return [ + body: Column( + children: [ Obx( () { if (MediaQuery.of(context).orientation == Orientation.landscape || - isFullScreen == true) { + isFullScreen.value == true) { enterFullScreen(); } else { exitFullScreen(); } - return SliverAppBar( - automaticallyImplyLeading: false, - // 假装使用一个非空变量,避免Obx检测不到而罢工 - pinned: videoDetailController.autoPlay.value ^ - false ^ - videoDetailController.autoPlay.value, - elevation: 0, - scrolledUnderElevation: 0, - forceElevated: innerBoxIsScrolled, - expandedHeight: MediaQuery.of(context).orientation == + final double videoheight = Get.width * 9 / 16; + final double videowidth = Get.width; + return SizedBox( + height: MediaQuery.of(context).orientation == Orientation.landscape || - isFullScreen == true + isFullScreen.value == true ? MediaQuery.sizeOf(context).height - (MediaQuery.of(context).orientation == Orientation.landscape ? 0 : MediaQuery.of(context).padding.top) - : videoHeight, - backgroundColor: Colors.black, - flexibleSpace: FlexibleSpaceBar( - background: PopScope( - canPop: isFullScreen != true, - onPopInvoked: (bool didPop) { - if (isFullScreen == true) { - plPlayerController! - .triggerFullScreen(status: false); - } - if (MediaQuery.of(context).orientation == - Orientation.landscape && - exitFullscreenAutoVertical) { - verticalScreen(); - } - }, - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints boxConstraints) { - final double maxWidth = - boxConstraints.maxWidth; - final double maxHeight = - boxConstraints.maxHeight; - return Stack( - children: [ - if (isShowing) - FutureBuilder( - future: _futureBuilderFuture, - builder: (BuildContext context, - AsyncSnapshot snapshot) { - if (snapshot.hasData && - snapshot.data['status']) { - return Obx( - () => - !videoDetailController - .autoPlay.value - ? nil - : PLVideoPlayer( - controller: - plPlayerController!, - headerControl: - videoDetailController - .headerControl, - danmuWidget: Obx( - () => PlDanmaku( - key: Key(videoDetailController - .danmakuCid - .value - .toString()), - cid: videoDetailController - .danmakuCid - .value, - playerController: - plPlayerController!, - ), - ), - ), - ); - } else { - return const SizedBox(); - } - }, - ), + : videoheight, + width: MediaQuery.of(context).size.width, + child: PopScope( + canPop: isFullScreen.value != true, + onPopInvoked: (bool didPop) { + if (isFullScreen.value == true) { + plPlayerController! + .triggerFullScreen(status: false); + } + if (MediaQuery.of(context).orientation == + Orientation.landscape && + !horizontalScreen) { + verticalScreen(); + } + }, + child: Stack( + children: [ + if (isShowing) + FutureBuilder( + future: _futureBuilderFuture, + builder: (BuildContext context, + AsyncSnapshot snapshot) { + if (snapshot.hasData && + snapshot.data['status']) { + return Obx( + () => !videoDetailController + .autoPlay.value || + plPlayerController == + null || + plPlayerController! + .videoController == + null + ? nil + : PLVideoPlayer( + controller: + plPlayerController!, + headerControl: + videoDetailController + .headerControl, + danmuWidget: Obx( + () => PlDanmaku( + key: Key( + videoDetailController + .danmakuCid + .value + .toString()), + cid: + videoDetailController + .danmakuCid + .value, + playerController: + plPlayerController!, + ), + ), + ), + ); + } else { + return const SizedBox(); + } + }), - /// 关闭自动播放时 手动播放 - if (!videoDetailController - .autoPlay.value) ...[ - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value, - child: Positioned( + /// 关闭自动播放时 手动播放 + if (!videoDetailController + .autoPlay.value) ...[ + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value, + child: Positioned( + top: 0, + left: 0, + right: 0, + child: GestureDetector( + onTap: () { + handlePlay(); + }, + child: NetworkImgLayer( + type: 'emote', + src: videoDetailController + .videoItem['pic'], + width: videowidth, + height: videoheight, + ), + ), + ), + ), + ), + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value && + videoDetailController + .isEffective.value, + child: Stack( + children: [ + Positioned( top: 0, left: 0, right: 0, - child: GestureDetector( - onTap: () { - handlePlay(); - }, - child: NetworkImgLayer( - type: 'emote', - src: videoDetailController - .videoItem['pic'], - width: maxWidth, - height: maxHeight, - ), + child: AppBar( + primary: false, + foregroundColor: Colors.white, + elevation: 0, + scrolledUnderElevation: 0, + backgroundColor: + Colors.transparent, + actions: [ + IconButton( + tooltip: '稍后再看', + onPressed: () async { + var res = await UserHttp + .toViewLater( + bvid: + videoDetailController + .bvid); + SmartDialog.showToast( + res['msg']); + }, + icon: const Icon( + Icons.history_outlined), + ), + const SizedBox(width: 14) + ], ), ), - ), - ), - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value && - videoDetailController - .isEffective.value, - child: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: AppBar( - primary: false, - foregroundColor: - Colors.white, - elevation: 0, - scrolledUnderElevation: 0, - backgroundColor: - Colors.transparent, - actions: [ - IconButton( - tooltip: '稍后再看', - onPressed: () async { - var res = await UserHttp - .toViewLater( - bvid: videoDetailController - .bvid); - SmartDialog - .showToast( - res['msg']); - }, - icon: const Icon(Icons - .history_outlined), - ), - const SizedBox( - width: 14) - ], - ), - ), - Positioned( - right: 12, - bottom: 10, - child: IconButton( - tooltip: '播放', - onPressed: () => - handlePlay(), - icon: Image.asset( - 'assets/images/play.png', - width: 60, - height: 60, - )), - ), - ], - )), - ), - ] - ], - ); - }, - )), - ), + Positioned( + right: 12, + bottom: 10, + child: IconButton( + tooltip: '播放', + onPressed: () => handlePlay(), + icon: Image.asset( + 'assets/images/play.png', + width: 60, + height: 60, + )), + ), + ], + )), + ), + ] + ], + )), ); }, ), - ]; - }, - // pinnedHeaderSliverHeightBuilder: () { - // return playerStatus != PlayerStatus.playing - // ? statusBarHeight + kToolbarHeight - // : pinnedHeaderHeight; - // }, - /// 不收回 - pinnedHeaderSliverHeightBuilder: () { - if (playerStatus != PlayerStatus.playing) { - return 0; - } - return MediaQuery.of(context).orientation == - Orientation.landscape || - isFullScreen == true - ? MediaQuery.sizeOf(context).height - : pinnedHeaderHeight; - }, - onlyOneScrollInBody: true, - body: ColoredBox( - key: Key(heroTag), - color: Theme.of(context).colorScheme.background, - child: Column( - children: [ - Opacity( - opacity: 0, - child: SizedBox( - width: double.infinity, - height: 0, - child: Obx( - () => TabBar( - controller: videoDetailController.tabCtr, - dividerColor: Colors.transparent, - indicatorColor: - Theme.of(context).colorScheme.background, - tabs: videoDetailController.tabs - .map((String name) => Tab(text: name)) - .toList(), + SizedBox( + height: MediaQuery.of(context).orientation == + Orientation.landscape || + isFullScreen.value == true + ? 0 + : Get.height - + Get.width * 9 / 16 - + MediaQuery.of(context).padding.top - + MediaQuery.of(context).padding.bottom, + width: MediaQuery.of(context).size.width, + child: ColoredBox( + key: Key(heroTag), + color: Theme.of(context).colorScheme.background, + child: Column( + children: [ + Opacity( + opacity: 0, + child: SizedBox( + width: double.infinity, + height: 0, + child: Obx( + () => TabBar( + controller: videoDetailController.tabCtr, + dividerColor: Colors.transparent, + indicatorColor: + Theme.of(context).colorScheme.background, + tabs: videoDetailController.tabs + .map((String name) => Tab(text: name)) + .toList(), + ), + ), + ), ), - ), - ), - ), - Expanded( - child: TabBarView( - controller: videoDetailController.tabCtr, - children: [ - Builder( - builder: (BuildContext context) { - return CustomScrollView( - key: const PageStorageKey('简介'), - slivers: [ - if (videoDetailController.videoType == - SearchType.video) ...[ - const VideoIntroPanel(), - ] else if (videoDetailController.videoType == - SearchType.media_bangumi) ...[ - Obx(() => BangumiIntroPanel( - cid: videoDetailController.cid.value)), - ], - // if (videoDetailController.videoType == - // SearchType.video) ...[ - // SliverPersistentHeader( - // floating: true, - // pinned: true, - // delegate: SliverHeaderDelegate( - // height: 50, - // child: - // const MenuRow(loadingStatus: false), - // ), - // ), - // ], - SliverToBoxAdapter( - child: Divider( - indent: 12, - endIndent: 12, - color: Theme.of(context) - .dividerColor - .withOpacity(0.06), - ), - ), - RelatedVideoPanel(), - ], - ); - }, + Expanded( + child: TabBarView( + controller: videoDetailController.tabCtr, + children: [ + Builder( + builder: (BuildContext context) { + return CustomScrollView( + key: const PageStorageKey('简介'), + slivers: [ + if (videoDetailController.videoType == + SearchType.video) ...[ + const VideoIntroPanel(), + ] else if (videoDetailController + .videoType == + SearchType.media_bangumi) ...[ + Obx(() => BangumiIntroPanel( + cid: videoDetailController + .cid.value)), + ], + SliverToBoxAdapter( + child: Divider( + indent: 12, + endIndent: 12, + color: Theme.of(context) + .dividerColor + .withOpacity(0.06), + ), + ), + RelatedVideoPanel(), + ], + ); + }, + ), + VideoReplyPanel( + bvid: videoDetailController.bvid, + ) + ], + ), ), - VideoReplyPanel( - bvid: videoDetailController.bvid, - ) ], ), ), - ], - ), - ), - ), - ), - - /// 重新进入会刷新 - // 播放完成/暂停播放 - // StreamBuilder( - // stream: appbarStream.stream, - // initialData: 0, - // builder: ((context, snapshot) { - // return ScrollAppBar( - // snapshot.data!.toDouble(), - // () => continuePlay(), - // playerStatus, - // null, - // ); - // }), - // ) + ), + ], + )), ], ), ); Widget childWhenDisabledLandscape = SafeArea( - left: isFullScreen != true, - right: isFullScreen != true, + left: isFullScreen.value != true, + right: isFullScreen.value != true, child: Stack(children: [ Scaffold( resizeToAvoidBottomInset: false, @@ -633,196 +579,207 @@ class _VideoDetailPageState extends State elevation: 0, ), ), - body: Row( - children: [ - Column( - children: [ - SizedBox( - width: isFullScreen == true - ? Get.width - : Get.height * 0.6 * 16 / 9, - height: isFullScreen == true - ? Get.height - : Get.height * 0.6, - child: PopScope( - canPop: isFullScreen != true, - onPopInvoked: (bool didPop) { - if (isFullScreen == true) { - plPlayerController! - .triggerFullScreen(status: false); - } - if (MediaQuery.of(context).orientation == - Orientation.landscape && - exitFullscreenAutoVertical) { - verticalScreen(); - } - }, - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints boxConstraints) { - final double maxWidth = - boxConstraints.maxWidth / 2; - final double maxHeight = - boxConstraints.maxHeight / 2; - return Stack( - children: [ - if (isShowing) - Obx( - () => !videoDetailController - .autoPlay.value || - plPlayerController - ?.videoController == - null - ? nil - : PLVideoPlayer( - controller: - plPlayerController!, - headerControl: - videoDetailController - .headerControl, - danmuWidget: Obx( - () => PlDanmaku( - key: Key( - videoDetailController - .danmakuCid.value - .toString()), - cid: videoDetailController - .danmakuCid.value, - playerController: - plPlayerController!, - ), - ), - ), - ), + body: Obx(() { + final double videoheight = Get.height * 0.32 + Get.width * 0.13; + final double videowidth = videoheight * 16 / 9; + return Row( + children: [ + Column( + children: [ + SizedBox( + width: isFullScreen.value == true + ? Get.width + : videowidth, + height: isFullScreen.value == true + ? Get.height + : videoheight, + child: PopScope( + canPop: isFullScreen.value != true, + onPopInvoked: (bool didPop) { + if (isFullScreen.value == true) { + plPlayerController! + .triggerFullScreen(status: false); + } + if (MediaQuery.of(context).orientation == + Orientation.landscape && + !horizontalScreen) { + verticalScreen(); + } + }, + child: Stack( + children: [ + if (isShowing) + FutureBuilder( + future: _futureBuilderFuture, + builder: (BuildContext context, + AsyncSnapshot snapshot) { + if (snapshot.hasData && + snapshot.data['status']) { + return Obx( + () => !videoDetailController + .autoPlay.value || + plPlayerController == + null || + plPlayerController! + .videoController == + null + ? nil + : PLVideoPlayer( + controller: + plPlayerController!, + headerControl: + videoDetailController + .headerControl, + danmuWidget: Obx( + () => PlDanmaku( + key: Key( + videoDetailController + .danmakuCid + .value + .toString()), + cid: + videoDetailController + .danmakuCid + .value, + playerController: + plPlayerController!, + ), + ), + ), + ); + } else { + return const SizedBox(); + } + }), - /// 关闭自动播放时 手动播放 - if (!videoDetailController - .autoPlay.value) ...[ - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value, - child: Positioned( - top: 0, - left: 0, - right: 0, - child: GestureDetector( - onTap: () { - handlePlay(); - }, - child: NetworkImgLayer( - type: 'emote', - src: videoDetailController - .videoItem['pic'], - width: maxWidth, - height: maxHeight, - ), + /// 关闭自动播放时 手动播放 + if (!videoDetailController + .autoPlay.value) ...[ + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value, + child: Positioned( + top: 0, + left: 0, + right: 0, + child: GestureDetector( + onTap: () { + handlePlay(); + }, + child: NetworkImgLayer( + type: 'emote', + src: videoDetailController + .videoItem['pic'], + width: videowidth, + height: videoheight, ), ), ), ), - Obx( - () => Visibility( - visible: videoDetailController - .isShowCover.value && - videoDetailController - .isEffective.value, - child: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: AppBar( - primary: false, - foregroundColor: - Colors.white, - elevation: 0, - scrolledUnderElevation: 0, - backgroundColor: - Colors.transparent, - actions: [ - IconButton( - tooltip: '稍后再看', - onPressed: () async { - var res = await UserHttp - .toViewLater( - bvid: videoDetailController - .bvid); - SmartDialog - .showToast( - res['msg']); - }, - icon: const Icon(Icons - .history_outlined), - ), - const SizedBox( - width: 14) - ], - ), + ), + Obx( + () => Visibility( + visible: videoDetailController + .isShowCover.value && + videoDetailController + .isEffective.value, + child: Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + child: AppBar( + primary: false, + foregroundColor: + Colors.white, + elevation: 0, + scrolledUnderElevation: 0, + backgroundColor: + Colors.transparent, + actions: [ + IconButton( + tooltip: '稍后再看', + onPressed: () async { + var res = await UserHttp + .toViewLater( + bvid: + videoDetailController + .bvid); + SmartDialog.showToast( + res['msg']); + }, + icon: const Icon(Icons + .history_outlined), + ), + const SizedBox(width: 14) + ], ), - Positioned( - right: 12, - bottom: 10, - child: IconButton( - tooltip: '播放', - onPressed: () => - handlePlay(), - icon: Image.asset( - 'assets/images/play.png', - width: 60, - height: 60, - )), - ), - ], - )), - ), - ] - ], - ); - }, - ))), - SizedBox( - width: isFullScreen == true - ? Get.width - : Get.height * 0.6 * 16 / 9, - height: isFullScreen == true ? 0 : Get.height * 0.4, - child: (videoDetailController.videoType == - SearchType.video) - ? const CustomScrollView( - slivers: [VideoIntroPanel()]) - : (videoDetailController.videoType == - SearchType.media_bangumi) - ? Obx(() => BangumiIntroPanel( - cid: videoDetailController.cid.value)) - : const SizedBox(), - ) - ], - ), - SizedBox( - width: isFullScreen == true - ? 0 - : (Get.width - - MediaQuery.of(context).padding.left - - MediaQuery.of(context).padding.right - - Get.height * 0.6 * 16 / 9), - height: Get.height, - child: TabBarView( - controller: videoDetailController.tabCtr, - children: [ - CustomScrollView( - slivers: [ - RelatedVideoPanel(), - ], - ), - VideoReplyPanel( - bvid: videoDetailController.bvid, + ), + Positioned( + right: 12, + bottom: 10, + child: IconButton( + tooltip: '播放', + onPressed: () => + handlePlay(), + icon: Image.asset( + 'assets/images/play.png', + width: 60, + height: 60, + )), + ), + ], + )), + ), + ] + ], + ))), + SizedBox( + width: isFullScreen.value == true + ? Get.width + : videowidth, + height: isFullScreen.value == true + ? 0 + : Get.height - videoheight, + child: (videoDetailController.videoType == + SearchType.video) + ? const CustomScrollView( + slivers: [VideoIntroPanel()]) + : (videoDetailController.videoType == + SearchType.media_bangumi) + ? Obx(() => BangumiIntroPanel( + cid: videoDetailController.cid.value)) + : const SizedBox(), ) ], ), - ) - ], - )) + SizedBox( + width: isFullScreen.value == true + ? 0 + : (Get.width - + MediaQuery.of(context).padding.left - + MediaQuery.of(context).padding.right - + videowidth), + height: Get.height, + child: TabBarView( + controller: videoDetailController.tabCtr, + children: [ + CustomScrollView( + slivers: [ + RelatedVideoPanel(), + ], + ), + VideoReplyPanel( + bvid: videoDetailController.bvid, + ) + ], + ), + ) + ], + ); + })) ])); Widget childWhenEnabled = FutureBuilder( key: Key(heroTag), @@ -855,23 +812,27 @@ class _VideoDetailPageState extends State ); return OrientationBuilder( builder: (BuildContext context, Orientation orientation) { - print("orientation:$orientation"); - if (orientation == Orientation.portrait || isFullScreen == true) { - // 竖屏 - return childWhenDisabled; - } else { + if (orientation == Orientation.landscape) { enterFullScreen(); - return childWhenDisabledLandscape; } + if (Platform.isAndroid) { + return PiPSwitcher( + childWhenDisabled: Container( + key: UniqueKey(), + child: !horizontalScreen || orientation == Orientation.portrait + ? childWhenDisabled + : childWhenDisabledLandscape, + ), + childWhenEnabled: childWhenEnabled, + floating: floating, + ); + } + return Container( + key: UniqueKey(), + child: !horizontalScreen || orientation == Orientation.portrait + ? childWhenDisabled + : childWhenDisabledLandscape, + ); }); - // if (Platform.isAndroid) { - // return PiPSwitcher( - // childWhenDisabled: childWhenDisabled, - // childWhenEnabled: childWhenEnabled, - // floating: floating, - // ); - // } else { - // return childWhenDisabled; - // } } } diff --git a/lib/pages/video/detail/widgets/ai_detail.dart b/lib/pages/video/detail/widgets/ai_detail.dart index 0a00d14a..9fca75d6 100644 --- a/lib/pages/video/detail/widgets/ai_detail.dart +++ b/lib/pages/video/detail/widgets/ai_detail.dart @@ -20,7 +20,7 @@ class AiDetail extends StatelessWidget { return Container( color: Theme.of(context).colorScheme.background, padding: const EdgeInsets.only(left: 14, right: 14), - height: context.height.abs() * 0.7, + height: Utils.getSheetHeight(context), child: Column( children: [ InkWell( diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 8c06d415..6bd01acc 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1070,8 +1070,8 @@ class _HeaderControlState extends State { { if (MediaQuery.of(context).orientation == Orientation.landscape && - setting.get(SettingBoxKey.exitFullscreenAutoVertical, - defaultValue: true)) + !setting.get(SettingBoxKey.horizontalScreen, + defaultValue: false)) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 527f2710..ebf2230c 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1002,7 +1002,7 @@ class PlPlayerController { StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE); // Get.back(); exitFullScreen(); - if (setting.get(SettingBoxKey.exitFullscreenAutoVertical, defaultValue: true)) { + if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) { await verticalScreen(); } toggleFullScreen(false); diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 1bc94e58..3f824ffd 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -92,7 +92,7 @@ class SettingBoxKey { enableAutoBrightness = 'enableAutoBrightness', enableAutoEnter = 'enableAutoEnter', enableAutoExit = 'enableAutoExit', - exitFullscreenAutoVertical = 'exitFullscreenAutoVertical', + horizontalScreen = 'horizontalScreen', p1080 = 'p1080', enableCDN = 'enableCDN', autoPiP = 'autoPiP', diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 3e9762fd..cfb6972b 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -9,6 +9,7 @@ import 'package:crypto/crypto.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:get/get.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:path_provider/path_provider.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -327,6 +328,16 @@ class Utils { return '$formattedHours:$formattedMinutes'; } + static double getSheetHeight(BuildContext context) { + double height = context.height.abs(); + double width = context.width.abs(); + if (height > width) { + return height * 0.7; + } + //横屏状态 + return height; + } + static String appSign( Map params, String appkey, String appsec) { params['appkey'] = appkey;