From b1f67d3daab6e1f2fe4e109a29c4e949a3d5358b Mon Sep 17 00:00:00 2001 From: Maxiwere45 Date: Tue, 9 Jun 2026 10:57:23 +0200 Subject: [PATCH] feat(presentation): add type colors helper Co-Authored-By: Claude Opus 4.8 --- lib/presentation/theme/type_colors.dart | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/presentation/theme/type_colors.dart diff --git a/lib/presentation/theme/type_colors.dart b/lib/presentation/theme/type_colors.dart new file mode 100644 index 0000000..59e7d2c --- /dev/null +++ b/lib/presentation/theme/type_colors.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import '../../domain/entities/pokemon.dart'; + +/// Couleur d'affichage associée à un type de Pokémon. +Color typeToColor(PokemonType type) { + final Map map = { + PokemonType.normal: Colors.white, + PokemonType.fire: Colors.red, + PokemonType.water: Colors.blue, + PokemonType.electric: Colors.yellow, + PokemonType.grass: Colors.green, + PokemonType.ice: Colors.cyan, + PokemonType.fighting: Colors.orange, + PokemonType.poison: Colors.purple, + PokemonType.ground: Colors.brown, + PokemonType.flying: Colors.indigo, + PokemonType.psychic: Colors.pink, + PokemonType.bug: Colors.lightGreen, + PokemonType.rock: Colors.grey, + PokemonType.ghost: Colors.indigo, + PokemonType.dragon: Colors.indigo, + PokemonType.dark: Colors.black45, + PokemonType.steel: Colors.grey.shade600, + PokemonType.fairy: Colors.pinkAccent, + PokemonType.unknown: Colors.transparent, + PokemonType.shadow: Colors.transparent, + }; + return map[type] ?? Colors.transparent; +} + +/// Nom du type avec une majuscule initiale. +String formatedTypeName(PokemonType type) { + final typeName = type.name; + return typeName[0].toUpperCase() + typeName.substring(1); +}