feat: 全屏手势可关闭
This commit is contained in:
@ -4,9 +4,12 @@ enum FullScreenGestureMode {
|
||||
|
||||
/// 从下滑到上
|
||||
fromBottomtoTop,
|
||||
|
||||
/// 关闭手势
|
||||
none,
|
||||
}
|
||||
|
||||
extension FullScreenGestureModeExtension on FullScreenGestureMode {
|
||||
String get values => ['fromToptoBottom', 'fromBottomtoTop'][index];
|
||||
String get labels => ['从上往下滑进入全屏', '从下往上滑进入全屏'][index];
|
||||
String get values => ['fromToptoBottom', 'fromBottomtoTop', 'none'][index];
|
||||
String get labels => ['从上往下滑进入全屏', '从下往上滑进入全屏', '关闭手势'][index];
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/utils/global_data_cache.dart';
|
||||
|
||||
@ -22,7 +23,7 @@ class _PlayGesturePageState extends State<PlayGesturePage> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
fullScreenGestureMode = setting.get(SettingBoxKey.fullScreenGestureMode,
|
||||
defaultValue: FullScreenGestureMode.values.last.index);
|
||||
defaultValue: FullScreenGestureMode.fromBottomtoTop.index);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -71,6 +72,7 @@ class _PlayGesturePageState extends State<PlayGesturePage> {
|
||||
GlobalDataCache().fullScreenGestureMode.index;
|
||||
setting.put(
|
||||
SettingBoxKey.fullScreenGestureMode, fullScreenGestureMode);
|
||||
SmartDialog.showToast('设置成功');
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
|
@ -204,6 +204,14 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
widget.controller.brightness.value = value;
|
||||
}
|
||||
|
||||
bool isUsingFullScreenGestures(double tapPosition, double sectionWidth) {
|
||||
if (fullScreenGestureMode == FullScreenGestureMode.none) {
|
||||
return false;
|
||||
} else {
|
||||
return tapPosition < sectionWidth * 2;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
animationController.dispose();
|
||||
@ -660,12 +668,12 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
|
||||
_brightnessValue.value - delta / level;
|
||||
final double result = brightness.clamp(0.0, 1.0);
|
||||
setBrightness(result);
|
||||
} else if (tapPosition < sectionWidth * 2) {
|
||||
} else if (isUsingFullScreenGestures(tapPosition, sectionWidth)) {
|
||||
// 全屏
|
||||
final double dy = details.delta.dy;
|
||||
const double threshold = 7.0; // 滑动阈值
|
||||
final bool flag =
|
||||
fullScreenGestureMode != FullScreenGestureMode.values.last;
|
||||
final bool flag = fullScreenGestureMode !=
|
||||
FullScreenGestureMode.fromBottomtoTop;
|
||||
if (dy > _distance.value &&
|
||||
dy > threshold &&
|
||||
!_.controlsLock.value) {
|
||||
|
Reference in New Issue
Block a user