import 'package:flutter/material.dart'; import '../../../core/constants/colors.dart'; import '../../../data/models/social_post_model.dart'; import '../../widgets/social_header_widget.dart'; import '../../widgets/social_interaction_row.dart'; import '../../widgets/swipe_background.dart'; // Import du widget de swipe class SocialCard extends StatelessWidget { final SocialPost post; final VoidCallback onLike; final VoidCallback onComment; final VoidCallback onShare; final VoidCallback onDeletePost; final VoidCallback onEditPost; const SocialCard({ Key? key, required this.post, required this.onLike, required this.onComment, required this.onShare, required this.onDeletePost, required this.onEditPost, }) : super(key: key); @override Widget build(BuildContext context) { return Dismissible( key: ValueKey(post.postText), direction: DismissDirection.endToStart, onDismissed: (direction) { onDeletePost(); }, background: SwipeBackground( color: Colors.red, icon: Icons.delete, label: 'Supprimer', ), child: Card( color: AppColors.cardColor, margin: const EdgeInsets.symmetric(vertical: 10.0), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.0)), child: Padding( padding: const EdgeInsets.all(12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SocialHeaderWidget( post: post, onEditPost: () { print('Modifier le post'); }, menuKey: GlobalKey(), menuContext: context, onClosePost: () { print('Close post'); }, ), const SizedBox(height: 8), Text ( post.postText, style: TextStyle( color: AppColors.textSecondary, fontSize: 14, ), ), const SizedBox(height: 8), if (post.postImage.isNotEmpty) ClipRRect( borderRadius: BorderRadius.circular(8), child: Image.asset(post.postImage, fit: BoxFit.cover), ), const SizedBox(height: 8), Row( children: post.tags .map((tag) => Padding( padding: const EdgeInsets.only(right: 8), child: Text( tag, style: TextStyle( color: AppColors.accentColor, fontSize: 12, ), ), )) .toList(), ), const SizedBox(height: 8), SocialInteractionRow( post: post, onLike: onLike, onComment: onComment, onShare: onShare, ), ], ), ), ), ); } }