183 lines
5.9 KiB
Dart
183 lines
5.9 KiB
Dart
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 localisée et éléments décoratifs.
|
|
class PokemonStatsPanel extends ConsumerWidget {
|
|
final Pokemon pokemon;
|
|
final Color surfaceColor;
|
|
final String? descriptionOverride;
|
|
|
|
const PokemonStatsPanel({
|
|
super.key,
|
|
required this.pokemon,
|
|
required this.surfaceColor,
|
|
this.descriptionOverride,
|
|
});
|
|
|
|
@override
|
|
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: surfaceColor,
|
|
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: [
|
|
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: "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)),
|
|
const SizedBox(height: 24),
|
|
Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFE2EBF0),
|
|
border: Border.all(color: Colors.grey[400]!),
|
|
),
|
|
child: Text(
|
|
description != null && description.isNotEmpty
|
|
? '"$description"'
|
|
: '"${l.noDescription}"',
|
|
style: const TextStyle(fontSize: 16, height: 1.5),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
_DecorativeLights(accentColor: surfaceColor),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _StatBar extends StatelessWidget {
|
|
final String label;
|
|
final int value;
|
|
final Color color;
|
|
const _StatBar({required this.label, required this.value, required this.color});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
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))),
|
|
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),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _DecorativeLights extends StatelessWidget {
|
|
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: accentColor,
|
|
shape: BoxShape.circle,
|
|
border: Border.all(color: dark, 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))),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|