2021-09-29 23:57:09 +00:00
|
|
|
/// 全屏操作
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../Common.dart';
|
|
|
|
import '../Method.dart';
|
|
|
|
|
|
|
|
enum FullScreenAction {
|
|
|
|
TOUCH_ONCE,
|
2022-03-17 01:39:38 +00:00
|
|
|
CONTROLLER,
|
2022-03-07 12:18:30 +00:00
|
|
|
TOUCH_DOUBLE,
|
|
|
|
TOUCH_DOUBLE_ONCE_NEXT,
|
2021-11-29 03:26:30 +00:00
|
|
|
THREE_AREA,
|
2021-09-29 23:57:09 +00:00
|
|
|
}
|
|
|
|
|
2021-11-04 05:56:25 +00:00
|
|
|
Map<String, FullScreenAction> _fullScreenActionMap = {
|
2021-12-02 02:32:35 +00:00
|
|
|
"点击屏幕一次全屏": FullScreenAction.TOUCH_ONCE,
|
2022-03-17 01:39:38 +00:00
|
|
|
"使用控制器全屏": FullScreenAction.CONTROLLER,
|
2022-03-07 12:18:30 +00:00
|
|
|
"双击屏幕全屏": FullScreenAction.TOUCH_DOUBLE,
|
|
|
|
"双击屏幕全屏 + 单击屏幕下一页": FullScreenAction.TOUCH_DOUBLE_ONCE_NEXT,
|
2022-03-31 14:09:35 +00:00
|
|
|
"将屏幕划分成三个区域 (上一页, 下一页, 全屏) (不能使用快捷下一页按钮)": FullScreenAction.THREE_AREA,
|
2021-11-04 05:56:25 +00:00
|
|
|
};
|
2021-09-29 23:57:09 +00:00
|
|
|
|
2021-12-03 21:56:31 +00:00
|
|
|
const _defaultController = FullScreenAction.TOUCH_ONCE;
|
2021-09-29 23:57:09 +00:00
|
|
|
const _propertyName = "fullScreenAction";
|
2021-11-04 05:56:25 +00:00
|
|
|
late FullScreenAction _fullScreenAction;
|
2021-09-29 23:57:09 +00:00
|
|
|
|
|
|
|
Future<void> initFullScreenAction() async {
|
2021-11-04 05:56:25 +00:00
|
|
|
_fullScreenAction = _fullScreenActionFromString(await method.loadProperty(
|
2021-09-29 23:57:09 +00:00
|
|
|
_propertyName,
|
2022-03-23 10:51:38 +00:00
|
|
|
FullScreenAction.TOUCH_ONCE.toString(),
|
2021-09-29 23:57:09 +00:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2021-11-04 05:56:25 +00:00
|
|
|
FullScreenAction currentFullScreenAction() {
|
|
|
|
return _fullScreenAction;
|
|
|
|
}
|
|
|
|
|
2021-09-29 23:57:09 +00:00
|
|
|
FullScreenAction _fullScreenActionFromString(String string) {
|
|
|
|
for (var value in FullScreenAction.values) {
|
|
|
|
if (string == value.toString()) {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
2021-12-03 21:56:31 +00:00
|
|
|
return _defaultController;
|
2021-09-29 23:57:09 +00:00
|
|
|
}
|
|
|
|
|
2021-12-03 10:51:21 +00:00
|
|
|
String currentFullScreenActionName() {
|
2021-11-04 05:56:25 +00:00
|
|
|
for (var e in _fullScreenActionMap.entries) {
|
|
|
|
if (e.value == _fullScreenAction) {
|
2021-09-29 23:57:09 +00:00
|
|
|
return e.key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2021-12-03 10:51:21 +00:00
|
|
|
Future<void> chooseFullScreenAction(BuildContext context) async {
|
2021-09-29 23:57:09 +00:00
|
|
|
FullScreenAction? result = await chooseMapDialog<FullScreenAction>(
|
2021-12-02 02:32:35 +00:00
|
|
|
context, _fullScreenActionMap, "选择操控方式");
|
2021-09-29 23:57:09 +00:00
|
|
|
if (result != null) {
|
|
|
|
await method.saveProperty(_propertyName, result.toString());
|
2021-11-04 05:56:25 +00:00
|
|
|
_fullScreenAction = result;
|
2021-09-29 23:57:09 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-04 03:45:22 +00:00
|
|
|
|
|
|
|
Widget fullScreenActionSetting() {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, void Function(void Function()) setState) {
|
|
|
|
return ListTile(
|
2022-03-19 04:12:27 +00:00
|
|
|
title: const Text("操控方式"),
|
2021-12-03 10:51:21 +00:00
|
|
|
subtitle: Text(currentFullScreenActionName()),
|
2021-11-04 03:45:22 +00:00
|
|
|
onTap: () async {
|
2021-12-03 10:51:21 +00:00
|
|
|
await chooseFullScreenAction(context);
|
2021-11-04 03:45:22 +00:00
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|