104 lines
3.1 KiB
Dart
104 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../../data/models/social_post_model.dart';
|
|
import 'social_card.dart'; // Import de la SocialCard
|
|
|
|
class SocialContent extends StatefulWidget {
|
|
const SocialContent({super.key});
|
|
|
|
@override
|
|
_SocialContentState createState() => _SocialContentState();
|
|
}
|
|
|
|
class _SocialContentState extends State<SocialContent> {
|
|
final List<SocialPost> _posts = [
|
|
SocialPost(
|
|
userName: 'John Doe',
|
|
userImage: 'lib/assets/images/profile_picture.png',
|
|
postText: 'Une belle journée au parc avec des amis ! 🌳🌞',
|
|
postImage: 'lib/assets/images/placeholder.png',
|
|
likes: 12,
|
|
comments: 4,
|
|
badges: ['Explorer', 'Photographe'],
|
|
tags: ['#Nature', '#FunDay'],
|
|
shares: 25,
|
|
),
|
|
SocialPost(
|
|
userName: 'Jane Smith',
|
|
userImage: 'lib/assets/images/profile_picture.png',
|
|
postText: 'Mon nouveau chat est tellement mignon 🐱',
|
|
postImage: 'lib/assets/images/placeholder.png',
|
|
likes: 30,
|
|
comments: 8,
|
|
badges: ['Animal Lover', 'Partageur'],
|
|
tags: ['#Chat', '#Cuteness'],
|
|
shares: 25,
|
|
),
|
|
SocialPost(
|
|
userName: 'Alice Brown',
|
|
userImage: 'lib/assets/images/profile_picture.png',
|
|
postText: 'Café du matin avec une vue magnifique ☕️',
|
|
postImage: 'lib/assets/images/placeholder.png',
|
|
likes: 45,
|
|
comments: 15,
|
|
badges: ['Gourmet', 'Partageur'],
|
|
tags: ['#Café', '#MorningVibes'],
|
|
shares: 25,
|
|
),
|
|
];
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView.builder(
|
|
padding: const EdgeInsets.all(16),
|
|
itemCount: _posts.length,
|
|
itemBuilder: (context, index) {
|
|
final post = _posts[index];
|
|
return SocialCard(
|
|
post: post,
|
|
onLike: () {
|
|
setState(() {
|
|
_posts[index] = SocialPost(
|
|
userName: post.userName,
|
|
userImage: post.userImage,
|
|
postText: post.postText,
|
|
postImage: post.postImage,
|
|
likes: post.likes + 1,
|
|
comments: post.comments,
|
|
badges: post.badges,
|
|
tags: post.tags,
|
|
shares: post.shares + 1,
|
|
);
|
|
});
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Like ajouté')),
|
|
);
|
|
},
|
|
onComment: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Commentaire ajouté')),
|
|
);
|
|
},
|
|
onShare: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Post partagé')),
|
|
);
|
|
},
|
|
onDeletePost: () {
|
|
setState(() {
|
|
_posts.removeAt(index);
|
|
});
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Post supprimé')),
|
|
);
|
|
},
|
|
onEditPost: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Post modifié')),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|