import 'package:flutter/material.dart'; import '../tokens/app_colors.dart'; /// Widget de statistique compacte — style identique à _buildKpiCell du super admin /// Fond adaptatif dark/light via AppColors, bordure gauche colorée, icône + valeur + label /// [compact] réduit le padding vertical pour les grilles très plates class UnionStatWidget extends StatelessWidget { final String label; final String value; final IconData icon; final Color color; final String? trend; final bool? isTrendUp; /// Mode ultra-compact : padding vertical réduit, espacement minimal final bool compact; const UnionStatWidget({ super.key, required this.label, required this.value, required this.icon, required this.color, this.trend, this.isTrendUp, this.compact = false, }); @override Widget build(BuildContext context) { final isDark = Theme.of(context).brightness == Brightness.dark; final bgColor = isDark ? AppColors.surfaceDark : AppColors.surface; final labelColor = isDark ? AppColors.textSecondaryDark : AppColors.textSecondary; final EdgeInsets pad = compact ? const EdgeInsets.symmetric(horizontal: 8, vertical: 5) : const EdgeInsets.all(6); return Container( padding: pad, decoration: BoxDecoration( color: bgColor, borderRadius: BorderRadius.circular(10), border: Border(left: BorderSide(color: color, width: 3)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(icon, size: 13, color: color), if (trend != null) ...[ const Spacer(), Text( trend!, style: TextStyle(fontSize: 8, fontWeight: FontWeight.w700, color: color), ), ], ], ), SizedBox(height: compact ? 2 : 4), Text( value, style: TextStyle( fontSize: 17, fontWeight: FontWeight.w800, color: color, letterSpacing: -0.3, height: 1, ), ), SizedBox(height: compact ? 1 : 2), Text( label, style: TextStyle(fontSize: 9, fontWeight: FontWeight.w500, color: labelColor), maxLines: 1, overflow: TextOverflow.ellipsis, ), ], ), ); } }