From 0577a090fdeb1ca599b20d75a68c4089cdf66c03 Mon Sep 17 00:00:00 2001 From: qshh <101165772+qinshah@users.noreply.github.com> Date: Sat, 1 Aug 2026 18:05:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(ui):=20=E9=87=8D=E6=9E=84=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E7=8A=B6=E6=80=81=E6=A0=8F=E5=88=87=E6=8D=A2=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除原有的 `StatusBar` 管理类,改用 `fullscreen.dart` 中的工具函数统一管理系统状态栏的显示与隐藏。 主要变更: - 移除 `lib/harmony_adapt/status_bar.dart`。 - 重构 `showSystemBar` 函数,支持传入 `reason` 参数用于调试日志打印。 - 在 `fullscreen.dart` 中新增 `toggleSystemBar` 函数,实现状态栏状态的切换。 - 更新视频播放器、图片查看器及视频详情页的调用逻辑,以适配新的工具函数。 --- .../widgets/image_viewer/gallery_viewer.dart | 2 +- lib/harmony_adapt/status_bar.dart | 16 ---------------- lib/main.dart | 11 +++++++++++ lib/pages/video/view.dart | 8 ++++---- lib/plugin/pl_player/controller.dart | 4 ++-- lib/plugin/pl_player/utils/fullscreen.dart | 14 ++++++++++---- lib/plugin/pl_player/view/view.dart | 14 +++++++------- pubspec.yaml | 2 +- 8 files changed, 36 insertions(+), 35 deletions(-) delete mode 100644 lib/harmony_adapt/status_bar.dart diff --git a/lib/common/widgets/image_viewer/gallery_viewer.dart b/lib/common/widgets/image_viewer/gallery_viewer.dart index 2c42522c3a..dc9d1e3e17 100644 --- a/lib/common/widgets/image_viewer/gallery_viewer.dart +++ b/lib/common/widgets/image_viewer/gallery_viewer.dart @@ -303,7 +303,7 @@ class _GalleryViewerState extends State Future.delayed(const Duration(milliseconds: 200), _currIndex.close); super.dispose(); if (_hideSystemBar) { - showSystemBar(); + showSystemBar('gallery_dispose'); } } diff --git a/lib/harmony_adapt/status_bar.dart b/lib/harmony_adapt/status_bar.dart deleted file mode 100644 index 15a793a2ac..0000000000 --- a/lib/harmony_adapt/status_bar.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -class StatusBar extends ChangeNotifier { - static final StatusBar i = StatusBar._(); - StatusBar._(); - - bool hidden = false; - - void toggleHide() { - SystemChrome.setEnabledSystemUIMode( - hidden ? SystemUiMode.edgeToEdge : SystemUiMode.immersiveSticky, - ); - hidden = !hidden; - } -} diff --git a/lib/main.dart b/lib/main.dart index b994b65f8a..7624770ab2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -410,6 +410,17 @@ class MyApp extends StatelessWidget { child: child, ); } + // child = Stack( + // children: [ + // child, + // const Center( + // child: ElevatedButton( + // onPressed: toggleSystemBar, + // child: Text('测试'), + // ), + // ), + // ], + // ); return child; } diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 3195c8e152..b4dffbf49f 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -60,14 +60,14 @@ import 'package:PiliPlus/utils/max_screen_size.dart'; import 'package:PiliPlus/utils/mobile_observer.dart'; import 'package:PiliPlus/utils/num_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; +import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_key.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/theme_utils.dart'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; -import 'package:flutter/foundation.dart' show kDebugMode; import 'package:floating/floating.dart'; -import 'package:PiliPlus/utils/platform_utils.dart'; +import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show SystemUiOverlayStyle; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -387,7 +387,7 @@ class _VideoDetailPageVState extends State } if (!videoDetailController.removeSafeArea) { - showSystemBar(); + showSystemBar('video_page_portrait'); } if (!videoDetailController.plPlayerController.isCloseAll) { @@ -531,7 +531,7 @@ class _VideoDetailPageVState extends State Widget get childWhenDisabled { if (PlatformUtils.isMobile && mounted && isShowing && !isFullScreen) { if (isPortrait) { - showSystemBar(); + // showSystemBar('video_page_dispose'); } else if (!videoDetailController.horizontalScreen) { hideSystemBar(); } diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 9ceb5cf54e..29084d5866 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1627,7 +1627,7 @@ class PlPlayerController with BlockConfigMixin { } else { if (PlatformUtils.isMobile) { if (!removeSafeArea) { - showSystemBar(); + showSystemBar('controller_fullscreen_exit'); } if (orientation == null && mode == .none) { return; @@ -1761,7 +1761,7 @@ class PlPlayerController with BlockConfigMixin { _playerCount = 0; if (removeSafeArea) { - showSystemBar(); + showSystemBar('controller_dispose'); } danmakuController = null; _stopOrientationListener(); diff --git a/lib/plugin/pl_player/utils/fullscreen.dart b/lib/plugin/pl_player/utils/fullscreen.dart index e4a6e12455..98763affe7 100644 --- a/lib/plugin/pl_player/utils/fullscreen.dart +++ b/lib/plugin/pl_player/utils/fullscreen.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'dart:io' show Platform; import 'package:PiliPlus/harmony_adapt/harmony_channel.dart'; -import 'package:PiliPlus/harmony_adapt/status_bar.dart'; import 'package:PiliPlus/utils/device_utils.dart'; import 'package:PiliPlus/utils/platform_utils.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:auto_orientation/auto_orientation.dart'; +import 'package:flutter/foundation.dart' show debugPrint; import 'package:flutter/services.dart' show SystemChrome, MethodChannel, SystemUiOverlay, DeviceOrientation; import 'package:os_type/os_type.dart'; @@ -113,19 +113,25 @@ Future? hideSystemBar() { return null; } _showSystemBar = false; - StatusBar.i.hidden = true; // 鸿蒙状态栏由原生侧控制 return SystemChrome.setEnabledSystemUIMode(.immersiveSticky); } //退出全屏显示 -Future? showSystemBar() { +Future? showSystemBar(String reason) { if (_showSystemBar) { return null; } _showSystemBar = true; - StatusBar.i.hidden = false; // 鸿蒙状态栏由原生侧控制 + debugPrint('showSystemBar: $reason'); return SystemChrome.setEnabledSystemUIMode( Platform.isAndroid && DeviceUtils.sdkInt < 29 ? .manual : .edgeToEdge, overlays: SystemUiOverlay.values, ); } + +Future toggleSystemBar() { + _showSystemBar = !_showSystemBar; + return SystemChrome.setEnabledSystemUIMode( + _showSystemBar ? .edgeToEdge : .immersiveSticky, + ); +} diff --git a/lib/plugin/pl_player/view/view.dart b/lib/plugin/pl_player/view/view.dart index 66e25a4e70..9b73ff006b 100644 --- a/lib/plugin/pl_player/view/view.dart +++ b/lib/plugin/pl_player/view/view.dart @@ -18,7 +18,6 @@ import 'package:PiliPlus/common/widgets/player_bar.dart'; import 'package:PiliPlus/common/widgets/progress_bar/audio_video_progress_bar.dart'; import 'package:PiliPlus/common/widgets/progress_bar/segment_progress_bar.dart'; import 'package:PiliPlus/common/widgets/view_safe_area.dart'; -import 'package:PiliPlus/harmony_adapt/status_bar.dart'; import 'package:PiliPlus/models/common/sponsor_block/action_type.dart'; import 'package:PiliPlus/models/common/sponsor_block/post_segment_model.dart'; import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart'; @@ -44,6 +43,7 @@ import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart'; import 'package:PiliPlus/plugin/pl_player/models/gesture_type.dart'; import 'package:PiliPlus/plugin/pl_player/models/play_status.dart'; import 'package:PiliPlus/plugin/pl_player/models/video_fit_type.dart'; +import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart'; import 'package:PiliPlus/plugin/pl_player/widgets/app_bar_ani.dart'; import 'package:PiliPlus/plugin/pl_player/widgets/backward_seek.dart'; import 'package:PiliPlus/plugin/pl_player/widgets/bottom_control.dart'; @@ -72,8 +72,6 @@ import 'package:easy_debounce/easy_throttle.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; -import 'package:os_type/os_type.dart'; -import 'package:screen_brightness_platform_interface/constant/plugin_channel.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart' show RenderProxyBox, SemanticsConfiguration; @@ -84,6 +82,8 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:media_kit_video/media_kit_video.dart'; +import 'package:os_type/os_type.dart'; +import 'package:screen_brightness_platform_interface/constant/plugin_channel.dart'; import 'package:screen_brightness_platform_interface/screen_brightness_platform_interface.dart'; import 'package:window_manager/window_manager.dart'; @@ -971,16 +971,16 @@ class _PLVideoPlayerState extends State mainAxisSize: .min, children: [ if (isFullScreen) - SizedBox( + const SizedBox( width: 42, height: 34, child: IconButton( tooltip: '切换状态栏隐藏', - style: const ButtonStyle( + style: ButtonStyle( padding: WidgetStatePropertyAll(EdgeInsets.zero), ), - onPressed: StatusBar.i.toggleHide, - icon: const Icon( + onPressed: toggleSystemBar, + icon: Icon( Icons.ad_units, size: 19, color: Colors.white, diff --git a/pubspec.yaml b/pubspec.yaml index 58d1a89832..4222b6862a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. # update when release -version: 2.1.0+5573 +version: 2.1.0+5578 environment: sdk: ">=3.11.1" From 577bd279821806cf01585708e6f4da1541d2a1a1 Mon Sep 17 00:00:00 2001 From: qshh <101165772+qinshah@users.noreply.github.com> Date: Sat, 1 Aug 2026 18:21:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(hideSystemBar):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AF=A6=E6=83=85=E9=A1=B5=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=A0=8F=E9=9A=90=E8=97=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整 `_VideoDetailPageVState` 中 `childWhenDisabled` 的判断条件。 移除对 `isPortrait` 的依赖,改为根据 `videoDetailController` 的横屏状态或安全区域移除状态来决定是否隐藏系统状态栏,以确保在不同显示模式下状态栏行为的一致性。 --- lib/pages/video/view.dart | 4 +--- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index b4dffbf49f..16a96e534b 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -530,9 +530,7 @@ class _VideoDetailPageVState extends State Widget get childWhenDisabled { if (PlatformUtils.isMobile && mounted && isShowing && !isFullScreen) { - if (isPortrait) { - // showSystemBar('video_page_dispose'); - } else if (!videoDetailController.horizontalScreen) { + if (videoDetailController.horizontalScreen || videoDetailController.removeSafeArea) { hideSystemBar(); } } diff --git a/pubspec.yaml b/pubspec.yaml index 4222b6862a..cc9379f2ca 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. # update when release -version: 2.1.0+5578 +version: 2.1.0+5579 environment: sdk: ">=3.11.1"