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';
|
|
|
|
|
|
|
|
const propertyName = "volumeController";
|
|
|
|
|
|
|
|
late bool volumeController;
|
|
|
|
|
|
|
|
Future<void> initVolumeController() async {
|
2021-10-13 13:57:35 +00:00
|
|
|
volumeController =
|
|
|
|
(await method.loadProperty(propertyName, "false")) == "true";
|
2021-09-29 23:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String volumeControllerName() {
|
|
|
|
return volumeController ? "是" : "否";
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> chooseVolumeController(BuildContext context) async {
|
|
|
|
String? result =
|
|
|
|
await chooseListDialog<String>(context, "音量键控制翻页", ["是", "否"]);
|
|
|
|
if (result != null) {
|
|
|
|
var target = result == "是";
|
|
|
|
await method.saveProperty(propertyName, "$target");
|
|
|
|
volumeController = target;
|
|
|
|
}
|
|
|
|
}
|
2021-10-13 13:57:35 +00:00
|
|
|
|
|
|
|
Widget volumeControllerSetting() {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
return StatefulBuilder(builder:
|
|
|
|
(BuildContext context, void Function(void Function()) setState) {
|
|
|
|
return ListTile(
|
|
|
|
title: Text("阅读器音量键翻页(仅安卓)"),
|
|
|
|
subtitle: Text(volumeControllerName()),
|
|
|
|
onTap: () async {
|
|
|
|
await chooseVolumeController(context);
|
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
}
|