opt gesture

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-09-30 13:54:44 +08:00
parent 299ee09749
commit c103551f6a
3 changed files with 24 additions and 17 deletions

View File

@@ -279,10 +279,12 @@ class MyApp extends StatelessWidget {
return;
}
// if (plCtr.isDesktopPip) {
// plCtr.exitDesktopPip();
// return;
// }
if (plCtr.isDesktopPip) {
plCtr.exitDesktopPip().whenComplete(
() => plCtr.initialFocalPoint = Offset.zero,
);
return;
}
}
Get.back();

View File

@@ -262,14 +262,16 @@ class PlPlayerController {
late bool isDesktopPip = false;
late Rect _lastWindowBounds;
void exitDesktopPip() {
isDesktopPip = false;
Offset initialFocalPoint = Offset.zero;
windowManager
..setTitleBarStyle(TitleBarStyle.normal)
..setMinimumSize(const Size(400, 700))
..setBounds(_lastWindowBounds)
..setAlwaysOnTop(false);
Future<void> exitDesktopPip() async {
isDesktopPip = false;
await Future.wait([
windowManager.setTitleBarStyle(TitleBarStyle.normal),
windowManager.setMinimumSize(const Size(400, 700)),
windowManager.setBounds(_lastWindowBounds),
windowManager.setAlwaysOnTop(false),
]);
}
Future<void> enterDesktopPip() async {

View File

@@ -123,7 +123,6 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
late final RxBool showRestoreScaleBtn = false.obs;
Offset _initialFocalPoint = Offset.zero;
GestureType? _gestureType;
//播放器放缩
@@ -810,7 +809,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
if (details.pointerCount == 2) {
interacting = true;
}
_initialFocalPoint = details.localFocalPoint;
plPlayerController.initialFocalPoint = details.localFocalPoint;
// if (kDebugMode) {
// debugPrint("_initialFocalPoint$_initialFocalPoint");
// }
@@ -819,8 +818,11 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
void _onInteractionUpdate(ScaleUpdateDetails details) {
showRestoreScaleBtn.value = transformationController.value.row0.x != 1.0;
if (interacting || _initialFocalPoint == Offset.zero) return;
Offset cumulativeDelta = details.localFocalPoint - _initialFocalPoint;
if (interacting || plPlayerController.initialFocalPoint == Offset.zero) {
return;
}
Offset cumulativeDelta =
details.localFocalPoint - plPlayerController.initialFocalPoint;
if (details.pointerCount == 2 && cumulativeDelta.distance < 1.5) {
interacting = true;
_gestureType = null;
@@ -955,7 +957,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
} else if (_gestureType == GestureType.center) {
// 全屏
const double threshold = 2.5; // 滑动阈值
double cumulativeDy = details.localFocalPoint.dy - _initialFocalPoint.dy;
double cumulativeDy =
details.localFocalPoint.dy - plPlayerController.initialFocalPoint.dy;
void fullScreenTrigger(bool status) {
plPlayerController.triggerFullScreen(status: status);
@@ -1014,7 +1017,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
plPlayerController.onChangedSliderEnd();
}
interacting = false;
_initialFocalPoint = Offset.zero;
plPlayerController.initialFocalPoint = Offset.zero;
_gestureType = null;
}