import 'package:flutter/material.dart'; import 'package:lucide_icons/lucide_icons.dart'; class SettingsScreen extends StatefulWidget { const SettingsScreen({super.key}); @override State createState() => _SettingsScreenState(); } class _SettingsScreenState extends State { bool _notificationsEnabled = true; bool _darkMode = true; bool _hapticFeedback = true; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: const Color(0xFF2E1065), body: SafeArea( child: Column( children: [ _buildHeader(), Expanded( child: SingleChildScrollView( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildSectionTitle('通知'), _buildSwitchTile( icon: LucideIcons.bell, title: '推送通知', subtitle: '接收消息和活动提醒', value: _notificationsEnabled, onChanged: (v) => setState(() => _notificationsEnabled = v), ), const SizedBox(height: 20), _buildSectionTitle('显示'), _buildSwitchTile( icon: LucideIcons.moon, title: '深色模式', subtitle: '始终使用深色主题', value: _darkMode, onChanged: (v) => setState(() => _darkMode = v), ), const SizedBox(height: 20), _buildSectionTitle('体验'), _buildSwitchTile( icon: LucideIcons.smartphone, title: '触觉反馈', subtitle: '操作时产生震动反馈', value: _hapticFeedback, onChanged: (v) => setState(() => _hapticFeedback = v), ), const SizedBox(height: 20), _buildSectionTitle('存储'), _buildActionTile( icon: LucideIcons.trash2, title: '清除缓存', subtitle: '已使用 128 MB', onTap: () {}, ), const SizedBox(height: 20), _buildSectionTitle('关于'), _buildInfoTile( icon: LucideIcons.info, title: '版本', value: 'v2.5.0', ), ], ), ), ), ], ), ), ); } Widget _buildHeader() { return Padding( padding: const EdgeInsets.fromLTRB(8, 8, 16, 16), child: Row( children: [ IconButton( onPressed: () => Navigator.of(context).pop(), icon: Icon(LucideIcons.chevronLeft, color: Colors.white.withOpacity(0.7)), ), const Text( '系统设置', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.white), ), ], ), ); } Widget _buildSectionTitle(String title) { return Padding( padding: const EdgeInsets.only(left: 4, bottom: 12), child: Text( title, style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, letterSpacing: 2, color: Colors.white.withOpacity(0.4), ), ), ); } Widget _buildSwitchTile({ required IconData icon, required String title, required String subtitle, required bool value, required ValueChanged onChanged, }) { return Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.white.withOpacity(0.1)), ), child: Row( children: [ Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(12), ), child: Icon(icon, size: 20, color: Colors.white.withOpacity(0.7)), ), const SizedBox(width: 14), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(title, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Colors.white)), const SizedBox(height: 2), Text(subtitle, style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.5))), ], ), ), Switch( value: value, onChanged: onChanged, activeColor: const Color(0xFFC084FC), ), ], ), ); } Widget _buildActionTile({ required IconData icon, required String title, required String subtitle, required VoidCallback onTap, }) { return GestureDetector( onTap: onTap, child: Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.white.withOpacity(0.1)), ), child: Row( children: [ Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(12), ), child: Icon(icon, size: 20, color: Colors.white.withOpacity(0.7)), ), const SizedBox(width: 14), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(title, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Colors.white)), const SizedBox(height: 2), Text(subtitle, style: TextStyle(fontSize: 12, color: Colors.white.withOpacity(0.5))), ], ), ), Icon(LucideIcons.chevronRight, size: 18, color: Colors.white.withOpacity(0.3)), ], ), ), ); } Widget _buildInfoTile({ required IconData icon, required String title, required String value, }) { return Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(16), border: Border.all(color: Colors.white.withOpacity(0.1)), ), child: Row( children: [ Container( padding: const EdgeInsets.all(10), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.circular(12), ), child: Icon(icon, size: 20, color: Colors.white.withOpacity(0.7)), ), const SizedBox(width: 14), Expanded(child: Text(title, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: Colors.white))), Text(value, style: TextStyle(fontSize: 14, fontFamily: 'monospace', color: Colors.white.withOpacity(0.5))), ], ), ); } }