diff --git a/lib/presentation/pages/game_over_page.dart b/lib/presentation/pages/game_over_page.dart index 40d5b5e..0248ef3 100644 --- a/lib/presentation/pages/game_over_page.dart +++ b/lib/presentation/pages/game_over_page.dart @@ -39,6 +39,7 @@ class _GameOverPageState extends ConsumerState { final String pokemonImage = args?['pokemonImage'] ?? ''; final String pokemonName = args?['pokemonName'] ?? 'Unknown'; final int streak = args?['streak'] ?? 0; + final int score = args?['score'] ?? 0; // Pad streak with zeroes to 3 digits as in mockup (e.g. 004) final String streakText = streak.toString().padLeft(3, '0'); @@ -241,6 +242,35 @@ class _GameOverPageState extends ConsumerState { ), ), ), + const SizedBox(width: 16), + Expanded( + child: Container( + color: statBoxBg, + padding: const EdgeInsets.symmetric(vertical: 12), + child: Column( + children: [ + const Text( + "SCORE", + style: TextStyle( + color: Colors.red, + fontSize: 10, + fontWeight: FontWeight.bold, + letterSpacing: 1, + ), + ), + const SizedBox(height: 4), + Text( + "$score", + style: const TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), ], ), const SizedBox(height: 16), diff --git a/lib/presentation/pages/guess_page.dart b/lib/presentation/pages/guess_page.dart index 3badd7f..762880e 100644 --- a/lib/presentation/pages/guess_page.dart +++ b/lib/presentation/pages/guess_page.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import '../../core/config/app_constants.dart'; import '../../domain/game/game_state.dart'; import '../providers/game_provider.dart'; import '../providers/navigation_provider.dart'; @@ -75,12 +76,17 @@ class _GuessPageState extends ConsumerState { ) as bool?; if (!mounted) return; - if (playAgain == true) { - await ref.read(gameProvider.notifier).startNewGame(); - } else if (playAgain == false) { + if (playAgain == false) { ref.read(selectedTabProvider.notifier).set(0); // onglet LIST - await ref.read(gameProvider.notifier).startNewGame(); } + // true (Try Again), false (Back to Pokédex) et null (geste retour système) + // relancent tous une nouvelle partie pour ne pas rester bloqué en game over. + await ref.read(gameProvider.notifier).startNewGame(); + } + + String _maskedName(String name) { + if (name.length <= 2) return name; // trop court pour masquer utilement + return '${name[0]}${List.filled(name.length - 2, '_').join()}${name[name.length - 1]}'; } @override @@ -167,7 +173,7 @@ class _GuessPageState extends ConsumerState { // Lives Row( mainAxisAlignment: MainAxisAlignment.center, - children: List.generate(3, (index) { + children: List.generate(AppConstants.startingLives, (index) { return Icon( index < state.lives ? Icons.favorite : Icons.favorite_border, color: Colors.red, @@ -196,7 +202,7 @@ class _GuessPageState extends ConsumerState { borderRadius: BorderRadius.circular(8), ), child: Text( - "HINT: ${pokemon.formatedName[0]}${List.filled(pokemon.formatedName.length - 2, '_').join()}${pokemon.formatedName[pokemon.formatedName.length - 1]}", + "HINT: ${_maskedName(pokemon.formatedName)}", textAlign: TextAlign.center, style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.amber[900], letterSpacing: 4), ),