加入新图标,优化通知栏,统计界面加入标签词云

This commit is contained in:
DelLevin-Home
2026-05-26 21:24:14 +08:00
parent 73f3795e65
commit daf66bd737
17 changed files with 766 additions and 403 deletions

View File

@@ -18,6 +18,7 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
final List<Map<String, String>> _icons = [
{'name': 'app_icon', 'label': '默认图标'},
{'name': 'app_icon2', 'label': '风格二'},
{'name': 'app_icon_m', 'label': '风格三'},
];
@override
@@ -28,35 +29,22 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
Future<void> _loadCurrentIcon() async {
final nativeIcon = await AppIconChannel.getCurrentIcon();
setState(() {
_currentIconName = nativeIcon;
});
setState(() => _currentIconName = nativeIcon);
}
Future<void> _selectIcon(String iconName) async {
if (iconName == _currentIconName) return;
try {
final success = await AppIconChannel.switchIcon(iconName);
if (success) {
await _userPrefs.setAppIconName(iconName);
setState(() {
_currentIconName = iconName;
});
if (mounted) {
ToastUtil.show(context, '图标已切换,请返回桌面查看');
}
setState(() => _currentIconName = iconName);
if (mounted) ToastUtil.show(context, '图标已切换,请返回桌面查看');
} else {
if (mounted) {
ToastUtil.show(context, '图标切换失败');
}
if (mounted) ToastUtil.show(context, '图标切换失败');
}
} catch (e) {
if (mounted) {
ToastUtil.show(context, '切换出错: $e');
}
if (mounted) ToastUtil.show(context, '切换出错: $e');
}
}
@@ -64,66 +52,68 @@ class _AppIconPickerPageState extends State<AppIconPickerPage> {
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: colors.surface,
backgroundColor: colors.surfaceContainerHigh,
appBar: AppBar(
title: const Text('应用图标'),
),
body: GridView.builder(
padding: const EdgeInsets.all(24),
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 0.85,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
),
body: ListView.builder(
padding: const EdgeInsets.symmetric(vertical: 12),
itemCount: _icons.length,
itemBuilder: (context, index) {
final icon = _icons[index];
final isSelected = _currentIconName == icon['name'];
return GestureDetector(
return InkWell(
onTap: () => _selectIcon(icon['name']!),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: isSelected ? colors.outlineVariant : colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(16),
color: colors.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: isSelected ? colors.primary : colors.outlineVariant,
width: isSelected ? 2 : 1,
color: isSelected ? colors.primary : Colors.transparent,
width: isSelected ? 2 : 0,
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
child: Row(
children: [
Image.asset(
'assets/icon/${icon['name']}.png',
Container(
width: 64,
height: 64,
errorBuilder: (context, error, stackTrace) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(14),
border: Border.all(color: colors.outlineVariant, width: 0.5),
),
clipBehavior: Clip.antiAlias,
child: Image.asset(
'assets/icon/${icon['name']}.png',
width: 64,
height: 64,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => Container(
width: 64,
height: 64,
decoration: BoxDecoration(
color: colors.outlineVariant,
borderRadius: BorderRadius.circular(12),
),
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: colors.onSurface,
color: colors.surfaceContainerHighest,
child: Icon(Icons.image_not_supported, size: 24, color: colors.onSurface.withValues(alpha: 0.3)),
),
),
),
if (isSelected) ...[
const SizedBox(height: 4),
Icon(Icons.check_circle, size: 18, color: colors.primary),
],
const SizedBox(width: 16),
Expanded(
child: Text(
icon['label']!,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: colors.onSurface,
),
),
),
if (isSelected)
Icon(Icons.check_circle, size: 22, color: colors.primary)
else
Icon(Icons.radio_button_unchecked, size: 22, color: colors.onSurface.withValues(alpha: 0.2)),
],
),
),