import 'package:flutter/material.dart'; import '../models/pokemon.dart'; import '../components/pokemon_type.dart'; class PokemonDetailPage extends StatefulWidget { const PokemonDetailPage({Key? key}) : super(key: key); @override State createState() => _PokemonDetailPageState(); } class _PokemonDetailPageState extends State { bool _isShiny = false; Widget _buildStatBar(String label, int value, Color color) { // Let's assume max base stat is 255 double 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), ), ), 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(), ), ], ), ), ), const SizedBox(width: 16), SizedBox( width: 40, child: Text( value.toString(), style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 18), textAlign: TextAlign.right, ), ) ], ), ); } @override Widget build(BuildContext context) { final Pokemon pokemon = ModalRoute.of(context)!.settings.arguments as Pokemon; return Scaffold( backgroundColor: const Color(0xFF1B2333), body: SafeArea( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 20.0), child: Container( decoration: BoxDecoration( color: const Color(0xFFD32F2F), borderRadius: BorderRadius.circular(30), border: Border.all(color: const Color(0xFFA12020), width: 4), ), child: SingleChildScrollView( child: Column( children: [ // App Bar / Top Red Padding Container( height: 50, padding: const EdgeInsets.symmetric(horizontal: 16), alignment: Alignment.centerLeft, child: GestureDetector( onTap: () => Navigator.pop(context), child: Container( padding: const EdgeInsets.all(4), decoration: const BoxDecoration( color: Color(0xFFA12020), shape: BoxShape.circle), child: const Icon(Icons.arrow_back, color: Colors.white), ), ), ), // TOP SCREEN Container( margin: const EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( color: const Color(0xFF1B2333), borderRadius: BorderRadius.circular(8), border: Border.all(color: const Color(0xFF1B2333), width: 8), ), child: Container( color: const Color(0xFF90A4AE), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), color: const Color(0xFF1B2333), child: Text( "NO. ${pokemon.id.toString().padLeft(3, '0')}", style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold), ), ), GestureDetector( onTap: () { setState(() { _isShiny = !_isShiny; }); }, child: Container( height: 180, alignment: Alignment.center, color: const Color(0xFF81CCA5).withAlpha(153), // subtle green background behind sprite child: Image.network(_isShiny ? pokemon.shinyImageUrl : pokemon.imageUrl, fit: BoxFit.contain), ), ), Container( color: const Color(0xFF37474F), padding: const EdgeInsets.all(12), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Text( pokemon.formatedName.toUpperCase(), style: const TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.bold, letterSpacing: 2), overflow: TextOverflow.ellipsis, ), ), const SizedBox(width: 8), Row( children: [ PokemonTypeWidget(pokemon.type1), if (pokemon.type2 != null) const SizedBox(width: 4), if (pokemon.type2 != null) PokemonTypeWidget(pokemon.type2!), ], ) ], ), ) ], ), ), ), // HINGE DETAILS const SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Container(height: 6, width: 40, color: const Color(0xFFA12020)), Container(height: 6, width: 40, color: const Color(0xFFA12020)), ], ), const SizedBox(height: 20), // BOTTOM SCREEN Container( margin: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: const Color(0xFF1B2333), borderRadius: BorderRadius.circular(8), ), child: Container( color: const Color(0xFFC8D1D8), padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( "BASE STATS", style: 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), _buildStatBar("HP", pokemon.hp, const Color(0xFFE53935)), _buildStatBar("ATK", pokemon.atk, const Color(0xFFFB8C00)), _buildStatBar("DEF", pokemon.def, const Color(0xFFFDD835)), _buildStatBar("SPD", pokemon.spd, const Color(0xFF1E88E5)), const SizedBox(height: 24), // DESCRIPTION BOX Container( width: double.infinity, padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: const Color(0xFFE2EBF0), border: Border.all(color: Colors.grey[400]!), ), child: Text( pokemon.description != null && pokemon.description!.isNotEmpty ? '"${pokemon.description!}"' : '"No description available for this Pokémon."', style: const TextStyle(fontSize: 16, height: 1.5), ), ), const SizedBox(height: 16), // DECORATIVE LIGHTS Row( children: [ Container( width: 24, height: 24, decoration: BoxDecoration( color: const Color(0xFF1E88E5), shape: BoxShape.circle, border: Border.all(color: const Color(0xFF1565C0), width: 2), ), ), const SizedBox(width: 8), Container( width: 24, height: 24, decoration: BoxDecoration( color: const Color(0xFFFFB300), shape: BoxShape.circle, border: Border.all(color: const Color(0xFFF57C00), width: 2), ), ), const Spacer(), Row( children: [ 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))), ], ) ], ) ], ), ), ), const SizedBox(height: 30), // BOTTOM DOTS Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Container(width: 6, height: 6, decoration: const BoxDecoration(color: Color(0xFFA12020), shape: BoxShape.circle)), const SizedBox(width: 4), Container(width: 6, height: 6, decoration: const BoxDecoration(color: Color(0xFFA12020), shape: BoxShape.circle)), const SizedBox(width: 4), Container(width: 6, height: 6, decoration: const BoxDecoration(color: Color(0xFFA12020), shape: BoxShape.circle)), const SizedBox(width: 4), Container(width: 6, height: 6, decoration: const BoxDecoration(color: Color(0xFFA12020), shape: BoxShape.circle)), ], ), const SizedBox(height: 20), ], ), ), ), ), ), ); } }