import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import '../models/task_item.dart'; import '../services/database_service.dart'; class SettingsPage extends StatelessWidget { const SettingsPage({super.key}); @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: ListView( padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20), children: [ const Text( "Settings", style: TextStyle(fontSize: 32, fontWeight: FontWeight.w900), ), const SizedBox(height: 30), // Profile Area Container( padding: const EdgeInsets.all(20), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.02), blurRadius: 10, offset: const Offset(0, 4), ) ], ), child: Row( children: [ CircleAvatar( backgroundColor: Colors.grey.shade100, radius: 24, child: const Icon(Icons.person, color: Colors.grey), ), const SizedBox(width: 16), const Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Guest User", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 16, ), ), Text( "Sign in to sync data", style: TextStyle(color: Colors.grey, fontSize: 12), ), ], ), const Spacer(), const Icon(Icons.chevron_right, color: Colors.grey), ], ), ), const SizedBox(height: 30), _buildSectionHeader("PREFERENCES"), _buildSettingTile(Icons.notifications_outlined, "Notifications", trailing: "On"), _buildSettingTile(Icons.vibration, "Haptic Feedback", trailing: "On"), _buildSettingTile(Icons.dark_mode_outlined, "Dark Mode", trailing: "System"), const SizedBox(height: 30), _buildSectionHeader("DATA & STORAGE"), _buildSettingTile(Icons.cloud_upload_outlined, "Backup Data"), _buildSettingTile( Icons.delete_outline, "Clear All Data", isDestructive: true, onTap: () async { await DatabaseService.getTasksBox().clear(); if (context.mounted) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text("Data Cleared")), ); } }, ), const SizedBox(height: 30), _buildSectionHeader("SUPPORT"), _buildSettingTile(Icons.share_outlined, "Share EssenceDailyCore"), _buildSettingTile(Icons.star_outline, "Rate Us"), _buildSettingTile(Icons.mail_outline, "Send Feedback"), _buildSettingTile(Icons.privacy_tip_outlined, "Privacy Policy"), const SizedBox(height: 40), Center( child: Text( "Version 1.0.0 (EssenceDailyCore)", style: TextStyle( color: Colors.grey.shade300, fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: 1, ), ), ), const SizedBox(height: 20), ], ), ), ); } Widget _buildSectionHeader(String title) { return Padding( padding: const EdgeInsets.only(left: 10, bottom: 10), child: Text( title, style: const TextStyle( fontSize: 11, fontWeight: FontWeight.bold, color: Color(0xFFFF7F50), letterSpacing: 1.2, ), ), ); } Widget _buildSettingTile( IconData icon, String title, { String? trailing, bool isDestructive = false, VoidCallback? onTap, }) { return Container( margin: const EdgeInsets.only(bottom: 8), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(16), ), child: ListTile( onTap: onTap, contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 4), leading: Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: Colors.grey.shade50, borderRadius: BorderRadius.circular(10), ), child: Icon( icon, color: isDestructive ? Colors.red : Colors.black87, size: 20, ), ), title: Text( title, style: TextStyle( fontWeight: FontWeight.w500, fontSize: 15, color: isDestructive ? Colors.red : Colors.black87, ), ), trailing: trailing != null ? Text( trailing, style: TextStyle( color: Colors.grey.shade400, fontSize: 13, ), ) : Icon( Icons.chevron_right, color: Colors.grey.shade300, size: 20, ), ), ); } }