import 'package:flutter/material.dart'; import '../../../core/constants/design_system.dart'; /// Badge réutilisable pour les posts sociaux. /// /// Design compact et uniforme pour différents types de badges. class SocialBadge extends StatelessWidget { const SocialBadge({ required this.label, this.icon, this.color, this.backgroundColor, this.fontSize = 11, this.padding, super.key, }); final String label; final IconData? icon; final Color? color; final Color? backgroundColor; final double fontSize; final EdgeInsets? padding; @override Widget build(BuildContext context) { final theme = Theme.of(context); final effectiveColor = color ?? theme.colorScheme.onPrimaryContainer; final effectiveBackgroundColor = backgroundColor ?? theme.colorScheme.primaryContainer; return Container( padding: padding ?? const EdgeInsets.symmetric( horizontal: DesignSystem.spacingSm, vertical: DesignSystem.spacingXs, ), decoration: BoxDecoration( color: effectiveBackgroundColor, borderRadius: BorderRadius.circular(DesignSystem.radiusSm), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ if (icon != null) ...[ Icon( icon, size: fontSize + 2, color: effectiveColor, ), const SizedBox(width: 4), ], Text( label, style: TextStyle( fontSize: fontSize, fontWeight: FontWeight.w600, color: effectiveColor, letterSpacing: -0.1, height: 1.2, ), ), ], ), ); } } /// Badge vérifié pour les utilisateurs vérifiés. class VerifiedBadge extends StatelessWidget { const VerifiedBadge({ this.size = 16, super.key, }); final double size; @override Widget build(BuildContext context) { final theme = Theme.of(context); return Tooltip( message: 'Compte vérifié', child: Icon( Icons.verified, size: size, color: theme.colorScheme.primary, ), ); } } /// Badge de catégorie pour les posts. class CategoryBadge extends StatelessWidget { const CategoryBadge({ required this.category, this.icon, super.key, }); final String category; final IconData? icon; @override Widget build(BuildContext context) { final theme = Theme.of(context); return SocialBadge( label: category, icon: icon, backgroundColor: theme.colorScheme.secondaryContainer, color: theme.colorScheme.onSecondaryContainer, fontSize: 10, ); } } /// Badge de statut pour les posts (nouveau, tendance, etc.). class StatusBadge extends StatelessWidget { const StatusBadge({ required this.status, this.icon, super.key, }); final String status; final IconData? icon; @override Widget build(BuildContext context) { final theme = Theme.of(context); Color backgroundColor; Color color; switch (status.toLowerCase()) { case 'nouveau': case 'new': backgroundColor = theme.colorScheme.primaryContainer; color = theme.colorScheme.onPrimaryContainer; break; case 'tendance': case 'trending': backgroundColor = theme.colorScheme.errorContainer; color = theme.colorScheme.onErrorContainer; break; case 'populaire': case 'popular': backgroundColor = theme.colorScheme.tertiaryContainer; color = theme.colorScheme.onTertiaryContainer; break; default: backgroundColor = theme.colorScheme.surfaceVariant; color = theme.colorScheme.onSurfaceVariant; } return SocialBadge( label: status, icon: icon, backgroundColor: backgroundColor, color: color, fontSize: 10, ); } } /// Badge de nombre de médias (images/vidéos). class MediaCountBadge extends StatelessWidget { const MediaCountBadge({ required this.count, this.isVideo = false, super.key, }); final int count; final bool isVideo; @override Widget build(BuildContext context) { final theme = Theme.of(context); return Container( padding: const EdgeInsets.symmetric( horizontal: 6, vertical: 3, ), decoration: BoxDecoration( color: Colors.black.withOpacity(0.7), borderRadius: BorderRadius.circular(DesignSystem.radiusSm), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( isVideo ? Icons.play_circle_outline : Icons.image_outlined, size: 12, color: Colors.white, ), const SizedBox(width: 3), Text( count.toString(), style: const TextStyle( fontSize: 10, fontWeight: FontWeight.w600, color: Colors.white, height: 1.2, ), ), ], ), ); } }