mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
feat: show progress bar during drag without revealing controls overlay
This commit is contained in:
@@ -145,6 +145,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
late FullScreenMode mode;
|
late FullScreenMode mode;
|
||||||
|
|
||||||
late final RxBool showRestoreScaleBtn = false.obs;
|
late final RxBool showRestoreScaleBtn = false.obs;
|
||||||
|
final RxBool _isDraggingProgress = false.obs;
|
||||||
|
|
||||||
GestureType? _gestureType;
|
GestureType? _gestureType;
|
||||||
|
|
||||||
@@ -976,7 +977,7 @@ 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();
|
_isDraggingProgress.value = true;
|
||||||
} else if (dy > 3 * dx) {
|
} else if (dy > 3 * dx) {
|
||||||
if (!plPlayerController.enableSlideVolumeBrightness &&
|
if (!plPlayerController.enableSlideVolumeBrightness &&
|
||||||
!plPlayerController.enableSlideFS) {
|
!plPlayerController.enableSlideFS) {
|
||||||
@@ -1127,6 +1128,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onInteractionEnd(ScaleEndDetails details) {
|
void _onInteractionEnd(ScaleEndDetails details) {
|
||||||
|
_isDraggingProgress.value = false;
|
||||||
if (plPlayerController.showSeekPreview) {
|
if (plPlayerController.showSeekPreview) {
|
||||||
plPlayerController.showPreview.value = false;
|
plPlayerController.showPreview.value = false;
|
||||||
}
|
}
|
||||||
@@ -1274,18 +1276,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;
|
||||||
@@ -1296,7 +1286,7 @@ 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();
|
_isDraggingProgress.value = true;
|
||||||
} else if (dy > 3 * dx) {
|
} else if (dy > 3 * dx) {
|
||||||
_gestureType = GestureType.right;
|
_gestureType = GestureType.right;
|
||||||
}
|
}
|
||||||
@@ -1350,6 +1340,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onPointerPanZoomEnd(PointerPanZoomEndEvent event) {
|
void _onPointerPanZoomEnd(PointerPanZoomEndEvent event) {
|
||||||
|
_isDraggingProgress.value = false;
|
||||||
_gestureType = null;
|
_gestureType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1737,13 +1728,16 @@ 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 isDragging = _isDraggingProgress.value;
|
||||||
BtmProgressBehavior.onlyShowFullScreen =>
|
final offstage = isDragging
|
||||||
showControls || !isFullScreen,
|
? false
|
||||||
BtmProgressBehavior.onlyHideFullScreen =>
|
: switch (plPlayerController.progressType) {
|
||||||
showControls || isFullScreen,
|
BtmProgressBehavior.onlyShowFullScreen =>
|
||||||
_ => showControls,
|
showControls || !isFullScreen,
|
||||||
};
|
BtmProgressBehavior.onlyHideFullScreen =>
|
||||||
|
showControls || isFullScreen,
|
||||||
|
_ => showControls,
|
||||||
|
};
|
||||||
return Offstage(
|
return Offstage(
|
||||||
offstage: offstage,
|
offstage: offstage,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
|||||||
Reference in New Issue
Block a user