2021-10-13 13:57:35 +00:00
|
|
|
// 显示模式, 仅安卓有效
|
|
|
|
|
2021-09-29 23:57:09 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:pikapi/basic/Method.dart';
|
|
|
|
|
|
|
|
import '../Common.dart';
|
|
|
|
|
|
|
|
const _propertyName = "androidDisplayMode";
|
2021-11-04 05:56:25 +00:00
|
|
|
List<String> _modes = [];
|
2021-09-29 23:57:09 +00:00
|
|
|
String _androidDisplayMode = "";
|
|
|
|
|
|
|
|
Future initAndroidDisplayMode() async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
_androidDisplayMode = await method.loadProperty(_propertyName, "");
|
2021-11-04 05:56:25 +00:00
|
|
|
_modes = await method.loadAndroidModes();
|
2021-09-29 23:57:09 +00:00
|
|
|
await _changeMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future _changeMode() async {
|
|
|
|
await method.setAndroidMode(_androidDisplayMode);
|
|
|
|
}
|
|
|
|
|
2021-11-04 05:56:25 +00:00
|
|
|
Future<void> _chooseAndroidDisplayMode(BuildContext context) async {
|
2021-09-29 23:57:09 +00:00
|
|
|
if (Platform.isAndroid) {
|
|
|
|
List<String> list = [""];
|
2021-11-04 05:56:25 +00:00
|
|
|
list.addAll(_modes);
|
2021-10-13 13:57:35 +00:00
|
|
|
String? result = await chooseListDialog<String>(context, "安卓屏幕刷新率", list);
|
2021-09-29 23:57:09 +00:00
|
|
|
if (result != null) {
|
|
|
|
await method.saveProperty(_propertyName, "$result");
|
|
|
|
_androidDisplayMode = result;
|
|
|
|
await _changeMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-10-13 13:57:35 +00:00
|
|
|
|
|
|
|
Widget androidDisplayModeSetting() {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
return StatefulBuilder(
|
|
|
|
builder: (BuildContext context, void Function(void Function()) setState) {
|
|
|
|
return ListTile(
|
|
|
|
title: Text("屏幕刷新率(安卓)"),
|
2021-11-04 05:56:25 +00:00
|
|
|
subtitle: Text(_androidDisplayMode),
|
2021-10-13 13:57:35 +00:00
|
|
|
onTap: () async {
|
2021-11-04 05:56:25 +00:00
|
|
|
await _chooseAndroidDisplayMode(context);
|
2021-10-13 13:57:35 +00:00
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
}
|