新批次的夜间模式适配代码

This commit is contained in:
2026-07-30 23:38:34 +08:00
parent b6d623a1eb
commit 42a30a73f9
11 changed files with 151 additions and 83 deletions
+13 -1
View File
@@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:device_info_plus/device_info_plus.dart';
// --- 本地导入 ---
import '../main.dart';
import '../models/device_matching.dart';
import '../models/saf_permission_state.dart';
import '../models/data_abnormal_type.dart';
@@ -742,7 +743,18 @@ class _BatteryHealthPageState extends State<BatteryHealthPage> {
);
break;
case 'dark_mode':
// 夜间模式切换逻辑(需要全局状态管理)
// 循环切换:浅色 → 深色 → 跟随系统 → 浅色
final brightness = Theme.of(context).brightness;
ThemeMode next;
if (brightness == Brightness.light) {
next = ThemeMode.dark;
} else if (brightness == Brightness.dark) {
next = ThemeMode.system;
} else {
next = ThemeMode.light;
}
// 🆕 通过全局 key 调用 MyApp 的 switchTheme 方法
appKey.currentState?.switchTheme(next);
break;
}
},