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