Files
AutoTime-Tracker/lib/screens/settings_screen.dart
2025-11-13 15:45:28 +08:00

271 lines
7.9 KiB
Dart

import 'package:flutter/material.dart';
import '../theme/app_theme.dart';
import 'category_management_screen.dart';
import 'goal_setting_screen.dart';
import 'export_data_screen.dart';
import 'data_privacy_screen.dart';
import 'about_screen.dart';
import 'notification_settings_screen.dart';
import 'appearance_settings_screen.dart';
class SettingsScreen extends StatelessWidget {
const SettingsScreen({super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: const Text('Settings'),
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
_buildSettingsSection(
title: '应用分类',
icon: Icons.category,
subtitle: '管理应用分类规则',
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const CategoryManagementScreen(),
),
);
},
theme: theme,
),
const SizedBox(height: 8),
_buildSettingsSection(
title: '时间目标',
icon: Icons.flag,
subtitle: '设置每日时间目标',
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const GoalSettingScreen(),
),
);
},
theme: theme,
),
const SizedBox(height: 8),
_buildSettingsSection(
title: '数据导出',
icon: Icons.file_download,
subtitle: '导出 CSV 数据、统计报告',
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const ExportDataScreen(),
),
);
},
theme: theme,
),
const SizedBox(height: 8),
_buildSettingsSection(
title: '数据与隐私',
icon: Icons.security,
subtitle: '数据管理、删除',
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const DataPrivacyScreen(),
),
);
},
theme: theme,
),
const SizedBox(height: 8),
_buildSettingsSection(
title: '通知设置',
icon: Icons.notifications,
subtitle: '目标提醒、每日报告',
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const NotificationSettingsScreen(),
),
);
},
theme: theme,
),
const SizedBox(height: 8),
_buildSettingsSection(
title: '外观设置',
icon: Icons.palette,
subtitle: '主题、字体大小',
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const AppearanceSettingsScreen(),
),
);
},
theme: theme,
),
const SizedBox(height: 24),
_buildUpgradeCard(theme),
const SizedBox(height: 24),
_buildSettingsSection(
title: '关于',
icon: Icons.info,
subtitle: '版本信息、帮助、反馈',
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const AboutScreen(),
),
);
},
theme: theme,
),
],
),
);
}
Widget _buildSettingsSection({
required String title,
required IconData icon,
required String subtitle,
required VoidCallback onTap,
required ThemeData theme,
}) {
return Card(
child: ListTile(
leading: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppTheme.primaryColor.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: Icon(
icon,
color: AppTheme.primaryColor,
),
),
title: Text(
title,
style: theme.textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
),
),
subtitle: Text(
subtitle,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurface.withOpacity(0.6),
),
),
trailing: const Icon(Icons.chevron_right),
onTap: onTap,
),
);
}
Widget _buildUpgradeCard(ThemeData theme) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
AppTheme.primaryColor,
AppTheme.secondaryColor,
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
Icons.diamond,
color: Colors.white,
size: 24,
),
),
const SizedBox(width: 12),
Text(
'Upgrade to Pro',
style: theme.textTheme.titleLarge?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
],
),
const SizedBox(height: 12),
Text(
'解锁高级功能',
style: theme.textTheme.bodyMedium?.copyWith(
color: Colors.white.withOpacity(0.9),
),
),
const SizedBox(height: 8),
...[
'无限历史数据',
'高级统计分析',
'效率评分与分析',
'个性化建议',
'数据导出',
].map((feature) => Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Row(
children: [
const Icon(
Icons.check_circle,
color: Colors.white,
size: 16,
),
const SizedBox(width: 8),
Text(
feature,
style: theme.textTheme.bodySmall?.copyWith(
color: Colors.white.withOpacity(0.9),
),
),
],
),
)),
const SizedBox(height: 16),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
// 打开订阅页面
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: AppTheme.primaryColor,
padding: const EdgeInsets.symmetric(vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Text(
'立即升级',
style: TextStyle(
fontWeight: FontWeight.w600,
),
),
),
),
],
),
);
}
}