多语言支持

This commit is contained in:
ytc1012
2025-11-24 11:25:33 +08:00
parent 2c6ced5c14
commit 4444c401b9
14 changed files with 672 additions and 167 deletions

View File

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../theme/app_colors.dart';
import '../theme/app_text_styles.dart';
import '../services/storage_service.dart';
@@ -21,6 +22,7 @@ class CompleteScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final storageService = StorageService();
final todayTotal = storageService.getTodayTotalMinutes();
final todayDistractions = storageService.getTodayDistractionCount();
@@ -44,12 +46,12 @@ class CompleteScreen extends StatelessWidget {
// You focused for X minutes
Text(
'You focused for',
l10n.youFocusedFor,
style: AppTextStyles.headline,
),
const SizedBox(height: 8),
Text(
'$focusedMinutes ${focusedMinutes == 1 ? 'minute' : 'minutes'}',
l10n.minutesValue(focusedMinutes, l10n.minutes(focusedMinutes)),
style: AppTextStyles.largeNumber,
),
@@ -67,12 +69,12 @@ class CompleteScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Total Today: $todayTotal mins',
l10n.totalToday(todayTotal),
style: AppTextStyles.bodyText,
),
const SizedBox(height: 12),
Text(
'Distractions: $todayDistractions ${todayDistractions == 1 ? 'time' : 'times'}',
l10n.distractionsCount(todayDistractions, l10n.times(todayDistractions)),
style: AppTextStyles.bodyText,
),
const SizedBox(height: 20),
@@ -101,7 +103,7 @@ class CompleteScreen extends StatelessWidget {
(route) => false,
);
},
child: const Text('Start Another'),
child: Text(l10n.startAnother),
),
),
@@ -118,7 +120,7 @@ class CompleteScreen extends StatelessWidget {
(route) => route.isFirst, // Keep only the home screen in stack
);
},
child: const Text('View History'),
child: Text(l10n.viewHistory),
),
],
),