积分、成就系统
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../theme/app_colors.dart';
|
||||
import '../theme/app_text_styles.dart';
|
||||
import '../models/focus_session.dart';
|
||||
import '../services/storage_service.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import 'session_detail_screen.dart';
|
||||
|
||||
/// History Screen - Shows past focus sessions
|
||||
class HistoryScreen extends StatefulWidget {
|
||||
@@ -81,10 +82,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'📊',
|
||||
style: TextStyle(fontSize: 64),
|
||||
),
|
||||
const Text('📊', style: TextStyle(fontSize: 64)),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.noFocusSessionsYet,
|
||||
@@ -108,7 +106,12 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTodaySummary(AppLocalizations l10n, int totalMins, int distractions, int sessions) {
|
||||
Widget _buildTodaySummary(
|
||||
AppLocalizations l10n,
|
||||
int totalMins,
|
||||
int distractions,
|
||||
int sessions,
|
||||
) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
@@ -155,13 +158,20 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildStat('Total', l10n.minutesValue(totalMins, l10n.minutes(totalMins)), '⏱️'),
|
||||
child: _buildStat(
|
||||
'Total',
|
||||
l10n.minutesValue(totalMins, l10n.minutes(totalMins)),
|
||||
'⏱️',
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: _buildStat(
|
||||
'Distractions',
|
||||
l10n.distractionsCount(distractions, l10n.times(distractions)),
|
||||
l10n.distractionsCount(
|
||||
distractions,
|
||||
l10n.times(distractions),
|
||||
),
|
||||
'🤚',
|
||||
),
|
||||
),
|
||||
@@ -176,10 +186,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
emoji,
|
||||
style: const TextStyle(fontSize: 24),
|
||||
),
|
||||
Text(emoji, style: const TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
label,
|
||||
@@ -204,7 +211,11 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDateSection(AppLocalizations l10n, DateTime date, List<FocusSession> sessions) {
|
||||
Widget _buildDateSection(
|
||||
AppLocalizations l10n,
|
||||
DateTime date,
|
||||
List<FocusSession> sessions,
|
||||
) {
|
||||
final isToday = _isToday(date);
|
||||
final dateLabel = isToday
|
||||
? l10n.today
|
||||
@@ -257,83 +268,108 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
final statusEmoji = session.completed ? '✅' : '⏸️';
|
||||
final statusText = session.completed ? l10n.completed : l10n.stoppedEarly;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppColors.divider,
|
||||
width: 1,
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SessionDetailScreen(session: session),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: AppColors.divider, width: 1),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.05),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Time
|
||||
Text(
|
||||
timeStr,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Duration
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.minutesValue(session.actualMinutes, l10n.minutes(session.actualMinutes)),
|
||||
style: AppTextStyles.bodyText,
|
||||
),
|
||||
if (session.distractionCount > 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
l10n.distractionsCount(session.distractionCount, l10n.times(session.distractionCount)),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Status badge
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: session.completed
|
||||
? AppColors.success.withValues(alpha: 0.1)
|
||||
: AppColors.distractionButton,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'$statusEmoji $statusText',
|
||||
style: TextStyle(
|
||||
child: Row(
|
||||
children: [
|
||||
// Time
|
||||
Text(
|
||||
timeStr,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 12,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: session.completed
|
||||
? AppColors.success
|
||||
: AppColors.textSecondary,
|
||||
color: AppColors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
const SizedBox(width: 16),
|
||||
|
||||
// Duration
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
l10n.minutesValue(
|
||||
session.actualMinutes,
|
||||
l10n.minutes(session.actualMinutes),
|
||||
),
|
||||
style: AppTextStyles.bodyText,
|
||||
),
|
||||
if (session.distractionCount > 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
l10n.distractionsCount(
|
||||
session.distractionCount,
|
||||
l10n.times(session.distractionCount),
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// Status badge
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: session.completed
|
||||
? AppColors.success.withValues(alpha: 0.1)
|
||||
: AppColors.distractionButton,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
'$statusEmoji $statusText',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: session.completed
|
||||
? AppColors.success
|
||||
: AppColors.textSecondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Arrow indicator
|
||||
const SizedBox(width: 8),
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 12,
|
||||
color: AppColors.textSecondary,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user