import 'package:flutter/material.dart'; /// Widget d'interaction avec un événement (réagir, commenter, partager). /// /// Ce widget affiche des boutons compacts pour interagir avec un événement, /// avec compteurs et design moderne. /// /// **Usage:** /// ```dart /// EventInteractionRow( /// onReact: () => handleReact(), /// onComment: () => handleComment(), /// onShare: () => handleShare(), /// reactionsCount: 10, /// commentsCount: 5, /// sharesCount: 2, /// ) /// ``` class EventInteractionRow extends StatelessWidget { const EventInteractionRow({ required this.onReact, required this.onComment, required this.onShare, required this.reactionsCount, required this.commentsCount, required this.sharesCount, super.key, }); final VoidCallback onReact; final VoidCallback onComment; final VoidCallback onShare; final int reactionsCount; final int commentsCount; final int sharesCount; @override Widget build(BuildContext context) { final theme = Theme.of(context); return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ _buildInteractionButton( context, theme, icon: Icons.thumb_up_outlined, label: 'Réagir', count: reactionsCount, onPressed: onReact, ), _buildInteractionButton( context, theme, icon: Icons.comment_outlined, label: 'Commenter', count: commentsCount, onPressed: onComment, ), _buildInteractionButton( context, theme, icon: Icons.share_outlined, label: 'Partager', count: sharesCount, onPressed: onShare, ), ], ); } /// Construit un bouton d'interaction compact. Widget _buildInteractionButton( BuildContext context, ThemeData theme, { required IconData icon, required String label, required int count, required VoidCallback onPressed, }) { return InkWell( onTap: onPressed, borderRadius: BorderRadius.circular(8), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( icon, size: 18, color: theme.colorScheme.primary, ), const SizedBox(width: 4), Text( _formatCount(count), style: theme.textTheme.bodySmall?.copyWith( color: theme.colorScheme.onSurface.withOpacity(0.7), fontWeight: FontWeight.w500, ), ), ], ), ), ); } /// Formate le compteur avec format compact. String _formatCount(int count) { if (count >= 1000) { return '${(count / 1000).toStringAsFixed(1)}k'; } return count.toString(); } }