From 1b4f58867130f499136f81dd80225b701c8494a9 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Fri, 28 Feb 2025 09:55:15 +0800 Subject: [PATCH] fix: #339 #341 Signed-off-by: bggRGjQaUbCoE --- .../interactiveviewer_gallery.dart | 20 +- lib/common/widgets/video_card_h.dart | 243 +++++++++--------- lib/pages/common/common_publish_page.dart | 2 +- lib/pages/home/view.dart | 11 +- lib/pages/main/view.dart | 5 +- lib/pages/search_result/view.dart | 2 +- lib/pages/setting/widgets/model.dart | 1 - lib/pages/video/detail/view_v.dart | 7 +- lib/plugin/pl_player/controller.dart | 2 - lib/plugin/pl_player/utils/fullscreen.dart | 3 - pubspec.lock | 8 - pubspec.yaml | 2 +- 12 files changed, 152 insertions(+), 154 deletions(-) diff --git a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart index 399bc4ba2..04d8157db 100644 --- a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart +++ b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart @@ -6,15 +6,16 @@ import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/utils.dart'; import 'package:cached_network_image/cached_network_image.dart'; +import 'package:device_info_plus/device_info_plus.dart'; import 'package:dio/dio.dart'; 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:media_kit/media_kit.dart'; import 'package:media_kit_video/media_kit_video.dart'; import 'package:path_provider/path_provider.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:status_bar_control/status_bar_control.dart'; import 'interactive_viewer_boundary.dart'; import 'interactive_viewer.dart' as custom; @@ -142,17 +143,21 @@ class _InteractiveviewerGalleryState extends State _transformationController!.value = _animation?.value ?? Matrix4.identity(); } + SystemUiMode? mode; setStatusBar() async { if (Platform.isIOS || Platform.isAndroid) { - await StatusBarControl.setHidden( - true, - animation: StatusBarAnimation.FADE, + SystemChrome.setEnabledSystemUIMode( + SystemUiMode.immersiveSticky, ); } + if (Platform.isAndroid && + (await DeviceInfoPlugin().androidInfo).version.sdkInt < 29) { + mode = SystemUiMode.manual; + } } @override - void dispose() async { + void dispose() { widget.onClose?.call(true); _player?.dispose(); _pageController?.dispose(); @@ -160,7 +165,10 @@ class _InteractiveviewerGalleryState extends State _animationController.dispose(); if (widget.setStatusBar != false) { if (Platform.isIOS || Platform.isAndroid) { - StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE); + SystemChrome.setEnabledSystemUIMode( + mode ?? SystemUiMode.edgeToEdge, + overlays: SystemUiOverlay.values, + ); } } for (int index = 0; index < widget.sources.length; index++) { diff --git a/lib/common/widgets/video_card_h.dart b/lib/common/widgets/video_card_h.dart index 75a29e318..3590d299b 100644 --- a/lib/common/widgets/video_card_h.dart +++ b/lib/common/widgets/video_card_h.dart @@ -41,134 +41,137 @@ class VideoCardH extends StatelessWidget { try { type = videoItem.type; } catch (_) {} - return Stack( - children: [ - Semantics( - label: Utils.videoItemSemantics(videoItem), - excludeSemantics: true, - // customSemanticsActions: { - // for (var item in actions) - // CustomSemanticsAction( - // label: item.title.isEmpty ? 'label' : item.title): item.onTap!, - // }, - child: InkWell( - onLongPress: () { - if (onLongPress != null) { - onLongPress!(); - } else { - imageSaveDialog( - context: context, - title: videoItem.title is String - ? videoItem.title - : videoItem.title is List - ? (videoItem.title as List) - .map((item) => item['text']) - .join() - : '', - cover: videoItem.pic, - ); - } - }, - onTap: () async { - if (onTap != null) { - onTap?.call(); - return; - } - if (type == 'ketang') { - SmartDialog.showToast('课堂视频暂不支持播放'); - return; - } - if (videoItem is HotVideoItemModel && - videoItem.redirectUrl?.isNotEmpty == true) { - if (Utils.viewPgcFromUri(videoItem.redirectUrl!)) { + return Material( + color: Colors.transparent, + child: Stack( + children: [ + Semantics( + label: Utils.videoItemSemantics(videoItem), + excludeSemantics: true, + // customSemanticsActions: { + // for (var item in actions) + // CustomSemanticsAction( + // label: item.title.isEmpty ? 'label' : item.title): item.onTap!, + // }, + child: InkWell( + onLongPress: () { + if (onLongPress != null) { + onLongPress!(); + } else { + imageSaveDialog( + context: context, + title: videoItem.title is String + ? videoItem.title + : videoItem.title is List + ? (videoItem.title as List) + .map((item) => item['text']) + .join() + : '', + cover: videoItem.pic, + ); + } + }, + onTap: () async { + if (onTap != null) { + onTap?.call(); return; } - } - try { - final int cid = videoItem.cid ?? - await SearchHttp.ab2c(aid: aid, bvid: bvid); - Utils.toViewPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'videoItem': videoItem, - 'heroTag': Utils.makeHeroTag(aid) - }, - ); - } catch (err) { - SmartDialog.showToast(err.toString()); - } - }, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: StyleString.safeSpace, - vertical: 5, - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AspectRatio( - aspectRatio: StyleString.aspectRatio, - child: LayoutBuilder( - builder: (BuildContext context, - BoxConstraints boxConstraints) { - final double maxWidth = boxConstraints.maxWidth; - final double maxHeight = boxConstraints.maxHeight; - return Stack( - children: [ - NetworkImgLayer( - src: videoItem.pic as String, - width: maxWidth, - height: maxHeight, - ), - if (videoItem is HotVideoItemModel && - videoItem.pgcLabel?.isNotEmpty == true) - PBadge( - text: videoItem.pgcLabel, - top: 6.0, - right: 6.0, + if (type == 'ketang') { + SmartDialog.showToast('课堂视频暂不支持播放'); + return; + } + if (videoItem is HotVideoItemModel && + videoItem.redirectUrl?.isNotEmpty == true) { + if (Utils.viewPgcFromUri(videoItem.redirectUrl!)) { + return; + } + } + try { + final int cid = videoItem.cid ?? + await SearchHttp.ab2c(aid: aid, bvid: bvid); + Utils.toViewPage( + 'bvid=$bvid&cid=$cid', + arguments: { + 'videoItem': videoItem, + 'heroTag': Utils.makeHeroTag(aid) + }, + ); + } catch (err) { + SmartDialog.showToast(err.toString()); + } + }, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: StyleString.safeSpace, + vertical: 5, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AspectRatio( + aspectRatio: StyleString.aspectRatio, + child: LayoutBuilder( + builder: (BuildContext context, + BoxConstraints boxConstraints) { + final double maxWidth = boxConstraints.maxWidth; + final double maxHeight = boxConstraints.maxHeight; + return Stack( + children: [ + NetworkImgLayer( + src: videoItem.pic as String, + width: maxWidth, + height: maxHeight, ), - if (videoItem.duration != 0) - PBadge( - text: Utils.timeFormat(videoItem.duration!), - right: 6.0, - bottom: 6.0, - type: 'gray', - ), - if (type != 'video') - PBadge( - text: type, - left: 6.0, - bottom: 6.0, - type: 'primary', - ), - // if (videoItem.rcmdReason != null && - // videoItem.rcmdReason.content != '') - // pBadge(videoItem.rcmdReason.content, context, - // 6.0, 6.0, null, null), - ], - ); - }, + if (videoItem is HotVideoItemModel && + videoItem.pgcLabel?.isNotEmpty == true) + PBadge( + text: videoItem.pgcLabel, + top: 6.0, + right: 6.0, + ), + if (videoItem.duration != 0) + PBadge( + text: Utils.timeFormat(videoItem.duration!), + right: 6.0, + bottom: 6.0, + type: 'gray', + ), + if (type != 'video') + PBadge( + text: type, + left: 6.0, + bottom: 6.0, + type: 'primary', + ), + // if (videoItem.rcmdReason != null && + // videoItem.rcmdReason.content != '') + // pBadge(videoItem.rcmdReason.content, context, + // 6.0, 6.0, null, null), + ], + ); + }, + ), ), - ), - const SizedBox(width: 10), - videoContent(context), - ], + const SizedBox(width: 10), + videoContent(context), + ], + ), ), ), ), - ), - if (source == 'normal') - Positioned( - bottom: 0, - right: 12, - child: VideoPopupMenu( - size: 29, - iconSize: 17, - videoItem: videoItem, + if (source == 'normal') + Positioned( + bottom: 0, + right: 12, + child: VideoPopupMenu( + size: 29, + iconSize: 17, + videoItem: videoItem, + ), ), - ), - ], + ], + ), ); } diff --git a/lib/pages/common/common_publish_page.dart b/lib/pages/common/common_publish_page.dart index 8329d867f..6eba2eb75 100644 --- a/lib/pages/common/common_publish_page.dart +++ b/lib/pages/common/common_publish_page.dart @@ -72,7 +72,7 @@ abstract class CommonPublishPageState } @override - void dispose() async { + void dispose() { focusNode.dispose(); editController.dispose(); WidgetsBinding.instance.removeObserver(this); diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 3cce1ddbb..a2753828b 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -37,7 +37,6 @@ class _HomePageState extends State @override Widget build(BuildContext context) { super.build(context); - return Scaffold( appBar: AppBar(toolbarHeight: 0), body: Column( @@ -45,12 +44,12 @@ class _HomePageState extends State if (!_homeController.useSideBar && context.orientation == Orientation.portrait) customAppBar, - if (_homeController.tabs.length > 1) ...[ - const SizedBox(height: 4), + if (_homeController.tabs.length > 1) Material( color: Theme.of(context).colorScheme.surface, - child: SizedBox( + child: Container( height: 42, + padding: const EdgeInsets.only(top: 4), child: TabBar( controller: _homeController.tabController, tabs: [ @@ -69,8 +68,8 @@ class _HomePageState extends State }, ), ), - ), - ] else + ) + else const SizedBox(height: 6), Expanded( child: tabBarView( diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 1c0c7a1c7..aad21e1c0 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -157,11 +157,10 @@ class _MainAppState extends State } @override - void dispose() async { + void dispose() { MainApp.routeObserver.unsubscribe(this); WidgetsBinding.instance.removeObserver(this); - // await GrpcClient.instance.shutdown(); - await GStorage.close(); + GStorage.close(); EventBus().off(EventName.loginEvent); PiliScheme.listener?.cancel(); super.dispose(); diff --git a/lib/pages/search_result/view.dart b/lib/pages/search_result/view.dart index 5b58e6db5..e9c9b57fc 100644 --- a/lib/pages/search_result/view.dart +++ b/lib/pages/search_result/view.dart @@ -75,9 +75,9 @@ class _SearchResultPageState extends State ), body: Column( children: [ - const SizedBox(height: 4), Container( width: double.infinity, + padding: const EdgeInsets.only(top: 4), color: Theme.of(context).colorScheme.surface, child: Theme( data: ThemeData( diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index 741d7cfae..3684b06ee 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -213,7 +213,6 @@ List get styleSettings => [ leading: Icon(Icons.fit_screen_outlined), setKey: SettingBoxKey.videoPlayerRemoveSafeArea, defaultVal: false, - needReboot: true, ), SettingsModel( settingsType: SettingsType.sw1tch, diff --git a/lib/pages/video/detail/view_v.dart b/lib/pages/video/detail/view_v.dart index 4b71661a9..64b21437e 100644 --- a/lib/pages/video/detail/view_v.dart +++ b/lib/pages/video/detail/view_v.dart @@ -637,7 +637,8 @@ class _VideoDetailPageVState extends State toolbarHeight: 0, ), if (videoDetailController.scrollRatio.value != 0 && - videoDetailController.scrollCtr.offset != 0) + videoDetailController.scrollCtr.offset != 0 && + context.orientation == Orientation.portrait) AppBar( backgroundColor: Theme.of(context) .colorScheme @@ -846,7 +847,8 @@ class _VideoDetailPageVState extends State ), ); return videoDetailController.scrollRatio.value == 0 || - videoDetailController.scrollCtr.offset == 0 + videoDetailController.scrollCtr.offset == 0 || + context.orientation != Orientation.portrait ? const SizedBox.shrink() : Positioned.fill( bottom: -2, @@ -1807,6 +1809,7 @@ class _VideoDetailPageVState extends State Widget videoIntro([bool needRelated = true, bool needCtr = true]) { Widget introPanel() => Scaffold( + resizeToAvoidBottomInset: false, backgroundColor: Colors.transparent, body: CustomScrollView( key: const PageStorageKey('简介'), diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 62a9d2f9d..19be9280c 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1379,7 +1379,6 @@ class PlPlayerController { bool removeSafeArea = setting.get(SettingBoxKey.videoPlayerRemoveSafeArea, defaultValue: false); if (!isFullScreen.value && status) { - // StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE); hideStatusBar(); /// 按照视频宽高比决定全屏方向 @@ -1403,7 +1402,6 @@ class PlPlayerController { await landScape(); } } else if (isFullScreen.value && !status) { - // StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE); if (!removeSafeArea) showStatusBar(); toggleFullScreen(false); if (mode == FullScreenMode.none) { diff --git a/lib/plugin/pl_player/utils/fullscreen.dart b/lib/plugin/pl_player/utils/fullscreen.dart index cd59a6415..bf8c16381 100644 --- a/lib/plugin/pl_player/utils/fullscreen.dart +++ b/lib/plugin/pl_player/utils/fullscreen.dart @@ -5,7 +5,6 @@ import 'package:device_info_plus/device_info_plus.dart'; import 'package:auto_orientation/auto_orientation.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; -import 'package:status_bar_control/status_bar_control.dart'; import '../../../utils/storage.dart'; @@ -75,7 +74,6 @@ Future hideStatusBar() async { await SystemChrome.setEnabledSystemUIMode( SystemUiMode.immersiveSticky, ); - StatusBarControl.setHidden(true); } //退出全屏显示 @@ -94,7 +92,6 @@ Future showStatusBar() async { mode, overlays: SystemUiOverlay.values, ); - StatusBarControl.setHidden(false); } else if (Platform.isMacOS || Platform.isWindows || Platform.isLinux) { await const MethodChannel('com.alexmercerind/media_kit_video') .invokeMethod( diff --git a/pubspec.lock b/pubspec.lock index b7d5a07bd..6884541a2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1741,14 +1741,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.1" - status_bar_control: - dependency: "direct main" - description: - name: status_bar_control - sha256: "7f2c1f3f7fd13b85ed284eb7ca3f74ceb8dcfdd25636d3a84186d0a687d36693" - url: "https://pub.dev" - source: hosted - version: "3.2.1" stream_channel: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5f533b9ea..57210929e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -139,7 +139,7 @@ dependencies: url: https://github.com/bggRGjQaUbCoE/canvas_danmaku.git ref: main # 状态栏图标控制 - status_bar_control: ^3.2.1 + # status_bar_control: ^3.2.1 # 代理 system_proxy: ^0.1.0 # pip