162 lines
4.9 KiB
Dart
162 lines
4.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/app_colors.dart';
|
|
import '../theme/app_text_styles.dart';
|
|
import '../services/encouragement_service.dart';
|
|
import 'focus_screen.dart';
|
|
import 'history_screen.dart';
|
|
import 'settings_screen.dart';
|
|
|
|
/// Home Screen - Loads default duration from settings
|
|
class HomeScreen extends StatefulWidget {
|
|
final EncouragementService encouragementService;
|
|
|
|
const HomeScreen({
|
|
super.key,
|
|
required this.encouragementService,
|
|
});
|
|
|
|
@override
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
int _defaultDuration = 25;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadDefaultDuration();
|
|
}
|
|
|
|
Future<void> _loadDefaultDuration() async {
|
|
final duration = await SettingsScreen.getDefaultDuration();
|
|
setState(() {
|
|
_defaultDuration = duration;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.background,
|
|
body: SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
// App Title
|
|
Text(
|
|
'FocusBuddy',
|
|
style: AppTextStyles.appTitle,
|
|
),
|
|
|
|
const SizedBox(height: 60),
|
|
|
|
// Duration Display
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 32,
|
|
vertical: 16,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Text(
|
|
'$_defaultDuration minutes',
|
|
style: const TextStyle(
|
|
fontFamily: 'Nunito',
|
|
fontSize: 28,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 60),
|
|
|
|
// Start Focusing Button
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ElevatedButton(
|
|
onPressed: () async {
|
|
final result = await Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => FocusScreen(
|
|
durationMinutes: _defaultDuration,
|
|
encouragementService: widget.encouragementService,
|
|
),
|
|
),
|
|
);
|
|
// Reload duration when returning
|
|
if (result == true || mounted) {
|
|
_loadDefaultDuration();
|
|
}
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Text('Start Focusing'),
|
|
const SizedBox(width: 8),
|
|
Icon(
|
|
Icons.play_arrow,
|
|
color: AppColors.white,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 24),
|
|
|
|
// Helper Text
|
|
Text(
|
|
"Tap 'I got distracted'\nanytime — no guilt.",
|
|
style: AppTextStyles.helperText,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
// Bottom Navigation (simplified for MVP)
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: [
|
|
TextButton.icon(
|
|
onPressed: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const HistoryScreen(),
|
|
),
|
|
);
|
|
},
|
|
icon: const Icon(Icons.bar_chart),
|
|
label: const Text('History'),
|
|
),
|
|
TextButton.icon(
|
|
onPressed: () async {
|
|
await Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => const SettingsScreen(),
|
|
),
|
|
);
|
|
// Reload duration after settings
|
|
_loadDefaultDuration();
|
|
},
|
|
icon: const Icon(Icons.settings),
|
|
label: const Text('Settings'),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|