import 'package:flutter/material.dart'; /// Liste des conversations /// /// Ce widget affiche la liste des conversations de l'utilisateur /// avec leurs derniers messages et statuts class ConversationsList extends StatefulWidget { final List? conversations; final bool loadFromHive; final Function(dynamic)? onConversationSelected; final bool showLastMessage; final bool showUnreadCount; final bool showAnnouncementBadge; final bool showPinnedFirst; final Widget? emptyStateWidget; const ConversationsList({ super.key, this.conversations, this.loadFromHive = true, this.onConversationSelected, this.showLastMessage = true, this.showUnreadCount = true, this.showAnnouncementBadge = true, this.showPinnedFirst = true, this.emptyStateWidget, }); @override State createState() => _ConversationsListState(); } class _ConversationsListState extends State { late List _conversations; bool _isLoading = true; @override void initState() { super.initState(); _loadConversations(); } Future _loadConversations() async { if (widget.loadFromHive) { // TODO: Charger depuis Hive } else { _conversations = widget.conversations ?? []; } setState(() { _isLoading = false; }); } @override Widget build(BuildContext context) { if (_isLoading) { return const Center(child: CircularProgressIndicator()); } if (_conversations.isEmpty) { return widget.emptyStateWidget ?? const Center(child: Text('Aucune conversation')); } return ListView.builder( itemCount: _conversations.length, itemBuilder: (context, index) { final conversation = _conversations[index]; // TODO: Créer le widget de conversation return ListTile( title: Text('Conversation ${index + 1}'), subtitle: const Text('Derniers messages...'), onTap: () => widget.onConversationSelected?.call(conversation), ); }, ); } }