opt player progress bar behavior (#1887)

* feat: no _showControlsIfNeeded() when slipping

* Revert "feat: no _showControlsIfNeeded() when slipping"

This reverts commit 551be3dc6a.

* feat: show progress bar during drag without revealing controls overlay

* fix: show Controls progress bar during drag instead of full overlay

* Revert "fix: show Controls progress bar during drag instead of full overlay"

This reverts commit 18ecda3379.

* fix: hide thin progress bar during drag when Controls already visible

* fix: show thin progress bar during drag when progressType is alwaysHide

* Revert "fix: show thin progress bar during drag when progressType is alwaysHide"

This reverts commit 1a60c8e6df.

* fix: show thin progress bar during drag when progressType is alwaysHide

* update

---------

Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
систем
2026-04-11 21:32:37 +08:00
committed by GitHub
parent cbc4f58323
commit a2ff54af70

View File

@@ -38,7 +38,6 @@ import 'package:PiliPlus/pages/video/post_panel/view.dart';
import 'package:PiliPlus/pages/video/widgets/header_control.dart'; import 'package:PiliPlus/pages/video/widgets/header_control.dart';
import 'package:PiliPlus/plugin/pl_player/controller.dart'; import 'package:PiliPlus/plugin/pl_player/controller.dart';
import 'package:PiliPlus/plugin/pl_player/models/bottom_control_type.dart'; import 'package:PiliPlus/plugin/pl_player/models/bottom_control_type.dart';
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
import 'package:PiliPlus/plugin/pl_player/models/data_status.dart'; import 'package:PiliPlus/plugin/pl_player/models/data_status.dart';
import 'package:PiliPlus/plugin/pl_player/models/double_tap_type.dart'; import 'package:PiliPlus/plugin/pl_player/models/double_tap_type.dart';
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart'; import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
@@ -976,7 +975,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
final dy = cumulativeDelta.dy.abs(); final dy = cumulativeDelta.dy.abs();
if (dx > 3 * dy) { if (dx > 3 * dy) {
_gestureType = GestureType.horizontal; _gestureType = GestureType.horizontal;
_showControlsIfNeeded();
} else if (dy > 3 * dx) { } else if (dy > 3 * dx) {
if (!plPlayerController.enableSlideVolumeBrightness && if (!plPlayerController.enableSlideVolumeBrightness &&
!plPlayerController.enableSlideFS) { !plPlayerController.enableSlideFS) {
@@ -1274,19 +1272,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
} }
} }
void _showControlsIfNeeded() {
if (plPlayerController.isLive) return;
late final isFullScreen = this.isFullScreen;
final progressType = plPlayerController.progressType;
if (progressType == BtmProgressBehavior.alwaysHide ||
(isFullScreen &&
progressType == BtmProgressBehavior.onlyHideFullScreen) ||
(!isFullScreen &&
progressType == BtmProgressBehavior.onlyShowFullScreen)) {
plPlayerController.controls = true;
}
}
void _onPointerPanZoomUpdate(PointerPanZoomUpdateEvent event) { void _onPointerPanZoomUpdate(PointerPanZoomUpdateEvent event) {
if (plPlayerController.controlsLock.value) return; if (plPlayerController.controlsLock.value) return;
if (_gestureType == null) { if (_gestureType == null) {
@@ -1296,7 +1281,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
final dy = pan.dy.abs(); final dy = pan.dy.abs();
if (dx > 3 * dy) { if (dx > 3 * dy) {
_gestureType = GestureType.horizontal; _gestureType = GestureType.horizontal;
_showControlsIfNeeded();
} else if (dy > 3 * dx) { } else if (dy > 3 * dx) {
_gestureType = GestureType.right; _gestureType = GestureType.right;
} }
@@ -1728,8 +1712,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
), ),
/// 进度条 live模式下禁用 /// 进度条 live模式下禁用
if (!isLive && if (!isLive)
plPlayerController.progressType != BtmProgressBehavior.alwaysHide)
Positioned( Positioned(
bottom: -2.2, bottom: -2.2,
left: 0, left: 0,
@@ -1737,13 +1720,26 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: Obx( child: Obx(
() { () {
final showControls = plPlayerController.showControls.value; final showControls = plPlayerController.showControls.value;
final offstage = switch (plPlayerController.progressType) { final bool offstage;
BtmProgressBehavior.onlyShowFullScreen => switch (plPlayerController.progressType) {
showControls || !isFullScreen, case .alwaysShow:
BtmProgressBehavior.onlyHideFullScreen => offstage = showControls;
showControls || isFullScreen, case .alwaysHide:
_ => showControls, if (!plPlayerController.isSliderMoving.value) {
}; return const SizedBox.shrink();
}
offstage = showControls;
case .onlyShowFullScreen:
offstage =
showControls ||
(!isFullScreen &&
!plPlayerController.isSliderMoving.value);
case .onlyHideFullScreen:
offstage =
showControls ||
(isFullScreen &&
!plPlayerController.isSliderMoving.value);
}
return Offstage( return Offstage(
offstage: offstage, offstage: offstage,
child: Stack( child: Stack(