2021-11-15 08:26:53 +00:00
|
|
|
/// 显示模式, 仅安卓有效
|
2021-10-13 13:57:35 +00:00
|
|
|
|
2021-09-29 23:57:09 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
2021-11-11 03:00:38 +00:00
|
|
|
import 'package:pikapika/basic/Method.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
|
|
|
|
import '../Common.dart';
|
2022-07-09 07:11:26 +00:00
|
|
|
import 'IsPro.dart';
|
2021-09-29 23:57:09 +00:00
|
|
|
|
|
|
|
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);
|
2022-07-09 07:11:26 +00:00
|
|
|
String? result = await chooseListDialog<String>(
|
|
|
|
context,
|
|
|
|
"安卓屏幕刷新率 \n(省电模式下不会高刷)",
|
|
|
|
list,
|
|
|
|
);
|
2021-09-29 23:57:09 +00:00
|
|
|
if (result != null) {
|
2022-03-17 03:31:25 +00:00
|
|
|
await method.saveProperty(_propertyName, result);
|
2021-09-29 23:57:09 +00:00
|
|
|
_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(
|
2022-07-09 07:11:26 +00:00
|
|
|
title: Text(
|
|
|
|
"屏幕刷新率(安卓)" + (!isPro ? "(发电)" : ""),
|
|
|
|
style: TextStyle(
|
|
|
|
color: !isPro ? Colors.grey : null,
|
|
|
|
),
|
|
|
|
),
|
2021-11-04 05:56:25 +00:00
|
|
|
subtitle: Text(_androidDisplayMode),
|
2021-10-13 13:57:35 +00:00
|
|
|
onTap: () async {
|
2022-07-09 07:11:26 +00:00
|
|
|
if (!isPro) {
|
|
|
|
defaultToast(context, "请先发电再使用");
|
|
|
|
return;
|
|
|
|
}
|
2021-11-04 05:56:25 +00:00
|
|
|
await _chooseAndroidDisplayMode(context);
|
2021-10-13 13:57:35 +00:00
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Container();
|
|
|
|
}
|