import 'package:flutter/material.dart'; import '../tokens/unionflow_colors.dart'; /// Carte premium affichant la vue unifiée "Compte Adhérent" du membre. class UnionUnifiedAccountCard extends StatelessWidget { final String numeroMembre; final String organisationNom; final String soldeTotal; final String capaciteEmprunt; final String epargneBloquee; final double engagementRate; // 0.0 to 1.0 final VoidCallback? onDetailsTap; const UnionUnifiedAccountCard({ super.key, required this.numeroMembre, required this.organisationNom, required this.soldeTotal, required this.capaciteEmprunt, required this.epargneBloquee, required this.engagementRate, this.onDetailsTap, }); @override Widget build(BuildContext context) { return Container( width: double.infinity, decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ UnionFlowColors.unionGreen, UnionFlowColors.unionGreen.withOpacity(0.85), ], ), borderRadius: BorderRadius.circular(12), ), child: Stack( children: [ // Pattern décoratif subtil (fond) Positioned( right: -20, bottom: -20, child: Icon( Icons.account_balance_wallet, size: 150, color: Colors.white.withOpacity(0.1), ), ), Padding( padding: const EdgeInsets.all(12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // En-tête : Organisation + Numéro Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( organisationNom.toUpperCase(), style: const TextStyle( color: Colors.white70, fontSize: 10, fontWeight: FontWeight.w700, letterSpacing: 1.2, ), ), const SizedBox(height: 4), Text( 'COMPTE ADHÉRENT', style: TextStyle( color: Colors.white.withOpacity(0.95), fontSize: 14, fontWeight: FontWeight.w800, ), ), ], ), ), Container( padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), decoration: BoxDecoration( color: Colors.white.withOpacity(0.2), borderRadius: BorderRadius.circular(8), border: Border.all(color: Colors.white30), ), child: Text( numeroMembre, style: const TextStyle( color: Colors.white, fontSize: 12, fontWeight: FontWeight.w700, fontFamily: 'Courier', // Look like a card number ), ), ), ], ), const SizedBox(height: 16), // Solde Total Disponible const Text( 'Solde Total Disponible', style: TextStyle( color: Colors.white70, fontSize: 12, fontWeight: FontWeight.w500, ), ), const SizedBox(height: 4), FittedBox( fit: BoxFit.scaleDown, child: Text( soldeTotal, style: const TextStyle( color: Colors.white, fontSize: 24, fontWeight: FontWeight.w800, letterSpacing: -0.5, ), ), ), const SizedBox(height: 16), // Grille de détails Row( children: [ _buildSubStat('Capacité Emprunt', capaciteEmprunt, Icons.rocket_launch, UnionFlowColors.gold), const SizedBox(width: 16), _buildSubStat('Épargne Bloquée', epargneBloquee, Icons.lock_clock, Colors.white60), ], ), const SizedBox(height: 10), // Barre d'engagement Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const Text( 'Taux d\'engagement (Cotisations)', style: TextStyle(color: Colors.white70, fontSize: 10, fontWeight: FontWeight.w600), ), Text( '${(engagementRate * 100).toInt()}%', style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.w800), ), ], ), const SizedBox(height: 8), ClipRRect( borderRadius: BorderRadius.circular(4), child: LinearProgressIndicator( value: engagementRate, backgroundColor: Colors.white10, valueColor: const AlwaysStoppedAnimation(UnionFlowColors.gold), minHeight: 6, ), ), ], ), ], ), ), ], ), ); } Widget _buildSubStat(String label, String value, IconData icon, Color iconColor) { return Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Icon(icon, size: 12, color: iconColor), const SizedBox(width: 4), Text( label, style: const TextStyle(color: Colors.white70, fontSize: 10, fontWeight: FontWeight.w600), ), ], ), const SizedBox(height: 4), Text( value, style: const TextStyle( color: Colors.white, fontSize: 16, fontWeight: FontWeight.w700, ), ), ], ), ); } }