Files
unionflow-mobile-apps/lib/shared/design_system/components/union_stat_widget.dart
dahoud 0abcdcc478 feat(design-system): dark mode adaptatif sur widgets partagés
Pattern AppColors pair (isDark ? AppColors.surfaceDark : AppColors.surface)
appliqué sur :
- UnionStatWidget, UnionBalanceCard, UnionActionButton, UFSectionHeader
- DashboardEventRow, DashboardActivityRow, UnionExportButton
- MiniAvatar (border adaptatif)
- ConfirmationDialog (cancel colors adaptés)
- FileUploadWidget (textSecondary adaptatif)

Les couleurs surface/border/textPrimary/textSecondary hardcodées (light-only)
sont remplacées par les paires *Dark conditionnelles.
Les couleurs sémantiques (error, success, warning, primary) restent inchangées.
2026-04-15 20:13:22 +00:00

86 lines
2.6 KiB
Dart

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,
),
],
),
);
}
}