深色模式、首页设置页面和功能优化

This commit is contained in:
Developer
2026-04-02 07:06:55 +08:00
parent f0a62ed68b
commit 954d173329
88 changed files with 12157 additions and 7578 deletions

View File

@@ -1,10 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../constants/app_constants.dart';
import '../../../services/get/theme_controller.dart';
import '../../../services/get/tap_liquid_glass_controller.dart';
import '../../../utils/audio_manager.dart';
import './widgets.dart';
import '../../home/home-load.dart';
import '../../home/set/home-load.dart';
import '../../../controllers/load/locally.dart';
/// 时间: 2026-03-26
@@ -20,6 +23,10 @@ class AppFunSettingsPage extends StatefulWidget {
}
class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
final ThemeController _themeController = Get.find<ThemeController>();
final TapLiquidGlassController _glassController = Get.put(
TapLiquidGlassController(),
);
bool _autoRefreshEnabled = false;
bool _debugInfoEnabled = false;
bool _soundEnabled = false; // 默认关闭
@@ -30,7 +37,6 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
static const String _autoRefreshKey = 'auto_refresh_enabled';
static const String _debugInfoKey = 'debug_info_enabled';
static const String _globalTipsKey = 'global_tips_enabled'; // 添加全局Tips开关key
static const String _soundEnabledKey = 'sound_enabled'; // 声音反馈开关key
static const String _hideSecondaryButtonsKey =
'hide_secondary_buttons'; // 隐藏次要按钮key
@@ -43,12 +49,13 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
Future<void> _loadSettings() async {
final prefs = await SharedPreferences.getInstance();
await GlobalTipsManager().init();
if (mounted) {
setState(() {
_autoRefreshEnabled = prefs.getBool(_autoRefreshKey) ?? false;
_debugInfoEnabled = prefs.getBool(_debugInfoKey) ?? false;
_globalTipsEnabled =
prefs.getBool(_globalTipsKey) ?? true; // 加载全局Tips开关状态
GlobalTipsManager().isEnabled; // 从 GlobalTipsManager 加载状态
_preloadEnabled = prefs.getBool('preload_enabled') ?? true;
_soundEnabled = prefs.getBool(_soundEnabledKey) ?? false; // 加载声音反馈状态
_hideSecondaryButtons =
@@ -160,141 +167,154 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(
title: Text(
'功能设置',
style: TextStyle(
color: AppConstants.primaryColor,
fontWeight: FontWeight.bold,
),
),
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(
'自动刷新',
'首页诗句自动刷新5s ',
Icons.refresh,
_autoRefreshEnabled,
_setAutoRefresh,
),
_buildSwitchItem(
'调式信息',
'开启后可加载更多信息',
Icons.bug_report,
_debugInfoEnabled,
_setDebugInfo,
),
_buildSwitchItem(
'预加载',
_preloadEnabled
? '开启后 部分数据优先使用本地缓存,减少与服务器的通信次数'
: '关闭后,优先使用云端数据,无延迟,但刷新缓慢',
Icons.storage,
_preloadEnabled,
_setPreload,
),
]),
const SizedBox(height: 16),
_buildSettingsGroup('主页显示设置', [
_buildDevelopmentItem(
'Tap沉浸光感',
'开启后底栏显示类iOS26 风格',
Icons.dark_mode,
),
_buildSwitchItem(
'隐藏次要按钮',
'开启后隐藏上一条和分享按钮',
Icons.share,
_hideSecondaryButtons,
_setHideSecondaryButtons,
),
_buildFontSliderItem(),
]),
const SizedBox(height: 16),
_buildSettingsGroup('交互反馈', [
_buildSwitchItem(
'全局Tips开关',
'显示一些使用技巧',
Icons.volume_up,
_globalTipsEnabled,
(value) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_globalTipsKey, value);
if (mounted) {
setState(() {
_globalTipsEnabled = value;
});
}
},
),
_buildSwitchItem(
'声音反馈',
'操作时播放提示音',
Icons.volume_up,
_soundEnabled,
_setSoundEnabled,
),
_buildSwitchItem(
'震动反馈',
'操作时震动提示',
Icons.vibration,
_vibrationEnabled,
(value) => _setVibrationEnabled(value),
),
]),
const SizedBox(height: 16),
_buildSettingsGroup('高级设置', [
// _buildActionItem(
// 'Beta开关 关闭软件',
// '开发者选项',
// Icons.developer_mode,
// () => _showSnackBar('调试模式开发中'),
// ),
_buildActionItem(
'重置设置',
'恢复默认设置',
Icons.restore,
() => _showResetDialog(),
),
// _buildActionItem(
// '调试模式',
// '开发者选项',
// Icons.developer_mode,
// () => _showSnackBar('调试模式开发中'),
// ),
]),
const SizedBox(height: 32),
_buildVersionInfo(),
],
),
);
// 设置Tap沉浸光感导航栏
Future<void> _setTapLiquidGlass(bool value) async {
await _glassController.toggleEnabled(value);
}
Widget _buildSettingsGroup(String title, List<Widget> items) {
@override
Widget build(BuildContext context) {
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(),
),
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildSettingsGroup('基础功能', [
_buildSwitchItem(
'自动刷新',
'首页诗句自动刷新5s ',
Icons.refresh,
_autoRefreshEnabled,
_setAutoRefresh,
isDark,
),
_buildSwitchItem(
'调式信息',
'开启后可加载更多信息',
Icons.bug_report,
_debugInfoEnabled,
_setDebugInfo,
isDark,
),
_buildSwitchItem(
'预加载',
_preloadEnabled
? '开启后 部分数据优先使用本地缓存,减少与服务器的通信次数'
: '关闭后,优先使用云端数据,无延迟,但刷新缓慢',
Icons.storage,
_preloadEnabled,
_setPreload,
isDark,
),
], isDark),
const SizedBox(height: 16),
_buildSettingsGroup('主页显示设置', [
Obx(
() => _buildSwitchItem(
'Tap沉浸光感',
'开启后底栏显示类iOS26 风格',
Icons.dark_mode,
_glassController.isEnabled,
_setTapLiquidGlass,
isDark,
),
),
Obx(() {
if (!_glassController.isEnabled) return const SizedBox.shrink();
return _buildTransparencyLevelItem(isDark);
}),
_buildSwitchItem(
'隐藏次要按钮',
'开启后隐藏上一条和分享按钮',
Icons.share,
_hideSecondaryButtons,
_setHideSecondaryButtons,
isDark,
),
_buildFontSliderItem(isDark),
], isDark),
const SizedBox(height: 16),
_buildSettingsGroup('交互反馈', [
_buildSwitchItem(
'全局Tips开关',
'显示一些使用技巧',
Icons.volume_up,
_globalTipsEnabled,
(value) async {
await GlobalTipsManager().setEnabled(value);
if (mounted) {
setState(() {
_globalTipsEnabled = value;
});
}
},
isDark,
),
_buildSwitchItem(
'声音反馈',
'操作时播放提示音',
Icons.volume_up,
_soundEnabled,
_setSoundEnabled,
isDark,
),
_buildSwitchItem(
'震动反馈',
'操作时震动提示',
Icons.vibration,
_vibrationEnabled,
(value) => _setVibrationEnabled(value),
isDark,
),
], isDark),
const SizedBox(height: 16),
_buildSettingsGroup('高级设置', [
_buildActionItem(
'重置设置',
'恢复默认设置',
Icons.restore,
() => _showResetDialog(),
isDark,
),
], isDark),
const SizedBox(height: 32),
_buildVersionInfo(isDark),
],
),
);
});
}
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.withValues(alpha: 0.05),
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -326,6 +346,7 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
IconData icon,
bool value,
ValueChanged<bool> onChanged,
bool isDark,
) {
return ListTile(
leading: Container(
@@ -338,11 +359,18 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
),
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,
@@ -352,7 +380,7 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
);
}
Widget _buildFontSliderItem() {
Widget _buildFontSliderItem(bool isDark) {
return ListTile(
leading: Container(
padding: const EdgeInsets.all(8),
@@ -362,43 +390,81 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
),
child: Icon(Icons.widgets, 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(
'使用帮助',
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
trailing: Icon(
Icons.chevron_right,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
trailing: Icon(Icons.chevron_right, color: Colors.grey[400]),
onTap: () {
// 显示对话框提示鸿蒙设备设置方法
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
title: Row(
children: [
Icon(Icons.info_outline, color: AppConstants.primaryColor),
const SizedBox(width: 8),
const Text('桌面卡片设置'),
Text(
'桌面卡片设置',
style: TextStyle(
color: isDark ? Colors.white : Colors.black,
),
),
],
),
content: const Column(
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'鸿蒙设备请在桌面端设置:',
style: TextStyle(fontWeight: FontWeight.bold),
style: TextStyle(
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
SizedBox(height: 8),
Text('1. 长按桌面空白处'),
Text('2. 选择「情景诗词」卡片'),
Text('3. 添加后点击桌面卡片即可设置'),
Text('4. 后续版本支持在应用内设置卡片'),
SizedBox(height: 12),
const SizedBox(height: 8),
Text(
'1. 长按桌面空白处',
style: TextStyle(
color: isDark ? Colors.grey[300] : Colors.black,
),
),
Text(
'2. 选择「情景诗词」卡片',
style: TextStyle(
color: isDark ? Colors.grey[300] : Colors.black,
),
),
Text(
'3. 添加后点击桌面卡片即可设置',
style: TextStyle(
color: isDark ? Colors.grey[300] : Colors.black,
),
),
Text(
'4. 后续版本支持在应用内设置卡片',
style: TextStyle(
color: isDark ? Colors.grey[300] : Colors.black,
),
),
const SizedBox(height: 12),
const Text(
'注意:该页面设置对鸿蒙设备不生效',
style: TextStyle(color: Colors.orange, fontSize: 12),
),
@@ -408,7 +474,6 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
TextButton(
onPressed: () {
Navigator.of(context).pop();
// 返回桌面
SystemNavigator.pop();
},
child: const Text('前往桌面'),
@@ -437,11 +502,116 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
);
}
Widget _buildTransparencyLevelItem(bool isDark) {
return Obx(() {
final currentIndex = _glassController.transparencyLevelIndex;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
child: Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppConstants.primaryColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.opacity,
color: AppConstants.primaryColor,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'高透级别',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: isDark ? Colors.white : Colors.black,
),
),
Text(
'当前: ${_glassController.transparencyLevelLabel}',
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
child: Row(
children: [
_buildLevelButton('', 0, currentIndex == 0, isDark),
const SizedBox(width: 8),
_buildLevelButton('', 1, currentIndex == 1, isDark),
const SizedBox(width: 8),
_buildLevelButton('', 2, currentIndex == 2, isDark),
],
),
),
],
);
});
}
Widget _buildLevelButton(
String label,
int levelIndex,
bool isSelected,
bool isDark,
) {
return Expanded(
child: GestureDetector(
onTap: () => _glassController.setTransparencyLevelByIndex(levelIndex),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 10),
decoration: BoxDecoration(
color: isSelected
? AppConstants.primaryColor
: (isDark ? Colors.grey[800] : Colors.grey[200]),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isSelected
? AppConstants.primaryColor
: (isDark ? Colors.grey[700]! : Colors.grey[300]!),
width: 1.5,
),
),
child: Text(
label,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: isSelected
? Colors.white
: (isDark ? Colors.grey[300] : Colors.grey[700]),
),
),
),
),
);
}
Widget _buildActionItem(
String title,
String subtitle,
IconData icon,
VoidCallback onTap,
bool isDark,
) {
return ListTile(
leading: Container(
@@ -454,66 +624,36 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
),
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: Icon(
Icons.chevron_right,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
trailing: Icon(Icons.chevron_right, color: Colors.grey[400]),
onTap: onTap,
);
}
Widget _buildDevelopmentItem(String title, String subtitle, IconData icon) {
return ListTile(
leading: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.grey.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(icon, color: Colors.grey, size: 20),
),
title: Text(
title,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w500,
color: Colors.grey[600],
),
),
subtitle: Text(
subtitle,
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
),
trailing: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: Colors.grey.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(12),
),
child: Text(
'开发中',
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],
fontWeight: FontWeight.w500,
),
),
),
);
}
Widget _buildVersionInfo() {
Widget _buildVersionInfo(bool isDark) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -529,12 +669,19 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
const SizedBox(height: 12),
Text(
AppConstants.appName,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(height: 4),
Text(
'版本 ${AppConstants.appVersion}',
style: TextStyle(fontSize: 13, color: Colors.grey[600]),
style: TextStyle(
fontSize: 13,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
@@ -567,9 +714,9 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
await _setPreload(true); // 预加载:开启
await _setHideSecondaryButtons(false); // 隐藏次要按钮:关闭
await _setSoundEnabled(false); // 声音反馈:关闭
await _setTapLiquidGlass(true); // Tap沉浸光感开启
// 全局Tips开启
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_globalTipsKey, true);
await GlobalTipsManager().setEnabled(true);
// 震动反馈开启不需要保存到SharedPreferences直接更新状态
setState(() {
_vibrationEnabled = true;
@@ -590,4 +737,5 @@ class _AppFunSettingsPageState extends State<AppFunSettingsPage> {
// - 隐藏次要按钮:关闭
// - 声音反馈:关闭
// - 震动反馈:开启
// - Tips
// - 全局Tips开启
// - tap

View File

@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../../../config/app_config.dart';
import '../../../constants/app_constants.dart';
import '../../../services/get/theme_controller.dart';
/// 时间: 2026-03-26
/// 功能: 了解我们页面
@@ -13,51 +15,58 @@ class LearnUsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(
title: Text(
'了解我们',
style: TextStyle(
color: AppConstants.primaryColor,
fontWeight: FontWeight.bold,
final themeController = Get.find<ThemeController>();
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: [
_buildHeaderCard(),
const SizedBox(height: 16),
_buildOfficialSiteCard(isDark),
const SizedBox(height: 16),
_buildQQGroupCard(context, isDark),
const SizedBox(height: 16),
_buildDeveloperCard(context, isDark),
const SizedBox(height: 16),
_buildTeamCard(isDark),
const SizedBox(height: 16),
_buildIcpCard(context, isDark),
const SizedBox(height: 24),
_buildBottomIndicator(isDark),
],
),
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildHeaderCard(),
const SizedBox(height: 16),
_buildOfficialSiteCard(),
const SizedBox(height: 16),
_buildQQGroupCard(context),
const SizedBox(height: 16),
_buildDeveloperCard(context),
const SizedBox(height: 16),
_buildTeamCard(),
const SizedBox(height: 16),
_buildIcpCard(context),
const SizedBox(height: 24),
_buildBottomIndicator(),
],
),
);
);
});
}
Widget _buildHeaderCard() {
return Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: const [
gradient: const LinearGradient(
colors: [
Color.fromARGB(255, 143, 73, 228),
Color(0xFF6200EE),
Color(0xFF3700B3),
@@ -145,14 +154,16 @@ class LearnUsPage extends StatelessWidget {
);
}
Widget _buildOfficialSiteCard() {
Widget _buildOfficialSiteCard(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.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.3)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -178,32 +189,41 @@ class LearnUsPage extends StatelessWidget {
),
),
const SizedBox(width: 12),
const Text(
Text(
'官方网站',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
),
const Divider(height: 1),
Divider(height: 1, color: isDark ? Colors.grey[800] : null),
Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
Text(
'访问我们的官方网站了解更多信息',
style: TextStyle(fontSize: 13, color: Colors.grey),
style: TextStyle(
fontSize: 13,
color: isDark ? Colors.grey[400] : Colors.grey,
),
),
const SizedBox(height: 12),
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey[50],
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[50],
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.grey.withValues(alpha: 0.2),
color: isDark
? Colors.grey[700]!.withValues(alpha: 0.2)
: Colors.grey.withValues(alpha: 0.2),
),
),
child: Row(
@@ -234,14 +254,16 @@ class LearnUsPage extends StatelessWidget {
);
}
Widget _buildQQGroupCard(BuildContext context) {
Widget _buildQQGroupCard(BuildContext context, 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.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.3)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -263,22 +285,29 @@ class LearnUsPage extends StatelessWidget {
child: Icon(Icons.group, color: Colors.blue[700], size: 20),
),
const SizedBox(width: 12),
const Text(
Text(
'QQ交流群',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
),
const Divider(height: 1),
Divider(height: 1, color: isDark ? Colors.grey[800] : null),
Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
Text(
'加入我们的QQ交流群与其他诗词爱好者一起交流',
style: TextStyle(fontSize: 13, color: Colors.grey),
style: TextStyle(
fontSize: 13,
color: isDark ? Colors.grey[400] : Colors.grey,
),
),
const SizedBox(height: 12),
InkWell(
@@ -288,7 +317,7 @@ class LearnUsPage extends StatelessWidget {
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey[50],
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[50],
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: AppConstants.primaryColor.withValues(alpha: 0.3),
@@ -318,7 +347,10 @@ class LearnUsPage extends StatelessWidget {
const SizedBox(height: 8),
Text(
'💡 点击群号可复制',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
),
],
),
@@ -348,14 +380,16 @@ class LearnUsPage extends StatelessWidget {
);
}
Widget _buildDeveloperCard(BuildContext context) {
Widget _buildDeveloperCard(BuildContext context, 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.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.3)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -381,14 +415,18 @@ class LearnUsPage extends StatelessWidget {
),
),
const SizedBox(width: 12),
const Text(
Text(
'开发者',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
),
const Divider(height: 1),
Divider(height: 1, color: isDark ? Colors.grey[800] : null),
Padding(
padding: const EdgeInsets.all(16),
child: Row(
@@ -414,17 +452,21 @@ class LearnUsPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
Text(
'微风暴工作室',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(height: 4),
Text(
'专注文字文化领域',
style: TextStyle(fontSize: 13, color: Colors.grey[600]),
style: TextStyle(
fontSize: 13,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
@@ -457,11 +499,12 @@ class LearnUsPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
Text(
'商务合作&侵权申诉&联系我们',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(height: 2),
@@ -504,11 +547,12 @@ class LearnUsPage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
Text(
'微信公众号',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(height: 4),
@@ -573,14 +617,16 @@ class LearnUsPage extends StatelessWidget {
);
}
Widget _buildTeamCard() {
Widget _buildTeamCard(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.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.3)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -602,17 +648,27 @@ class LearnUsPage extends StatelessWidget {
child: Icon(Icons.group, color: Colors.purple[700], size: 20),
),
const SizedBox(width: 12),
const Text(
Text(
'团队信息(Team)',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
),
_buildTeamMember('💻', '程序设计', '无书的书🤡', '尽毕生所学,取天下之诗集,只为逗她一笑'),
_buildTeamMember('🎨', 'UI/UX/Testing', 'Ayk', '....'),
_buildTeamMember('⚙️', '后端', '伯乐不相马', '真的吗,还是做不到吗?'),
_buildTeamMember('🔧', '技术支持', '闲言app', '闲言app原班人马打造'),
_buildTeamMember(
'💻',
'程序设计',
'无书的书🤡',
'尽毕生所学,取天下之诗集,只为逗她一笑',
isDark,
),
_buildTeamMember('🎨', 'UI/UX/Testing', 'Ayk', '....', isDark),
_buildTeamMember('⚙️', '后端', '伯乐不相马', '真的吗,还是做不到吗?', isDark),
_buildTeamMember('🔧', '技术支持', '闲言app', '闲言app原班人马打造', isDark),
],
),
);
@@ -623,6 +679,7 @@ class LearnUsPage extends StatelessWidget {
String role,
String name,
String signature,
bool isDark,
) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
@@ -632,7 +689,7 @@ class LearnUsPage extends StatelessWidget {
width: 44,
height: 44,
decoration: BoxDecoration(
color: Colors.grey[100],
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[100],
borderRadius: BorderRadius.circular(10),
),
child: Center(
@@ -648,9 +705,10 @@ class LearnUsPage extends StatelessWidget {
children: [
Text(
role,
style: const TextStyle(
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(width: 8),
@@ -676,7 +734,10 @@ class LearnUsPage extends StatelessWidget {
const SizedBox(height: 4),
Text(
signature,
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
@@ -686,14 +747,16 @@ class LearnUsPage extends StatelessWidget {
);
}
Widget _buildIcpCard(BuildContext context) {
Widget _buildIcpCard(BuildContext context, 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.withValues(alpha: 0.05),
color: isDark
? Colors.black.withValues(alpha: 0.3)
: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -713,68 +776,43 @@ class LearnUsPage extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.verified_user,
Icons.verified,
color: Colors.orange[700],
size: 20,
),
),
const SizedBox(width: 12),
const Text(
'ICP备案信息',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
Text(
'备案信息',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
),
const Divider(height: 1),
Divider(height: 1, color: isDark ? Colors.grey[800] : null),
Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'APP核准备案号',
style: TextStyle(fontSize: 13, color: Colors.grey),
),
const SizedBox(height: 12),
InkWell(
onTap: () => _copyIcpNumber(context),
borderRadius: BorderRadius.circular(8),
child: Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey[50],
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: AppConstants.primaryColor.withValues(alpha: 0.3),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.content_copy,
size: 16,
color: AppConstants.primaryColor,
),
const SizedBox(width: 8),
Text(
'滇ICP备2022000863号-15A',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: AppConstants.primaryColor,
),
),
],
),
Text(
'滇ICP备2025002147号-2A',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
const SizedBox(height: 8),
const SizedBox(height: 4),
Text(
'💡 点击备案号可复制',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
'弥勒市朋普镇微风暴网络科技工作室',
style: TextStyle(
fontSize: 13,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
@@ -784,41 +822,32 @@ class LearnUsPage extends StatelessWidget {
);
}
void _copyIcpNumber(BuildContext context) {
Clipboard.setData(const ClipboardData(text: '滇ICP备2022000863号-15A'));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Row(
children: [
Icon(Icons.check_circle, color: Colors.white, size: 20),
SizedBox(width: 8),
Text('备案号已复制到剪贴板'),
],
),
backgroundColor: AppConstants.primaryColor,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
duration: const Duration(seconds: 2),
),
);
}
Widget _buildBottomIndicator() {
Widget _buildBottomIndicator(bool isDark) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'到底了',
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
),
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
],
),
);

View File

@@ -1,8 +1,10 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../constants/app_constants.dart';
import '../../../services/get/theme_controller.dart';
import '../../../utils/http/http_client.dart';
import 'user-plan.dart';
import '../components/server_info_dialog.dart';
@@ -25,6 +27,7 @@ enum DownloadType {
}
class _OfflineDataPageState extends State<OfflineDataPage> {
final ThemeController _themeController = Get.find<ThemeController>();
DownloadType _selectedType = DownloadType.poetry;
int _selectedCount = 30;
bool _isLoading = false;
@@ -510,262 +513,109 @@ class _OfflineDataPageState extends State<OfflineDataPage> {
@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(),
),
actions: [
IconButton(
icon: Icon(
Icons.cloud_outlined,
color: AppConstants.primaryColor,
),
onPressed: _showServerInfo,
tooltip: '服务器信息',
),
],
),
backgroundColor: Colors.white,
elevation: 0,
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
onPressed: () => Navigator.of(context).pop(),
),
actions: [
IconButton(
icon: Icon(Icons.cloud_outlined, color: AppConstants.primaryColor),
onPressed: _showServerInfo,
tooltip: '服务器信息',
),
],
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
// 缓存状态卡片
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
children: [
Row(
children: [
Icon(
Icons.download_done,
color: AppConstants.primaryColor,
size: 24,
),
const SizedBox(width: 12),
const Text(
'缓存状态',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'精选诗句: $_poetryCount',
style: const TextStyle(fontSize: 14, color: Colors.grey),
),
const SizedBox(height: 8),
Text(
'答题挑战: $_quizCount',
style: const TextStyle(fontSize: 14, color: Colors.grey),
),
],
),
],
),
),
const SizedBox(height: 20),
// 下载类型选择
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.category,
color: AppConstants.primaryColor,
size: 20,
),
const SizedBox(width: 8),
const Text(
'下载类型',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildTypeOption(DownloadType.poetry, '精选诗句'),
_buildTypeOption(DownloadType.quiz, '答题挑战'),
],
),
],
),
),
const SizedBox(height: 20),
// 下载数量选择
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.settings,
color: AppConstants.primaryColor,
size: 20,
),
const SizedBox(width: 8),
const Text(
'下载数量',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: _selectedType == DownloadType.poetry
? [
_buildCountOption(20),
_buildCountOption(30),
_buildCountOption(60),
_buildCountOption(100),
]
: [
_buildCountOption(20),
_buildCountOption(50),
_buildCountOption(80),
_buildCountOption(100),
],
),
],
),
),
const SizedBox(height: 20),
// 下载/取消按钮
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: _isLoading
? (_isCancelling ? null : _cancelDownload)
: _downloadOfflineData,
style: ElevatedButton.styleFrom(
backgroundColor: _isCancelling
? Colors.red
: AppConstants.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: _isCancelling
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
)
: Text(
_isLoading ? '取消下载' : '开始下载',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
const SizedBox(height: 16),
// 清空按钮
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: _clearOfflineData,
style: OutlinedButton.styleFrom(
foregroundColor: Colors.red,
side: const BorderSide(color: Colors.red),
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Text(
'清空缓存',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
),
),
),
const SizedBox(height: 20),
// 进度条
if (_isLoading) ...[
body: ListView(
padding: const EdgeInsets.all(16),
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
children: [
Row(
children: [
Icon(
Icons.download_done,
color: AppConstants.primaryColor,
size: 24,
),
const SizedBox(width: 12),
Text(
'缓存状态',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
const SizedBox(height: 16),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'精选诗句: $_poetryCount',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[400] : Colors.grey,
),
),
const SizedBox(height: 8),
Text(
'答题挑战: $_quizCount',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[400] : Colors.grey,
),
),
],
),
],
),
),
const SizedBox(height: 20),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -774,145 +624,351 @@ class _OfflineDataPageState extends State<OfflineDataPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_status,
style: const TextStyle(fontSize: 14, color: Colors.grey),
Row(
children: [
Icon(
Icons.category,
color: AppConstants.primaryColor,
size: 20,
),
const SizedBox(width: 8),
Text(
'下载类型',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildTypeOption(DownloadType.poetry, '精选诗句', isDark),
_buildTypeOption(DownloadType.quiz, '答题挑战', isDark),
],
),
],
),
),
const SizedBox(height: 20),
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.settings,
color: AppConstants.primaryColor,
size: 20,
),
const SizedBox(width: 8),
Text(
'下载数量',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: _selectedType == DownloadType.poetry
? [
_buildCountOption(20, isDark),
_buildCountOption(30, isDark),
_buildCountOption(60, isDark),
_buildCountOption(100, isDark),
]
: [
_buildCountOption(20, isDark),
_buildCountOption(50, isDark),
_buildCountOption(80, isDark),
_buildCountOption(100, isDark),
],
),
],
),
),
const SizedBox(height: 20),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: _isLoading
? (_isCancelling ? null : _cancelDownload)
: _downloadOfflineData,
style: ElevatedButton.styleFrom(
backgroundColor: _isCancelling
? Colors.red
: AppConstants.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: _isCancelling
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white,
),
),
)
: Text(
_isLoading ? '取消下载' : '开始下载',
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
),
const SizedBox(height: 16),
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: _clearOfflineData,
style: OutlinedButton.styleFrom(
foregroundColor: Colors.red,
side: const BorderSide(color: Colors.red),
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Text(
'清空缓存',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
),
),
),
const SizedBox(height: 20),
if (_isLoading) ...[
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(
alpha: isDark ? 0.3 : 0.05,
),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_status,
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[400] : Colors.grey,
),
),
const SizedBox(height: 12),
LinearProgressIndicator(
value: _progress / 100,
backgroundColor: isDark
? Colors.grey[700]
: Colors.grey[200],
valueColor: AlwaysStoppedAnimation<Color>(
AppConstants.primaryColor,
),
borderRadius: BorderRadius.circular(10),
),
const SizedBox(height: 8),
Align(
alignment: Alignment.centerRight,
child: Text(
'$_progress%',
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey,
),
),
),
],
),
),
],
const SizedBox(height: 20),
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: isDark
? Colors.blue.withValues(alpha: 0.15)
: Colors.blue.withValues(alpha: 0.05),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: isDark
? Colors.blue.withValues(alpha: 0.3)
: Colors.blue.withValues(alpha: 0.2),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.info_outline,
color: Colors.blue[600],
size: 20,
),
const SizedBox(width: 8),
Text(
'温馨提示',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue[600],
),
),
],
),
const SizedBox(height: 12),
LinearProgressIndicator(
value: _progress / 100,
backgroundColor: Colors.grey[200],
valueColor: AlwaysStoppedAnimation<Color>(
AppConstants.primaryColor,
),
borderRadius: BorderRadius.circular(10),
),
const SizedBox(height: 8),
Align(
alignment: Alignment.centerRight,
child: Text(
'$_progress%',
style: const TextStyle(fontSize: 12, color: Colors.grey),
Padding(
padding: const EdgeInsets.only(left: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'• 数据下载后 需手动开启离线状态',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
'方法:个人 → 下拉 点击头像下面关闭按钮 头像显示离线',
style: TextStyle(
fontSize: 13,
color: isDark
? Colors.grey[400]
: Colors.grey[600],
),
),
),
const SizedBox(height: 8),
Text(
'• 开启离线模式后,将会循环加载本地的数据源',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
const SizedBox(height: 8),
Text(
'• 下载的数据将保存在本地,可在无网络时使用',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
const SizedBox(height: 8),
Text(
'• 下载过程中请保持网络连接',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
const SizedBox(height: 8),
Text(
'• 缓存数据不会写入历史记录',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
const SizedBox(height: 8),
Text(
'• 建议在WiFi环境下下载较多数据',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
],
),
),
],
),
),
],
const SizedBox(height: 20),
// 说明信息
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.blue.withValues(alpha: 0.05),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.blue.withValues(alpha: 0.2)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(Icons.info_outline, color: Colors.blue[600], size: 20),
const SizedBox(width: 8),
Text(
'温馨提示',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue[600],
),
),
],
),
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.only(left: 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'• 数据下载后 需手动开启离线状态',
style: TextStyle(
fontSize: 14,
color: Colors.grey[700],
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 4),
Padding(
padding: const EdgeInsets.only(left: 20),
child: Text(
'方法:个人 → 下拉 点击头像下面关闭按钮 头像显示离线',
style: TextStyle(
fontSize: 13,
color: Colors.grey[600],
),
),
),
const SizedBox(height: 8),
Text(
'• 开启离线模式后,将会循环加载本地的数据源',
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
),
const SizedBox(height: 8),
Text(
'• 下载的数据将保存在本地,可在无网络时使用',
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
),
const SizedBox(height: 8),
Text(
'• 下载过程中请保持网络连接',
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
),
const SizedBox(height: 8),
Text(
'• 缓存数据不会写入历史记录',
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
),
const SizedBox(height: 8),
Text(
'• 建议在WiFi环境下下载较多数据',
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
),
],
),
),
],
),
),
],
),
);
),
);
});
}
Widget _buildTypeOption(DownloadType type, String label) {
Widget _buildTypeOption(DownloadType type, String label, bool isDark) {
final isSelected = _selectedType == type;
return GestureDetector(
onTap: () {
setState(() {
_selectedType = type;
// 重置为默认数量
_selectedCount = type == DownloadType.poetry ? 30 : 50;
});
// 重新加载缓存数量
_loadCachedCount();
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
decoration: BoxDecoration(
color: isSelected ? AppConstants.primaryColor : Colors.grey[100],
color: isSelected
? AppConstants.primaryColor
: (isDark ? Colors.grey[800] : Colors.grey[100]),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isSelected ? AppConstants.primaryColor : Colors.grey[300]!,
color: isSelected
? AppConstants.primaryColor
: (isDark ? Colors.grey[700]! : Colors.grey[300]!),
),
),
child: Text(
label,
style: TextStyle(
color: isSelected ? Colors.white : Colors.black,
color: isSelected
? Colors.white
: (isDark ? Colors.white : Colors.black),
fontSize: 14,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
@@ -921,7 +977,7 @@ class _OfflineDataPageState extends State<OfflineDataPage> {
);
}
Widget _buildCountOption(int count) {
Widget _buildCountOption(int count, bool isDark) {
final isSelected = _selectedCount == count;
return Stack(
children: [
@@ -934,25 +990,28 @@ class _OfflineDataPageState extends State<OfflineDataPage> {
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: isSelected ? AppConstants.primaryColor : Colors.grey[100],
color: isSelected
? AppConstants.primaryColor
: (isDark ? Colors.grey[800] : Colors.grey[100]),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isSelected
? AppConstants.primaryColor
: Colors.grey[300]!,
: (isDark ? Colors.grey[700]! : Colors.grey[300]!),
),
),
child: Text(
'$count条',
style: TextStyle(
color: isSelected ? Colors.white : Colors.black,
color: isSelected
? Colors.white
: (isDark ? Colors.white : Colors.black),
fontSize: 12,
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
),
),
),
),
// 为100条添加标记在卡片外面右上角
if (count == 100)
Positioned(
top: -6,

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import '../../../constants/app_constants.dart';
import '../../../services/get/theme_controller.dart';
/// 时间: 2026-03-26
/// 功能: 隐私政策与软件协议页面
@@ -9,7 +11,8 @@ import '../../../constants/app_constants.dart';
/// 公共协议内容组件 - 隐私政策
class PrivacyPolicyContent extends StatelessWidget {
const PrivacyPolicyContent({super.key});
final bool isDark;
const PrivacyPolicyContent({super.key, this.isDark = false});
@override
Widget build(BuildContext context) {
@@ -87,10 +90,10 @@ class PrivacyPolicyContent extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 8),
child: Text(
title,
style: const TextStyle(
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black87,
color: isDark ? Colors.white : Colors.black87,
),
),
);
@@ -101,10 +104,10 @@ class PrivacyPolicyContent extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 8),
child: Text(
title,
style: const TextStyle(
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.black87,
color: isDark ? Colors.white : Colors.black87,
),
),
);
@@ -113,7 +116,11 @@ class PrivacyPolicyContent extends StatelessWidget {
Widget _buildParagraph(String text) {
return Text(
text,
style: TextStyle(fontSize: 14, color: Colors.grey[700], height: 1.6),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
height: 1.6,
),
);
}
@@ -137,7 +144,7 @@ class PrivacyPolicyContent extends StatelessWidget {
text,
style: TextStyle(
fontSize: 14,
color: Colors.grey[700],
color: isDark ? Colors.grey[300] : Colors.grey[700],
height: 1.5,
),
),
@@ -152,19 +159,33 @@ class PrivacyPolicyContent extends StatelessWidget {
margin: const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey.withValues(alpha: 0.2)),
border: Border.all(
color: isDark
? Colors.grey[700]!.withValues(alpha: 0.2)
: Colors.grey.withValues(alpha: 0.2),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(height: 4),
Text(desc, style: TextStyle(fontSize: 13, color: Colors.grey[600])),
Text(
desc,
style: TextStyle(
fontSize: 13,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
);
@@ -179,13 +200,20 @@ class PrivacyPolicyContent extends StatelessWidget {
width: 80,
child: Text(
'$label',
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: isDark ? Colors.white : Colors.black,
),
),
),
Expanded(
child: Text(
value,
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
),
],
@@ -196,14 +224,20 @@ class PrivacyPolicyContent extends StatelessWidget {
Widget _buildUpdateDate(String date) {
return Text(
'更新日期:$date',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
);
}
Widget _buildEffectiveDate(String date) {
return Text(
'生效日期:$date',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
);
}
@@ -213,15 +247,26 @@ class PrivacyPolicyContent extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'到底了',
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
),
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
],
),
);
@@ -230,7 +275,8 @@ class PrivacyPolicyContent extends StatelessWidget {
/// 公共协议内容组件 - 用户协议
class UserAgreementContent extends StatelessWidget {
const UserAgreementContent({super.key});
final bool isDark;
const UserAgreementContent({super.key, this.isDark = false});
@override
Widget build(BuildContext context) {
@@ -320,10 +366,10 @@ class UserAgreementContent extends StatelessWidget {
padding: const EdgeInsets.only(bottom: 8),
child: Text(
title,
style: const TextStyle(
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black87,
color: isDark ? Colors.white : Colors.black87,
),
),
);
@@ -332,7 +378,11 @@ class UserAgreementContent extends StatelessWidget {
Widget _buildParagraph(String text) {
return Text(
text,
style: TextStyle(fontSize: 14, color: Colors.grey[700], height: 1.6),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
height: 1.6,
),
);
}
@@ -345,13 +395,20 @@ class UserAgreementContent extends StatelessWidget {
width: 80,
child: Text(
'$label',
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: isDark ? Colors.white : Colors.black,
),
),
),
Expanded(
child: Text(
value,
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.grey[700],
),
),
),
],
@@ -362,7 +419,10 @@ class UserAgreementContent extends StatelessWidget {
Widget _buildEffectiveDate(String date) {
return Text(
'生效日期:$date',
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[500],
),
);
}
@@ -372,15 +432,26 @@ class UserAgreementContent extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'到底了',
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
),
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
],
),
);
@@ -398,6 +469,7 @@ class PrivacyPage extends StatefulWidget {
class _PrivacyPageState extends State<PrivacyPage>
with TickerProviderStateMixin {
late TabController _tabController;
final ThemeController _themeController = Get.find<ThemeController>();
@override
void initState() {
@@ -413,73 +485,93 @@ class _PrivacyPageState extends State<PrivacyPage>
@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: Colors.white,
elevation: 0,
centerTitle: true,
bottom: TabBar(
controller: _tabController,
labelColor: AppConstants.primaryColor,
unselectedLabelColor: Colors.grey[600],
indicatorColor: AppConstants.primaryColor,
indicatorWeight: 2,
tabs: const [
Tab(text: '隐私政策'),
Tab(text: '用户协议'),
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
elevation: 0,
centerTitle: true,
bottom: TabBar(
controller: _tabController,
labelColor: AppConstants.primaryColor,
unselectedLabelColor: isDark ? Colors.grey[400] : Colors.grey[600],
indicatorColor: AppConstants.primaryColor,
indicatorWeight: 2,
tabs: const [
Tab(text: '隐私政策'),
Tab(text: '用户协议'),
],
),
leading: IconButton(
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
onPressed: () => Navigator.of(context).pop(),
),
actions: [
IconButton(
icon: Icon(Icons.link, color: AppConstants.primaryColor),
onPressed: () => _showOnlineLinkDialog(isDark),
tooltip: '在线版本',
),
],
),
leading: IconButton(
icon: Icon(Icons.arrow_back, color: AppConstants.primaryColor),
onPressed: () => Navigator.of(context).pop(),
body: TabBarView(
controller: _tabController,
children: [
PrivacyPolicyContent(isDark: isDark),
UserAgreementContent(isDark: isDark),
],
),
actions: [
IconButton(
icon: Icon(Icons.link, color: AppConstants.primaryColor),
onPressed: () => _showOnlineLinkDialog(),
tooltip: '在线版本',
),
],
),
body: TabBarView(
controller: _tabController,
children: const [PrivacyPolicyContent(), UserAgreementContent()],
),
);
);
});
}
void _showOnlineLinkDialog() {
void _showOnlineLinkDialog(bool isDark) {
showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: isDark ? const Color(0xFF2A2A2A) : Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: Row(
children: [
Icon(Icons.public, color: AppConstants.primaryColor),
const SizedBox(width: 8),
const Text('在线版本'),
Text(
'在线版本',
style: TextStyle(color: isDark ? Colors.white : Colors.black),
),
],
),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text('您可以访问以下链接查看最新版本的协议:', style: TextStyle(fontSize: 14)),
Text(
'您可以访问以下链接查看最新版本的协议:',
style: TextStyle(
fontSize: 14,
color: isDark ? Colors.grey[300] : Colors.black,
),
),
const SizedBox(height: 16),
Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.grey[100],
color: isDark ? const Color(0xFF3A3A3A) : Colors.grey[100],
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.grey[300]!),
border: Border.all(
color: isDark ? Colors.grey[700]! : Colors.grey[300]!,
),
),
child: SelectableText(
'https://poe.vogov.cn/privacy.html',
@@ -493,14 +585,20 @@ class _PrivacyPageState extends State<PrivacyPage>
const SizedBox(height: 12),
Text(
'💡 点击下方按钮复制链接,在浏览器中打开查看',
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
),
],
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('关闭'),
child: Text(
'关闭',
style: TextStyle(color: isDark ? Colors.grey[400] : null),
),
),
ElevatedButton.icon(
onPressed: () {

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../constants/app_constants.dart';
import '../../../services/get/theme_controller.dart';
/// 时间: 2026-03-26
/// 功能: 用户体验计划页面
@@ -15,6 +17,7 @@ class UserPlanPage extends StatefulWidget {
}
class _UserPlanPageState extends State<UserPlanPage> {
final ThemeController _themeController = Get.find<ThemeController>();
bool _isJoined = false;
bool _isLoading = true;
@@ -187,46 +190,51 @@ class _UserPlanPageState extends State<UserPlanPage> {
@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: _isLoading
? const Center(child: CircularProgressIndicator())
: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildStatusCard(),
const SizedBox(height: 16),
_buildCollectInfoSection(),
const SizedBox(height: 16),
_buildBenefitsSection(),
const SizedBox(height: 16),
_buildPrivacyNotice(),
const SizedBox(height: 24),
_buildActionButton(),
const SizedBox(height: 16),
_buildBottomIndicator(),
],
),
);
body: _isLoading
? const Center(child: CircularProgressIndicator())
: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildStatusCard(isDark),
const SizedBox(height: 16),
_buildCollectInfoSection(isDark),
const SizedBox(height: 16),
_buildBenefitsSection(isDark),
const SizedBox(height: 16),
_buildPrivacyNotice(isDark),
const SizedBox(height: 24),
_buildActionButton(isDark),
const SizedBox(height: 16),
_buildBottomIndicator(isDark),
],
),
);
});
}
Widget _buildStatusCard() {
Widget _buildStatusCard(bool isDark) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
@@ -299,14 +307,14 @@ class _UserPlanPageState extends State<UserPlanPage> {
);
}
Widget _buildCollectInfoSection() {
Widget _buildCollectInfoSection(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.withValues(alpha: 0.05),
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -332,26 +340,32 @@ class _UserPlanPageState extends State<UserPlanPage> {
),
),
const SizedBox(width: 12),
const Text(
Text(
'收集的信息',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
),
const Divider(height: 1),
_buildInfoItem(Icons.timer, '软件使用时长', '统计每日使用时长及时段'),
_buildInfoItem(Icons.visibility, '不同页面停留时间', '了解用户关注的页面'),
_buildInfoItem(Icons.favorite, '个人喜爱诗词', '推荐更精准的内容'),
_buildInfoItem(Icons.error, '错误信息', '优化软件功能体验'),
_buildInfoItem(Icons.location_on, 'IP归属地', '群体用户画像生成分析'),
_buildInfoItem(Icons.devices, '设备信息', '适配更多设备型号'),
_buildInfoItem(Icons.timer, '软件使用时长', '统计每日使用时长及时段', isDark),
_buildInfoItem(Icons.visibility, '不同页面停留时间', '了解用户关注的页面', isDark),
_buildInfoItem(Icons.favorite, '个人喜爱诗词', '推荐更精准的内容', isDark),
_buildInfoItem(Icons.error, '错误信息', '优化软件功能体验', isDark),
_buildInfoItem(Icons.location_on, 'IP归属地', '群体用户画像生成分析', isDark),
_buildInfoItem(Icons.devices, '设备信息', '适配更多设备型号', isDark),
Padding(
padding: const EdgeInsets.all(16),
child: Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.blue.withValues(alpha: 0.05),
color: isDark
? Colors.blue.withValues(alpha: 0.15)
: Colors.blue.withValues(alpha: 0.05),
borderRadius: BorderRadius.circular(8),
),
child: Row(
@@ -373,12 +387,21 @@ class _UserPlanPageState extends State<UserPlanPage> {
);
}
Widget _buildInfoItem(IconData icon, String title, String subtitle) {
Widget _buildInfoItem(
IconData icon,
String title,
String subtitle,
bool isDark,
) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
children: [
Icon(icon, size: 20, color: Colors.grey[600]),
Icon(
icon,
size: 20,
color: isDark ? Colors.grey[400] : Colors.grey[600],
),
const SizedBox(width: 12),
Expanded(
child: Column(
@@ -386,15 +409,19 @@ class _UserPlanPageState extends State<UserPlanPage> {
children: [
Text(
title,
style: const TextStyle(
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(height: 2),
Text(
subtitle,
style: TextStyle(fontSize: 12, color: Colors.grey[500]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[400] : Colors.grey[500],
),
),
],
),
@@ -404,7 +431,7 @@ class _UserPlanPageState extends State<UserPlanPage> {
);
}
Widget _buildBenefitsSection() {
Widget _buildBenefitsSection(bool isDark) {
final benefits = [
{'icon': Icons.how_to_vote, 'title': '参与投票', 'desc': '对产品功能进行投票'},
{'icon': Icons.bar_chart, 'title': '查看统计数据', 'desc': '查看全站使用统计'},
@@ -416,11 +443,11 @@ class _UserPlanPageState extends State<UserPlanPage> {
return Container(
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -450,11 +477,12 @@ class _UserPlanPageState extends State<UserPlanPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
Text(
'加入后的权益',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
const SizedBox(height: 2),
@@ -464,7 +492,9 @@ class _UserPlanPageState extends State<UserPlanPage> {
'体验更多受限制的功能',
style: TextStyle(
fontSize: 11,
color: Colors.grey[500],
color: isDark
? Colors.grey[400]
: Colors.grey[500],
),
),
const SizedBox(width: 4),
@@ -473,7 +503,9 @@ class _UserPlanPageState extends State<UserPlanPage> {
child: Icon(
Icons.info_outline,
size: 14,
color: Colors.grey[500],
color: isDark
? Colors.grey[400]
: Colors.grey[500],
),
),
],
@@ -502,10 +534,12 @@ class _UserPlanPageState extends State<UserPlanPage> {
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.grey[50],
color: isDark ? Colors.grey[800] : Colors.grey[50],
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: Colors.grey.withValues(alpha: 0.2),
color: isDark
? Colors.grey[700]!
: Colors.grey.withValues(alpha: 0.2),
),
),
child: Row(
@@ -523,16 +557,19 @@ class _UserPlanPageState extends State<UserPlanPage> {
children: [
Text(
benefit['title'] as String,
style: const TextStyle(
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: isDark ? Colors.white : Colors.black,
),
),
Text(
benefit['desc'] as String,
style: TextStyle(
fontSize: 10,
color: Colors.grey[500],
color: isDark
? Colors.grey[400]
: Colors.grey[500],
),
),
],
@@ -549,15 +586,15 @@ class _UserPlanPageState extends State<UserPlanPage> {
);
}
Widget _buildPrivacyNotice() {
Widget _buildPrivacyNotice(bool isDark) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
color: isDark ? const Color(0xFF2A2A2A) : Colors.white,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.05),
color: Colors.black.withValues(alpha: isDark ? 0.3 : 0.05),
blurRadius: 10,
offset: const Offset(0, 2),
),
@@ -581,23 +618,27 @@ class _UserPlanPageState extends State<UserPlanPage> {
),
),
const SizedBox(width: 12),
const Text(
Text(
'隐私保护说明',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: isDark ? Colors.white : Colors.black,
),
),
],
),
const SizedBox(height: 16),
_buildPrivacyItem('🔒 数据匿名化处理,无法追溯到个人'),
_buildPrivacyItem('🛡️ 数据仅用于产品改进,不会出售'),
_buildPrivacyItem('📋 您可以随时退出计划'),
_buildPrivacyItem('🗑️ 部分数据将被删除'),
_buildPrivacyItem('🔒 数据匿名化处理,无法追溯到个人', isDark),
_buildPrivacyItem('🛡️ 数据仅用于产品改进,不会出售', isDark),
_buildPrivacyItem('📋 您可以随时退出计划', isDark),
_buildPrivacyItem('🗑️ 部分数据将被删除', isDark),
],
),
);
}
Widget _buildPrivacyItem(String text) {
Widget _buildPrivacyItem(String text, bool isDark) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Row(
@@ -608,7 +649,7 @@ class _UserPlanPageState extends State<UserPlanPage> {
text,
style: TextStyle(
fontSize: 13,
color: Colors.grey[700],
color: isDark ? Colors.grey[300] : Colors.grey[700],
height: 1.4,
),
),
@@ -618,7 +659,7 @@ class _UserPlanPageState extends State<UserPlanPage> {
);
}
Widget _buildActionButton() {
Widget _buildActionButton(bool isDark) {
return Container(
width: double.infinity,
height: 50,
@@ -631,7 +672,9 @@ class _UserPlanPageState extends State<UserPlanPage> {
AppConstants.primaryColor.withBlue(180),
],
),
color: _isJoined ? Colors.grey[300] : null,
color: _isJoined
? (isDark ? Colors.grey[700] : Colors.grey[300])
: null,
borderRadius: BorderRadius.circular(12),
boxShadow: _isJoined
? null
@@ -663,7 +706,9 @@ class _UserPlanPageState extends State<UserPlanPage> {
children: [
Icon(
_isJoined ? Icons.exit_to_app : Icons.volunteer_activism,
color: _isJoined ? Colors.grey[600] : Colors.white,
color: _isJoined
? (isDark ? Colors.grey[300] : Colors.grey[600])
: Colors.white,
),
const SizedBox(width: 8),
Text(
@@ -671,7 +716,9 @@ class _UserPlanPageState extends State<UserPlanPage> {
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: _isJoined ? Colors.grey[600] : Colors.white,
color: _isJoined
? (isDark ? Colors.grey[300] : Colors.grey[600])
: Colors.white,
),
),
],
@@ -680,21 +727,32 @@ class _UserPlanPageState extends State<UserPlanPage> {
);
}
Widget _buildBottomIndicator() {
Widget _buildBottomIndicator(bool isDark) {
return Container(
padding: const EdgeInsets.symmetric(vertical: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'到底了',
style: TextStyle(fontSize: 12, color: Colors.grey[400]),
style: TextStyle(
fontSize: 12,
color: isDark ? Colors.grey[500] : Colors.grey[400],
),
),
),
Container(width: 40, height: 1, color: Colors.grey[300]),
Container(
width: 40,
height: 1,
color: isDark ? Colors.grey[700] : Colors.grey[300],
),
],
),
);

View File

@@ -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(