first commit

This commit is contained in:
ytc1012
2025-11-22 18:17:35 +08:00
commit d427916c6a
169 changed files with 15241 additions and 0 deletions

View File

@@ -0,0 +1,321 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../theme/app_colors.dart';
import '../theme/app_text_styles.dart';
/// Settings Screen - MVP version with duration presets
class SettingsScreen extends StatefulWidget {
const SettingsScreen({super.key});
/// Get the saved default duration (for use in other screens)
static Future<int> getDefaultDuration() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getInt(_durationKey) ?? 25;
}
static const String _durationKey = 'default_duration';
@override
State<SettingsScreen> createState() => _SettingsScreenState();
}
class _SettingsScreenState extends State<SettingsScreen> {
int _selectedDuration = 25; // Default
final List<int> _durationOptions = [15, 25, 45];
@override
void initState() {
super.initState();
_loadSavedDuration();
}
Future<void> _loadSavedDuration() async {
final prefs = await SharedPreferences.getInstance();
setState(() {
_selectedDuration = prefs.getInt(SettingsScreen._durationKey) ?? 25;
});
}
Future<void> _saveDuration(int duration) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setInt(SettingsScreen._durationKey, duration);
setState(() {
_selectedDuration = duration;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.background,
appBar: AppBar(
title: const Text('Settings'),
backgroundColor: AppColors.background,
),
body: ListView(
padding: const EdgeInsets.all(24),
children: [
// Focus Duration Section
_buildSection(
title: 'Focus Settings',
children: [
Padding(
padding: const EdgeInsets.only(bottom: 16),
child: Text(
'Default Focus Duration',
style: AppTextStyles.bodyText,
),
),
..._durationOptions.map((duration) {
return _buildDurationOption(duration);
}),
],
),
const SizedBox(height: 32),
// About Section
_buildSection(
title: 'About',
children: [
ListTile(
contentPadding: EdgeInsets.zero,
title: Text(
'Privacy Policy',
style: AppTextStyles.bodyText,
),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 16,
color: AppColors.textSecondary,
),
onTap: () {
_showPrivacyPolicy();
},
),
const Divider(color: AppColors.divider),
ListTile(
contentPadding: EdgeInsets.zero,
title: Text(
'About FocusBuddy',
style: AppTextStyles.bodyText,
),
trailing: const Icon(
Icons.arrow_forward_ios,
size: 16,
color: AppColors.textSecondary,
),
onTap: () {
_showAboutDialog();
},
),
],
),
const SizedBox(height: 32),
// Version info
Center(
child: Text(
'Version 1.0.0 (MVP)',
style: AppTextStyles.helperText.copyWith(fontSize: 12),
),
),
],
),
);
}
Widget _buildSection({
required String title,
required List<Widget> children,
}) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontFamily: 'Nunito',
fontSize: 18,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
),
),
const SizedBox(height: 16),
...children,
],
),
);
}
Widget _buildDurationOption(int duration) {
final isSelected = _selectedDuration == duration;
return GestureDetector(
onTap: () => _saveDuration(duration),
child: Container(
margin: const EdgeInsets.only(bottom: 12),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: isSelected
? AppColors.primary.withValues(alpha: 0.1)
: AppColors.background,
border: Border.all(
color: isSelected ? AppColors.primary : AppColors.divider,
width: isSelected ? 2 : 1,
),
borderRadius: BorderRadius.circular(12),
),
child: Row(
children: [
// Radio button
Container(
width: 20,
height: 20,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: isSelected ? AppColors.primary : AppColors.textSecondary,
width: 2,
),
color: isSelected ? AppColors.primary : Colors.transparent,
),
child: isSelected
? const Center(
child: Icon(
Icons.check,
size: 12,
color: AppColors.white,
),
)
: null,
),
const SizedBox(width: 16),
// Duration text
Expanded(
child: Text(
'$duration minutes',
style: TextStyle(
fontFamily: 'Nunito',
fontSize: 16,
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
color: isSelected
? AppColors.primary
: AppColors.textPrimary,
),
),
),
// Description
if (duration == 25)
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: AppColors.success.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Text(
'Default',
style: TextStyle(
fontFamily: 'Nunito',
fontSize: 12,
fontWeight: FontWeight.w600,
color: AppColors.success,
),
),
),
],
),
),
);
}
void _showPrivacyPolicy() {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Privacy Policy'),
content: SingleChildScrollView(
child: Text(
'FocusBuddy is 100% offline. We do not collect your name, email, '
'location, or usage data. All sessions stay on your device.\n\n'
'There is no cloud sync, no account system, and no analytics tracking.\n\n'
'For the full privacy policy, visit:\n'
'[Your website URL]/privacy',
style: AppTextStyles.bodyText,
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Close'),
),
],
),
);
}
void _showAboutDialog() {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('About FocusBuddy'),
content: SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'FocusBuddy',
style: TextStyle(
fontFamily: 'Nunito',
fontSize: 20,
fontWeight: FontWeight.w700,
color: AppColors.primary,
),
),
const SizedBox(height: 8),
Text(
'A gentle focus timer for neurodivergent minds',
style: AppTextStyles.bodyText,
),
const SizedBox(height: 16),
Text(
'"Focus is not about never getting distracted — '
'it\'s about gently coming back every time you do."',
style: AppTextStyles.encouragementQuote,
),
const SizedBox(height: 16),
Text(
'✨ No punishment for distractions\n'
'💚 Encouragement over criticism\n'
'🔒 100% offline and private\n'
'🌱 Made with care',
style: AppTextStyles.bodyText,
),
],
),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Close'),
),
],
),
);
}
}