深色模式、首页设置页面和功能优化
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
|
||||
/// 时间: 2026-03-27
|
||||
/// 功能: 桌面小卡片设置页面
|
||||
@@ -12,6 +14,7 @@ class WidgetsPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WidgetsPageState extends State<WidgetsPage> {
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
bool _enableWidget = true;
|
||||
bool _showWeather = true;
|
||||
bool _showQuote = true;
|
||||
@@ -22,79 +25,88 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFFF5F5F5),
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'桌面卡片设置',
|
||||
style: TextStyle(
|
||||
color: AppConstants.primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
return Obx(() {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
return Scaffold(
|
||||
backgroundColor: isDark
|
||||
? const Color(0xFF1A1A1A)
|
||||
: const Color(0xFFF5F5F5),
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'桌面卡片设置',
|
||||
style: TextStyle(
|
||||
color: AppConstants.primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_buildSettingsGroup('卡片状态', [
|
||||
_buildSwitchItem(
|
||||
'启用桌面卡片',
|
||||
'在桌面上显示诗词卡片',
|
||||
Icons.widgets,
|
||||
_enableWidget,
|
||||
(value) => setState(() => _enableWidget = value),
|
||||
isDark,
|
||||
),
|
||||
], isDark),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup('显示内容', [
|
||||
_buildSwitchItem(
|
||||
'显示天气',
|
||||
'在卡片上显示当前天气',
|
||||
Icons.cloud,
|
||||
_showWeather,
|
||||
(value) => setState(() => _showWeather = value),
|
||||
isDark,
|
||||
),
|
||||
_buildSwitchItem(
|
||||
'显示诗句',
|
||||
'在卡片上显示随机诗句',
|
||||
Icons.edit_document,
|
||||
_showQuote,
|
||||
(value) => setState(() => _showQuote = value),
|
||||
isDark,
|
||||
),
|
||||
_buildSwitchItem(
|
||||
'显示时间',
|
||||
'在卡片上显示当前时间',
|
||||
Icons.access_time,
|
||||
_showTime,
|
||||
(value) => setState(() => _showTime = value),
|
||||
isDark,
|
||||
),
|
||||
], isDark),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup('更新设置', [_buildIntervalItem(isDark)], isDark),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup('预览', [_buildPreviewCard(isDark)], isDark),
|
||||
const SizedBox(height: 32),
|
||||
_buildActionButton(isDark),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
_buildSettingsGroup('卡片状态', [
|
||||
_buildSwitchItem(
|
||||
'启用桌面卡片',
|
||||
'在桌面上显示诗词卡片',
|
||||
Icons.widgets,
|
||||
_enableWidget,
|
||||
(value) => setState(() => _enableWidget = value),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup('显示内容', [
|
||||
_buildSwitchItem(
|
||||
'显示天气',
|
||||
'在卡片上显示当前天气',
|
||||
Icons.cloud,
|
||||
_showWeather,
|
||||
(value) => setState(() => _showWeather = value),
|
||||
),
|
||||
_buildSwitchItem(
|
||||
'显示诗句',
|
||||
'在卡片上显示随机诗句',
|
||||
Icons.edit_document,
|
||||
_showQuote,
|
||||
(value) => setState(() => _showQuote = value),
|
||||
),
|
||||
_buildSwitchItem(
|
||||
'显示时间',
|
||||
'在卡片上显示当前时间',
|
||||
Icons.access_time,
|
||||
_showTime,
|
||||
(value) => setState(() => _showTime = value),
|
||||
),
|
||||
]),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup('更新设置', [_buildIntervalItem()]),
|
||||
const SizedBox(height: 16),
|
||||
_buildSettingsGroup('预览', [_buildPreviewCard()]),
|
||||
const SizedBox(height: 32),
|
||||
_buildActionButton(),
|
||||
],
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildSettingsGroup(String title, List<Widget> items) {
|
||||
Widget _buildSettingsGroup(String title, List<Widget> items, bool isDark) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withAlpha(5),
|
||||
color: Colors.black.withAlpha(isDark ? 30 : 5),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
@@ -126,6 +138,7 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
IconData icon,
|
||||
bool value,
|
||||
ValueChanged<bool> onChanged,
|
||||
bool isDark,
|
||||
) {
|
||||
return ListTile(
|
||||
leading: Container(
|
||||
@@ -138,11 +151,18 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
),
|
||||
title: Text(
|
||||
title,
|
||||
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
subtitle,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
trailing: Switch(
|
||||
value: value,
|
||||
@@ -152,7 +172,7 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIntervalItem() {
|
||||
Widget _buildIntervalItem(bool isDark) {
|
||||
return ListTile(
|
||||
leading: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
@@ -162,13 +182,20 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
),
|
||||
child: Icon(Icons.refresh, color: AppConstants.primaryColor, size: 20),
|
||||
),
|
||||
title: const Text(
|
||||
title: Text(
|
||||
'更新间隔',
|
||||
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isDark ? Colors.white : Colors.black,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
'每 $_updateInterval 分钟更新一次',
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: isDark ? Colors.grey[400] : Colors.grey[600],
|
||||
),
|
||||
),
|
||||
trailing: SizedBox(
|
||||
width: 150,
|
||||
@@ -188,13 +215,13 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return AppConstants.primaryColor;
|
||||
}
|
||||
return Colors.grey[200];
|
||||
return isDark ? Colors.grey[700] : Colors.grey[200];
|
||||
}),
|
||||
foregroundColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return Colors.white;
|
||||
}
|
||||
return Colors.black87;
|
||||
return isDark ? Colors.white : Colors.black87;
|
||||
}),
|
||||
),
|
||||
),
|
||||
@@ -202,7 +229,7 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPreviewCard() {
|
||||
Widget _buildPreviewCard(bool isDark) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -275,7 +302,7 @@ class _WidgetsPageState extends State<WidgetsPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildActionButton() {
|
||||
Widget _buildActionButton(bool isDark) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
|
||||
Reference in New Issue
Block a user