多语言支持
This commit is contained in:
@@ -4,6 +4,7 @@ import '../theme/app_colors.dart';
|
||||
import '../theme/app_text_styles.dart';
|
||||
import 'home_screen.dart';
|
||||
import '../services/encouragement_service.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
|
||||
/// Onboarding Screen - Shows on first launch
|
||||
class OnboardingScreen extends StatefulWidget {
|
||||
@@ -35,27 +36,7 @@ class OnboardingScreen extends StatefulWidget {
|
||||
class _OnboardingScreenState extends State<OnboardingScreen> {
|
||||
final PageController _pageController = PageController();
|
||||
int _currentPage = 0;
|
||||
|
||||
final List<OnboardingPage> _pages = [
|
||||
OnboardingPage(
|
||||
emoji: '💚',
|
||||
title: 'Focus without guilt',
|
||||
description:
|
||||
"This app is different — it won't punish you for losing focus.\n\nPerfect for ADHD, anxiety, or anyone who finds traditional timers too harsh.",
|
||||
),
|
||||
OnboardingPage(
|
||||
emoji: '🤚',
|
||||
title: 'Tap when you get distracted',
|
||||
description:
|
||||
"We'll gently remind you to come back.\n\nNo shame. No stress. Just a friendly nudge.",
|
||||
),
|
||||
OnboardingPage(
|
||||
emoji: '📊',
|
||||
title: 'Track your progress',
|
||||
description:
|
||||
"See how you're improving, one session at a time.\n\nEvery distraction is just data — not failure.",
|
||||
),
|
||||
];
|
||||
static const int _totalPages = 3;
|
||||
|
||||
void _onPageChanged(int page) {
|
||||
setState(() {
|
||||
@@ -64,7 +45,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
|
||||
}
|
||||
|
||||
void _nextPage() {
|
||||
if (_currentPage < _pages.length - 1) {
|
||||
if (_currentPage < _totalPages - 1) {
|
||||
_pageController.animateToPage(
|
||||
_currentPage + 1,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
@@ -102,6 +83,26 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
final pages = [
|
||||
OnboardingPage(
|
||||
emoji: '💚',
|
||||
title: l10n.onboarding1Title,
|
||||
description: l10n.onboarding1Description,
|
||||
),
|
||||
OnboardingPage(
|
||||
emoji: '🤚',
|
||||
title: l10n.onboarding2Title,
|
||||
description: l10n.onboarding2Description,
|
||||
),
|
||||
OnboardingPage(
|
||||
emoji: '📊',
|
||||
title: l10n.onboarding3Title,
|
||||
description: l10n.onboarding3Description,
|
||||
),
|
||||
];
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.background,
|
||||
body: SafeArea(
|
||||
@@ -114,9 +115,9 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: TextButton(
|
||||
onPressed: _skipOnboarding,
|
||||
child: const Text(
|
||||
'Skip',
|
||||
style: TextStyle(
|
||||
child: Text(
|
||||
l10n.skip,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Nunito',
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -132,9 +133,9 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
|
||||
child: PageView.builder(
|
||||
controller: _pageController,
|
||||
onPageChanged: _onPageChanged,
|
||||
itemCount: _pages.length,
|
||||
itemCount: pages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return _buildPage(_pages[index]);
|
||||
return _buildPage(pages[index]);
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -145,7 +146,7 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(
|
||||
_pages.length,
|
||||
pages.length,
|
||||
(index) => _buildIndicator(index == _currentPage),
|
||||
),
|
||||
),
|
||||
@@ -159,9 +160,9 @@ class _OnboardingScreenState extends State<OnboardingScreen> {
|
||||
child: ElevatedButton(
|
||||
onPressed: _nextPage,
|
||||
child: Text(
|
||||
_currentPage == _pages.length - 1
|
||||
? 'Get Started'
|
||||
: 'Next',
|
||||
_currentPage == pages.length - 1
|
||||
? l10n.getStarted
|
||||
: l10n.next,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user