适配深色模式

This commit is contained in:
DelLevin-Home
2026-05-26 05:10:21 +08:00
parent b36f50827f
commit 73f3795e65
53 changed files with 3846 additions and 3211 deletions

View File

@@ -15,7 +15,6 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
final UserPrefs _userPrefs = UserPrefs();
String _currentIconName = 'app_icon';
// 预定义的图标列表
final List<Map<String, String>> _icons = [
{'name': 'app_icon', 'label': '默认图标'},
{'name': 'app_icon2', 'label': '风格二'},
@@ -28,7 +27,6 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
}
Future<void> _loadCurrentIcon() async {
// 先从原生层获取当前实际启用的图标(更准确)
final nativeIcon = await AppIconChannel.getCurrentIcon();
setState(() {
_currentIconName = nativeIcon;
@@ -39,7 +37,6 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
if (iconName == _currentIconName) return;
try {
// 调用原生层切换桌面图标
final success = await AppIconChannel.switchIcon(iconName);
if (success) {
@@ -65,8 +62,9 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
appBar: AppBar(
title: const Text('应用图标'),
),
@@ -82,22 +80,21 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
itemBuilder: (context, index) {
final icon = _icons[index];
final isSelected = _currentIconName == icon['name'];
return GestureDetector(
onTap: () => _selectIcon(icon['name']!),
child: Container(
decoration: BoxDecoration(
color: isSelected ? const Color(0xFFF0F0F0) : const Color(0xFFFAFAFA),
color: isSelected ? colors.outlineVariant : colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: isSelected ? const Color(0xFF1A1A1A) : const Color(0xFFE8E8E8),
color: isSelected ? colors.primary : colors.outlineVariant,
width: isSelected ? 2 : 1,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// 图标预览
Image.asset(
'assets/icon/${icon['name']}.png',
width: 64,
@@ -107,26 +104,25 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
width: 64,
height: 64,
decoration: BoxDecoration(
color: const Color(0xFFEEEEEE),
color: colors.outlineVariant,
borderRadius: BorderRadius.circular(12),
),
child: const Icon(Icons.image_not_supported, color: Color(0xFF999999)),
child: Icon(Icons.image_not_supported, color: colors.onSurface.withValues(alpha: 0.4)),
);
},
),
const SizedBox(height: 12),
// 标签
Text(
icon['label']!,
style: TextStyle(
fontSize: 14,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
color: const Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
if (isSelected) ...[
const SizedBox(height: 4),
const Icon(Icons.check_circle, size: 18, color: Color(0xFF1A1A1A)),
Icon(Icons.check_circle, size: 18, color: colors.primary),
],
],
),