2021-09-29 23:57:09 +00:00
|
|
|
/// 上下键翻页
|
|
|
|
|
2021-10-13 13:57:35 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2021-09-29 23:57:09 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import '../Common.dart';
|
|
|
|
import '../Method.dart';
|
|
|
|
|
2021-10-19 06:28:12 +00:00
|
|
|
const _propertyName = "keyboardController";
|
2021-09-29 23:57:09 +00:00
|
|
|
|
|
|
|
late bool keyboardController;
|
|
|
|
|
|
|
|
Future<void> initKeyboardController() async {
|
|
|
|
keyboardController =
|
2021-10-19 06:28:12 +00:00
|
|
|
(await method.loadProperty(_propertyName, "false")) == "true";
|
2021-09-29 23:57:09 +00:00
|
|
|
}
|
|
|
|
|
2021-11-04 05:56:25 +00:00
|
|
|
Future<void> _chooseKeyboardController(BuildContext context) async {
|
2021-09-29 23:57:09 +00:00
|
|
|
String? result =
|
|
|
|
await chooseListDialog<String>(context, "键盘控制翻页", ["是", "否"]);
|
|
|
|
if (result != null) {
|
|
|
|
var target = result == "是";
|
2021-10-19 06:28:12 +00:00
|
|
|
await method.saveProperty(_propertyName, "$target");
|
2021-09-29 23:57:09 +00:00
|
|
|
keyboardController = target;
|
|
|
|
}
|
|
|
|
}
|
2021-10-13 13:57:35 +00:00
|
|
|
|
|
|
|
Widget keyboardControllerSetting() {
|
|
|
|
if (Platform.isWindows || Platform.isMacOS || Platform.isLinux) {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, void Function(void Function()) setState) {
|
|
|
|
return ListTile(
|
2022-03-19 04:12:27 +00:00
|
|
|
title: const Text("阅读器键盘翻页(仅PC)"),
|
2021-11-04 05:56:25 +00:00
|
|
|
subtitle: Text(keyboardController ? "是" : "否"),
|
2021-10-13 13:57:35 +00:00
|
|
|
onTap: () async {
|
2021-11-04 05:56:25 +00:00
|
|
|
await _chooseKeyboardController(context);
|
2021-10-13 13:57:35 +00:00
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
}
|