|
|
@@ -11,8 +11,9 @@ import 'package:sys_volume/flutter_volume.dart';
|
|
|
import 'package:video_player/video_player.dart';
|
|
|
|
|
|
class I2MaterialControls extends StatefulWidget {
|
|
|
+ final bool enableQuickControl;
|
|
|
|
|
|
- const I2MaterialControls({Key key}) : super(key: key);
|
|
|
+ const I2MaterialControls({Key key, this.enableQuickControl = false}) : super(key: key);
|
|
|
|
|
|
@override
|
|
|
State<StatefulWidget> createState() {
|
|
|
@@ -79,7 +80,9 @@ class _MaterialControlsState extends State<I2MaterialControls> {
|
|
|
child: GestureDetector(
|
|
|
onTap: () => _cancelAndRestartTimer(),
|
|
|
onVerticalDragStart: (DragStartDetails details) async {
|
|
|
- print("onVerticalDragStart ${details.globalPosition}");
|
|
|
+ if (!widget.enableQuickControl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 判断距离 只响应2/5的左边和2/5的右边
|
|
|
if (details.globalPosition.dx < MediaQuery.of(context).size.width / 5 * 2) {
|
|
|
// 响应亮度
|
|
|
@@ -103,7 +106,9 @@ class _MaterialControlsState extends State<I2MaterialControls> {
|
|
|
}
|
|
|
},
|
|
|
onVerticalDragUpdate: (DragUpdateDetails details) async {
|
|
|
- print("onVerticalDragUpdate ${details.globalPosition}");
|
|
|
+ if (!widget.enableQuickControl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (_verticalMode != null) {
|
|
|
// 显示数值(百分比)
|
|
|
setState(() {
|
|
|
@@ -152,6 +157,9 @@ class _MaterialControlsState extends State<I2MaterialControls> {
|
|
|
}
|
|
|
},
|
|
|
onVerticalDragEnd: (DragEndDetails details){
|
|
|
+ if (!widget.enableQuickControl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
setState(() {
|
|
|
_verticalMode = null;
|
|
|
currentBright = null;
|
|
|
@@ -160,12 +168,18 @@ class _MaterialControlsState extends State<I2MaterialControls> {
|
|
|
});
|
|
|
},
|
|
|
onHorizontalDragStart: (DragStartDetails detail) {
|
|
|
+ if (!widget.enableQuickControl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (_latestValue.duration == null) return;
|
|
|
_cancelAndRestartTimer();
|
|
|
startDx = detail.localPosition.dx;
|
|
|
dragDuration = _latestValue.position;
|
|
|
},
|
|
|
onHorizontalDragUpdate: (DragUpdateDetails detail) {
|
|
|
+ if (!widget.enableQuickControl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (_latestValue.duration == null) return;
|
|
|
_cancelAndRestartTimer();
|
|
|
lastDx = detail.localPosition.dx;
|
|
|
@@ -177,6 +191,9 @@ class _MaterialControlsState extends State<I2MaterialControls> {
|
|
|
});
|
|
|
},
|
|
|
onHorizontalDragCancel: (){
|
|
|
+ if (!widget.enableQuickControl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
startDx = null;
|
|
|
lastDx = null;
|
|
|
dragDuration = null;
|
|
|
@@ -185,6 +202,9 @@ class _MaterialControlsState extends State<I2MaterialControls> {
|
|
|
});
|
|
|
},
|
|
|
onHorizontalDragEnd: (DragEndDetails detail) {
|
|
|
+ if (!widget.enableQuickControl) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (startDx != null && lastDx != null && _latestValue.duration != null && dragDuration != null) {
|
|
|
Duration finalDuration = getDragDuration();
|
|
|
chewieController.seekTo(finalDuration);
|