Files
FocusBuddy/lib/screens/complete_screen.dart
2025-11-22 18:17:35 +08:00

130 lines
4.1 KiB
Dart

import 'package:flutter/material.dart';
import '../theme/app_colors.dart';
import '../theme/app_text_styles.dart';
import '../services/storage_service.dart';
import '../services/encouragement_service.dart';
import 'home_screen.dart';
import 'history_screen.dart';
/// Complete Screen - Shows after focus session ends
class CompleteScreen extends StatelessWidget {
final int focusedMinutes;
final int distractionCount;
final EncouragementService encouragementService;
const CompleteScreen({
super.key,
required this.focusedMinutes,
required this.distractionCount,
required this.encouragementService,
});
@override
Widget build(BuildContext context) {
final storageService = StorageService();
final todayTotal = storageService.getTodayTotalMinutes();
final todayDistractions = storageService.getTodayDistractionCount();
final encouragement = encouragementService.getRandomMessage();
return Scaffold(
backgroundColor: AppColors.background,
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Success Icon
const Text(
'',
style: TextStyle(fontSize: 64),
),
const SizedBox(height: 32),
// You focused for X minutes
Text(
'You focused for',
style: AppTextStyles.headline,
),
const SizedBox(height: 8),
Text(
'$focusedMinutes ${focusedMinutes == 1 ? 'minute' : 'minutes'}',
style: AppTextStyles.largeNumber,
),
const SizedBox(height: 40),
// Stats Card
Container(
width: double.infinity,
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: AppColors.white,
borderRadius: BorderRadius.circular(16),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Total Today: $todayTotal mins',
style: AppTextStyles.bodyText,
),
const SizedBox(height: 12),
Text(
'Distractions: $todayDistractions ${todayDistractions == 1 ? 'time' : 'times'}',
style: AppTextStyles.bodyText,
),
const SizedBox(height: 20),
Text(
'"$encouragement"',
style: AppTextStyles.encouragementQuote,
),
],
),
),
const SizedBox(height: 40),
// Start Another Button
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => HomeScreen(
encouragementService: encouragementService,
),
),
(route) => false,
);
},
child: const Text('Start Another'),
),
),
const SizedBox(height: 16),
// View Full Report - Navigate to History
TextButton(
onPressed: () {
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const HistoryScreen(),
),
(route) => route.isFirst, // Keep only the home screen in stack
);
},
child: const Text('View History'),
),
],
),
),
),
);
}
}