opt: func

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-07 13:07:15 +08:00
parent 6353ecc13e
commit 286193f08f
99 changed files with 204 additions and 270 deletions

View File

@@ -97,9 +97,9 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
PopupMenuButton(
enabled: ctr.type.value != 0,
initialValue: _dynamicSchemeVariant,
onSelected: (item) async {
onSelected: (item) {
_dynamicSchemeVariant = item;
await GStorage.setting
GStorage.setting
.put(SettingBoxKey.schemeVariant, item.index);
Get.forceAppUpdate();
},
@@ -151,7 +151,7 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
value: 0,
title: const Text('动态取色'),
groupValue: ctr.type.value,
onChanged: (dynamic val) async {
onChanged: (dynamic val) {
ctr.type.value = 0;
ctr.setting.put(SettingBoxKey.dynamicColor, true);
Get.forceAppUpdate();
@@ -163,7 +163,7 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
value: 1,
title: const Text('指定颜色'),
groupValue: ctr.type.value,
onChanged: (dynamic val) async {
onChanged: (dynamic val) {
ctr.type.value = 1;
ctr.setting.put(SettingBoxKey.dynamicColor, false);
Get.forceAppUpdate();

View File

@@ -59,13 +59,13 @@ class _SetDisplayModeState extends State<SetDisplayMode> {
} on PlatformException catch (e) {
debugPrint(e.toString());
}
var res = await getDisplayModeType(modes);
var res = getDisplayModeType(modes);
preferred = modes.toList().firstWhere((el) => el == res);
FlutterDisplayMode.setPreferredMode(preferred!);
}
Future<DisplayMode> getDisplayModeType(modes) async {
DisplayMode getDisplayModeType(modes) {
var value = setting.get(SettingBoxKey.displayMode);
DisplayMode f = DisplayMode.auto;
if (value != null) {

View File

@@ -38,11 +38,11 @@ class _LogsPageState extends State<LogsPage> {
Future<void> getPath() async {
logsPath = await getLogsPath();
fileContent = await logsPath.readAsString();
logsContent = await parseLogs(fileContent);
logsContent = parseLogs(fileContent);
setState(() {});
}
Future<List<Map<String, dynamic>>> parseLogs(String fileContent) async {
List<Map<String, dynamic>> parseLogs(String fileContent) {
const String splitToken =
'======================================================================';
List contentList = fileContent.split(splitToken).map((item) {
@@ -83,8 +83,8 @@ class _LogsPageState extends State<LogsPage> {
return result.reversed.toList();
}
Future<void> copyLogs() async {
await Utils.copyText('```\n$fileContent\n```', needToast: false);
void copyLogs() {
Utils.copyText('```\n$fileContent\n```', needToast: false);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('复制成功')),
@@ -177,8 +177,8 @@ class _LogsPageState extends State<LogsPage> {
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.compact,
),
onPressed: () async {
await Utils.copyText('```\n${log['body']}\n```',
onPressed: () {
Utils.copyText('```\n${log['body']}\n```',
needToast: false);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(

View File

@@ -108,7 +108,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
child: const Text('取消'),
),
TextButton(
onPressed: () async {
onPressed: () {
if (customSpeed == null) {
SmartDialog.showToast('输入倍数不合法');
} else if (speedList.contains(customSpeed)) {
@@ -118,7 +118,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
speedList
..add(customSpeed!)
..sort();
await video.put(VideoBoxKey.speedsList, speedList);
video.put(VideoBoxKey.speedsList, speedList);
setState(() {});
}
},
@@ -168,7 +168,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
}
//
Future<void> menuAction(index, id) async {
void menuAction(index, id) {
double speed = speedList[index];
// 设置
if (id == 1) {
@@ -189,7 +189,7 @@ class _PlaySpeedPageState extends State<PlaySpeedPage> {
return;
}
speedList.removeAt(index);
await video.put(VideoBoxKey.speedsList, speedList);
video.put(VideoBoxKey.speedsList, speedList);
}
setState(() {});
}