121 lines
3.6 KiB
Dart
121 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../tokens/unionflow_colors.dart';
|
|
|
|
/// Carte identité utilisateur — header uniforme pour tous les dashboards
|
|
/// Gradient coloré + initiales + nom + sous-titre + badge rôle
|
|
class UserIdentityCard extends StatelessWidget {
|
|
final String initials;
|
|
final String name;
|
|
final String subtitle;
|
|
final String badgeLabel;
|
|
final Gradient gradient;
|
|
final Color accentColor;
|
|
|
|
/// true = fond clair → texte sombre, badge avec fond coloré
|
|
/// false (défaut) = fond sombre → texte blanc, badge blanc + texte coloré
|
|
final bool lightBackground;
|
|
|
|
/// Afficher la bordure supérieure colorée (accentColor)
|
|
final bool showTopBorder;
|
|
|
|
const UserIdentityCard({
|
|
super.key,
|
|
required this.initials,
|
|
required this.name,
|
|
required this.subtitle,
|
|
required this.badgeLabel,
|
|
required this.gradient,
|
|
required this.accentColor,
|
|
this.lightBackground = false,
|
|
this.showTopBorder = true,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final textColor =
|
|
lightBackground ? UnionFlowColors.textPrimary : Colors.white;
|
|
final subtitleColor = lightBackground
|
|
? UnionFlowColors.textSecondary
|
|
: Colors.white.withOpacity(0.85);
|
|
final avatarBg = lightBackground
|
|
? accentColor.withOpacity(0.15)
|
|
: Colors.white.withOpacity(0.25);
|
|
final avatarTextColor = lightBackground ? accentColor : Colors.white;
|
|
final badgeBg = lightBackground ? accentColor : Colors.white;
|
|
final badgeTextColor = lightBackground ? Colors.white : accentColor;
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
decoration: BoxDecoration(
|
|
gradient: gradient,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: showTopBorder
|
|
? Border(top: BorderSide(color: accentColor, width: 3))
|
|
: null,
|
|
boxShadow: showTopBorder
|
|
? [
|
|
BoxShadow(
|
|
color: accentColor.withOpacity(0.25),
|
|
blurRadius: 10,
|
|
offset: const Offset(0, 3),
|
|
)
|
|
]
|
|
: null,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
CircleAvatar(
|
|
radius: 20,
|
|
backgroundColor: avatarBg,
|
|
child: Text(
|
|
initials,
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w700,
|
|
color: avatarTextColor,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
name,
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
fontWeight: FontWeight.w700,
|
|
color: textColor,
|
|
),
|
|
),
|
|
const SizedBox(height: 3),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(fontSize: 11, color: subtitleColor),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
|
decoration: BoxDecoration(
|
|
color: badgeBg,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Text(
|
|
badgeLabel,
|
|
style: TextStyle(
|
|
fontSize: 9,
|
|
fontWeight: FontWeight.w800,
|
|
color: badgeTextColor,
|
|
letterSpacing: 0.8,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|