新增夜间模式相关代码
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:developer' as dev;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import '../theme/theme_service.dart';
|
||||
|
||||
// --- 本地导入 ---
|
||||
import '../models/device_matching.dart';
|
||||
@@ -626,6 +627,56 @@ class _BatteryHealthPageState extends State<BatteryHealthPage> {
|
||||
return ChargeUtils.getChargeTypeLabel(_isWireless, _chargeType);
|
||||
}
|
||||
|
||||
// 🆕 夜间模式切换弹窗 ← 加在这里
|
||||
void _showThemePicker() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (ctx) {
|
||||
final current = ThemeService.notifier.value;
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.brightness_auto),
|
||||
title: const Text('跟随系统'),
|
||||
trailing: current == ThemeMode.system
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ThemeService.setMode(ThemeMode.system);
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.light_mode),
|
||||
title: const Text('浅色'),
|
||||
trailing: current == ThemeMode.light
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ThemeService.setMode(ThemeMode.light);
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.dark_mode),
|
||||
title: const Text('深色'),
|
||||
trailing: current == ThemeMode.dark
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () {
|
||||
ThemeService.setMode(ThemeMode.dark);
|
||||
Navigator.pop(ctx);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- Build ----------
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -695,7 +746,7 @@ class _BatteryHealthPageState extends State<BatteryHealthPage> {
|
||||
);
|
||||
break;
|
||||
case 'dark_mode':
|
||||
// 夜间模式切换逻辑(1.7.0 再实现)
|
||||
_showThemePicker();
|
||||
break;
|
||||
}
|
||||
},
|
||||
@@ -705,11 +756,7 @@ class _BatteryHealthPageState extends State<BatteryHealthPage> {
|
||||
value: 'about', // 🟢 新增
|
||||
child: Text('关于'),
|
||||
),
|
||||
const PopupMenuItem(
|
||||
value: 'dark_mode',
|
||||
enabled: false, // 暂时灰显
|
||||
child: Text('夜间模式(开发中)'),
|
||||
),
|
||||
const PopupMenuItem(value: 'dark_mode', child: Text('夜间模式')),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user