import 'package:flutter/material.dart'; import '../design_system/tokens/app_colors.dart'; import '../design_system/tokens/app_typography.dart'; /// UnionFlow Mobile - Composant DRY : ActionRow /// Centralise les interactions (J'aime, Commenter, Partager, etc.) sous une barre compacte. class ActionRow extends StatelessWidget { final int? likesCount; final int? commentsCount; final VoidCallback? onLike; final VoidCallback? onComment; final VoidCallback? onShare; final bool isLiked; // Permet de teinter l'icône Like // Peut être personnalisé pour des actions spécifiques (ex: Payer) final String? customActionLabel; final VoidCallback? onCustomAction; final IconData? customActionIcon; const ActionRow({ Key? key, this.likesCount, this.commentsCount, this.onLike, this.onComment, this.onShare, this.isLiked = false, this.customActionLabel, this.onCustomAction, this.customActionIcon, }) : super(key: key); @override Widget build(BuildContext context) { final isDark = Theme.of(context).brightness == Brightness.dark; final iconColor = isDark ? AppColors.textSecondaryDark : AppColors.textSecondaryLight; return Padding( padding: const EdgeInsets.only(top: 8.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // Actions standards (Like/Comment/Share) Row( children: [ if (onLike != null) _buildActionIcon( icon: isLiked ? Icons.favorite : Icons.favorite_border, color: isLiked ? AppColors.error : iconColor, count: likesCount, onTap: onLike!, ), if (onLike != null && onComment != null) const SizedBox(width: 24), if (onComment != null) _buildActionIcon( icon: Icons.chat_bubble_outline, color: iconColor, count: commentsCount, onTap: onComment!, ), if (onComment != null && onShare != null) const SizedBox(width: 24), if (onShare != null) _buildActionIcon( icon: Icons.share_outlined, color: iconColor, onTap: onShare!, ), ], ), // Action personnalisée à droite (ex: Payer la cotisation) if (onCustomAction != null) GestureDetector( onTap: onCustomAction, child: Container( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), decoration: BoxDecoration( color: AppColors.primaryGreen.withOpacity(0.1), borderRadius: BorderRadius.circular(12), ), child: Row( children: [ if (customActionIcon != null) ...[ Icon(customActionIcon, size: 14, color: AppColors.primaryGreen), const SizedBox(width: 4), ], Text( customActionLabel ?? '', style: AppTypography.badgeText.copyWith(color: AppColors.primaryGreen), ), ], ), ), ), ], ), ); } Widget _buildActionIcon({ required IconData icon, required Color color, required VoidCallback onTap, int? count, }) { return GestureDetector( onTap: onTap, behavior: HitTestBehavior.opaque, child: Row( children: [ Icon(icon, size: 16, color: color), if (count != null && count > 0) ...[ const SizedBox(width: 4), Text( count.toString(), style: AppTypography.subtitleSmall.copyWith(color: color), ), ] ], ), ); } }