patch small issue with trad and theme

This commit is contained in:
2026-06-23 14:17:27 +02:00
parent 47536843be
commit 3984e94bc5
33 changed files with 556 additions and 156 deletions
@@ -8,12 +8,18 @@ class PokemonDetailTop extends StatelessWidget {
final Pokemon pokemon;
final bool isShiny;
final VoidCallback onToggleShiny;
final Color primaryColor;
final Color primaryDark;
final Color surfaceColor;
const PokemonDetailTop({
super.key,
required this.pokemon,
required this.isShiny,
required this.onToggleShiny,
required this.primaryColor,
required this.primaryDark,
required this.surfaceColor,
});
@override
@@ -21,9 +27,9 @@ class PokemonDetailTop extends StatelessWidget {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: const Color(0xFF1B2333),
color: surfaceColor,
borderRadius: BorderRadius.circular(8),
border: Border.all(color: const Color(0xFF1B2333), width: 8),
border: Border.all(color: surfaceColor, width: 8),
),
child: Container(
color: const Color(0xFF90A4AE),
@@ -32,7 +38,7 @@ class PokemonDetailTop extends StatelessWidget {
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
color: const Color(0xFF1B2333),
color: surfaceColor,
child: Text(
"NO. ${pokemon.id.toString().padLeft(3, '0')}",
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
@@ -60,7 +66,11 @@ class PokemonDetailTop extends StatelessWidget {
Expanded(
child: Text(
pokemon.formatedName.toUpperCase(),
style: const TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold, letterSpacing: 2),
style: const TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.bold,
letterSpacing: 2),
overflow: TextOverflow.ellipsis,
),
),
@@ -1,19 +1,35 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../domain/entities/pokemon.dart';
import '../../../l10n/app_localizations.dart';
import '../../providers/locale_provider.dart';
/// Écran inférieur du détail : stats de base, description et éléments décoratifs.
class PokemonStatsPanel extends StatelessWidget {
/// Écran inférieur du détail : stats de base, description localisée et éléments décoratifs.
class PokemonStatsPanel extends ConsumerWidget {
final Pokemon pokemon;
const PokemonStatsPanel({super.key, required this.pokemon});
final Color surfaceColor;
final String? descriptionOverride;
const PokemonStatsPanel({
super.key,
required this.pokemon,
required this.surfaceColor,
this.descriptionOverride,
});
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final l = AppLocalizations.of(context)!;
ref.watch(localeProvider); // watch locale so widget rebuilds on language change
final description = descriptionOverride ?? pokemon.description;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(color: const Color(0xFF1B2333), borderRadius: BorderRadius.circular(8)),
decoration: BoxDecoration(
color: surfaceColor,
borderRadius: BorderRadius.circular(8),
),
child: Container(
color: const Color(0xFFC8D1D8),
padding: const EdgeInsets.all(16),
@@ -23,12 +39,20 @@ class PokemonStatsPanel extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(l.baseStats, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold, letterSpacing: 2)),
Text("MODEL: DS-01", style: TextStyle(fontSize: 12, color: Colors.grey[700], fontWeight: FontWeight.bold)),
Text(l.baseStats,
style: const TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
letterSpacing: 2)),
Text("MODEL: DS-01",
style: TextStyle(
fontSize: 12,
color: Colors.grey[700],
fontWeight: FontWeight.bold)),
],
),
const Divider(color: Colors.black38, thickness: 2, height: 20),
_StatBar(label: "HP", value: pokemon.hp, color: const Color(0xFFE53935)),
_StatBar(label: "HP", value: pokemon.hp, color: const Color(0xFFE53935)),
_StatBar(label: "ATK", value: pokemon.atk, color: const Color(0xFFFB8C00)),
_StatBar(label: "DEF", value: pokemon.def, color: const Color(0xFFFDD835)),
_StatBar(label: "SPD", value: pokemon.spd, color: const Color(0xFF1E88E5)),
@@ -36,16 +60,19 @@ class PokemonStatsPanel extends StatelessWidget {
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(color: const Color(0xFFE2EBF0), border: Border.all(color: Colors.grey[400]!)),
decoration: BoxDecoration(
color: const Color(0xFFE2EBF0),
border: Border.all(color: Colors.grey[400]!),
),
child: Text(
pokemon.description != null && pokemon.description!.isNotEmpty
? '"${pokemon.description!}"'
description != null && description.isNotEmpty
? '"$description"'
: '"${l.noDescription}"',
style: const TextStyle(fontSize: 16, height: 1.5),
),
),
const SizedBox(height: 16),
const _DecorativeLights(),
_DecorativeLights(accentColor: surfaceColor),
],
),
),
@@ -53,7 +80,6 @@ class PokemonStatsPanel extends StatelessWidget {
}
}
/// Barre d'une statistique (libellé, jauge proportionnelle, valeur).
class _StatBar extends StatelessWidget {
final String label;
final int value;
@@ -62,20 +88,27 @@ class _StatBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final ratio = (value / 255).clamp(0.0, 1.0); // stat de base max supposée = 255
final ratio = (value / 255).clamp(0.0, 1.0);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
children: [
SizedBox(width: 50, child: Text(label, style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18))),
SizedBox(
width: 50,
child: Text(label,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18))),
Expanded(
child: Container(
height: 14,
decoration: BoxDecoration(color: Colors.grey[400]),
child: Row(
children: [
Expanded(flex: (ratio * 100).toInt(), child: Container(color: color)),
Expanded(flex: 100 - (ratio * 100).toInt(), child: Container()),
Expanded(
flex: (ratio * 100).toInt(),
child: Container(color: color)),
Expanded(
flex: 100 - (ratio * 100).toInt(),
child: Container()),
],
),
),
@@ -84,7 +117,8 @@ class _StatBar extends StatelessWidget {
SizedBox(
width: 40,
child: Text(value.toString(),
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18), textAlign: TextAlign.right),
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
textAlign: TextAlign.right),
),
],
),
@@ -92,21 +126,26 @@ class _StatBar extends StatelessWidget {
}
}
/// Petites diodes décoratives en bas du panneau (purement cosmétiques).
class _DecorativeLights extends StatelessWidget {
const _DecorativeLights();
final Color accentColor;
const _DecorativeLights({required this.accentColor});
@override
Widget build(BuildContext context) {
final dark = HSLColor.fromColor(accentColor)
.withLightness(
(HSLColor.fromColor(accentColor).lightness - 0.1).clamp(0.0, 1.0))
.toColor();
return Row(
children: [
Container(
width: 24,
height: 24,
decoration: BoxDecoration(
color: const Color(0xFF1E88E5),
color: accentColor,
shape: BoxShape.circle,
border: Border.all(color: const Color(0xFF1565C0), width: 2),
border: Border.all(color: dark, width: 2),
),
),
const SizedBox(width: 8),
@@ -122,9 +161,19 @@ class _DecorativeLights extends StatelessWidget {
const Spacer(),
Row(
children: [
Container(height: 6, width: 30, decoration: BoxDecoration(color: Colors.grey[500], borderRadius: BorderRadius.circular(3))),
Container(
height: 6,
width: 30,
decoration: BoxDecoration(
color: Colors.grey[500],
borderRadius: BorderRadius.circular(3))),
const SizedBox(width: 4),
Container(height: 6, width: 30, decoration: BoxDecoration(color: Colors.grey[500], borderRadius: BorderRadius.circular(3))),
Container(
height: 6,
width: 30,
decoration: BoxDecoration(
color: Colors.grey[500],
borderRadius: BorderRadius.circular(3))),
],
),
],
@@ -3,19 +3,27 @@ import '../../../l10n/app_localizations.dart';
/// Boutons d'action de l'écran game over : rejouer ou retourner au Pokédex.
class GameOverActions extends StatelessWidget {
final Color primaryColor;
final Color primaryDark;
final VoidCallback onTryAgain;
final VoidCallback onBack;
const GameOverActions({super.key, required this.onTryAgain, required this.onBack});
const GameOverActions({
super.key,
required this.primaryColor,
required this.primaryDark,
required this.onTryAgain,
required this.onBack,
});
@override
Widget build(BuildContext context) {
final l = AppLocalizations.of(context)!;
return Column(
children: [
_button(label: l.tryAgain, icon: Icons.refresh, color: const Color(0xFF2962FF), onPressed: onTryAgain),
_button(label: l.tryAgain, icon: Icons.refresh, color: primaryColor, onPressed: onTryAgain),
const SizedBox(height: 16),
_button(label: l.backToPokedex, icon: Icons.menu_book, color: const Color(0xFFA66A00), onPressed: onBack),
_button(label: l.backToPokedex, icon: Icons.menu_book, color: primaryDark, onPressed: onBack),
],
);
}
@@ -6,17 +6,24 @@ import '../pokemon_image.dart';
class GameOverHeader extends StatelessWidget {
final String pokemonImage;
final String pokemonName;
final Color primaryDark;
final Color surfaceColor;
const GameOverHeader({super.key, required this.pokemonImage, required this.pokemonName});
const GameOverHeader({
super.key,
required this.pokemonImage,
required this.pokemonName,
required this.primaryDark,
required this.surfaceColor,
});
static const _darkRed = Color(0xFF9E1B1B);
static const _silverBg = Color(0xFFC8D1D8);
@override
Widget build(BuildContext context) {
final l = AppLocalizations.of(context)!;
return Container(
decoration: BoxDecoration(color: _darkRed, border: Border.all(color: _darkRed, width: 4)),
decoration: BoxDecoration(color: primaryDark, border: Border.all(color: primaryDark, width: 4)),
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 16),
@@ -24,7 +31,7 @@ class GameOverHeader extends StatelessWidget {
child: Column(
children: [
Container(
color: _darkRed,
color: primaryDark,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
child: Text(
l.gameOver,
@@ -44,10 +51,10 @@ class GameOverHeader extends StatelessWidget {
Text(
l.itWas(pokemonName),
textAlign: TextAlign.center,
style: const TextStyle(
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Color(0xFF1B2333),
color: surfaceColor,
letterSpacing: 1,
),
),
@@ -2,9 +2,8 @@ import 'package:flutter/material.dart';
/// Séparateur décoratif (deux traits + trois points) entre les blocs de l'écran game over.
class HingeDivider extends StatelessWidget {
const HingeDivider({super.key});
static const _darkRed = Color(0xFF9E1B1B);
final Color color;
const HingeDivider({super.key, required this.color});
@override
Widget build(BuildContext context) {
@@ -12,7 +11,7 @@ class HingeDivider extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 24.0),
child: Row(
children: [
Expanded(child: Container(height: 2, color: _darkRed)),
Expanded(child: Container(height: 2, color: color)),
const SizedBox(width: 8),
Row(
mainAxisSize: MainAxisSize.min,
@@ -22,12 +21,12 @@ class HingeDivider extends StatelessWidget {
width: 8,
height: 8,
margin: const EdgeInsets.symmetric(horizontal: 4),
decoration: const BoxDecoration(color: _darkRed, shape: BoxShape.circle),
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
),
),
),
const SizedBox(width: 8),
Expanded(child: Container(height: 2, color: _darkRed)),
Expanded(child: Container(height: 2, color: color)),
],
),
);
@@ -8,6 +8,7 @@ class GenFilterSection extends StatelessWidget {
final VoidCallback onToggleOpen;
final Set<int> selectedGens;
final void Function(int) onToggle;
final Color surfaceColor;
const GenFilterSection({
super.key,
@@ -15,6 +16,7 @@ class GenFilterSection extends StatelessWidget {
required this.onToggleOpen,
required this.selectedGens,
required this.onToggle,
required this.surfaceColor,
});
@override
@@ -29,19 +31,19 @@ class GenFilterSection extends StatelessWidget {
onPressed: onToggleOpen,
icon: Icon(
isOpen ? Icons.expand_less : Icons.filter_list,
color: const Color(0xFF1B2333),
color: surfaceColor,
),
label: Text(
AppLocalizations.of(context)!.genFilter,
style: const TextStyle(
color: Color(0xFF1B2333),
style: TextStyle(
color: surfaceColor,
fontWeight: FontWeight.bold,
fontSize: 16,
letterSpacing: 2,
),
),
style: OutlinedButton.styleFrom(
side: const BorderSide(color: Color(0xFF1B2333), width: 2),
side: BorderSide(color: surfaceColor, width: 2),
padding: const EdgeInsets.symmetric(vertical: 12),
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.zero),
),
@@ -51,7 +53,7 @@ class GenFilterSection extends StatelessWidget {
duration: const Duration(milliseconds: 250),
curve: Curves.easeInOut,
child: isOpen
? _GenFilterPanel(selectedGens: selectedGens, onToggle: onToggle)
? _GenFilterPanel(selectedGens: selectedGens, onToggle: onToggle, surfaceColor: surfaceColor)
: const SizedBox.shrink(),
),
],
@@ -63,8 +65,9 @@ class GenFilterSection extends StatelessWidget {
class _GenFilterPanel extends StatelessWidget {
final Set<int> selectedGens;
final void Function(int) onToggle;
final Color surfaceColor;
const _GenFilterPanel({required this.selectedGens, required this.onToggle});
const _GenFilterPanel({required this.selectedGens, required this.onToggle, required this.surfaceColor});
static const _genNames = [
'Gen I', 'Gen II', 'Gen III', 'Gen IV', 'Gen V', 'Gen VI', 'Gen VII', 'Gen VIII', 'Gen IX'
@@ -76,7 +79,7 @@ class _GenFilterPanel extends StatelessWidget {
margin: const EdgeInsets.only(top: 4),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: const Color(0xFF1B2333), width: 2),
border: Border.all(color: surfaceColor, width: 2),
),
child: Column(
children: List.generate(AppConstants.genRanges.length, (i) {
@@ -8,12 +8,14 @@ class GuessSilhouette extends StatelessWidget {
final Pokemon pokemon;
final bool isShiny;
final bool isGuessed;
final Color surfaceColor;
const GuessSilhouette({
super.key,
required this.pokemon,
required this.isShiny,
required this.isGuessed,
required this.surfaceColor,
});
@override
@@ -27,7 +29,7 @@ class GuessSilhouette extends StatelessWidget {
decoration: BoxDecoration(
color: const Color(0xFF3B6EE3),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFF1B2333), width: 8),
border: Border.all(color: surfaceColor, width: 8),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -51,7 +53,7 @@ class GuessSilhouette extends StatelessWidget {
),
),
Container(
color: const Color(0xFF1B2333),
color: surfaceColor,
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(
@@ -10,15 +10,9 @@ class PokedexListHeader extends StatelessWidget {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
color: const Color(0xFF90A4AE),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Icon(Icons.menu, color: Colors.black87),
Text(AppLocalizations.of(context)!.listNational,
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold, letterSpacing: 2)),
const Icon(Icons.search, color: Colors.black87),
],
),
alignment: Alignment.center,
child: Text(AppLocalizations.of(context)!.listNational,
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold, letterSpacing: 2)),
);
}
}
+2 -1
View File
@@ -10,7 +10,8 @@ class PokemonTypeWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
String typeName = formatedTypeName(type);
final lang = Localizations.localeOf(context).languageCode;
String typeName = localizedTypeName(type, lang);
Color typeColor = typeToColor(type);
return Container(
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../../../l10n/app_localizations.dart';
import '../../providers/locale_provider.dart';
/// Sélecteur de langue de l'application (parmi [supportedLocales]).
@@ -14,11 +15,13 @@ class LanguagePicker extends StatelessWidget {
required this.onSelect,
});
static const _names = {'en': 'English', 'fr': 'Français'};
static const _flags = {'en': '🇬🇧', 'fr': '🇫🇷'};
@override
Widget build(BuildContext context) {
final l = AppLocalizations.of(context)!;
final names = {'en': l.langEnglish, 'fr': l.langFrench};
return Column(
children: supportedLocales.map((locale) {
final isSelected = locale.languageCode == selected.languageCode;
@@ -41,7 +44,7 @@ class LanguagePicker extends StatelessWidget {
Text(_flags[locale.languageCode] ?? '', style: const TextStyle(fontSize: 22)),
const SizedBox(width: 16),
Text(
_names[locale.languageCode] ?? locale.languageCode,
names[locale.languageCode] ?? locale.languageCode,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import '../../../l10n/app_localizations.dart';
import '../../providers/theme_provider.dart';
/// Sélecteur de palette de couleurs de l'application.
@@ -9,6 +10,9 @@ class PalettePicker extends StatelessWidget {
@override
Widget build(BuildContext context) {
final l = AppLocalizations.of(context)!;
final paletteNames = [l.palette0, l.palette1, l.palette2, l.palette3, l.palette4];
return Column(
children: List.generate(appPalettes.length, (i) {
final p = appPalettes[i];
@@ -53,7 +57,7 @@ class PalettePicker extends StatelessWidget {
),
const SizedBox(width: 16),
Text(
p.name,
paletteNames[i],
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,