79 lines
2.0 KiB
Dart
79 lines
2.0 KiB
Dart
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<dynamic>? 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<ConversationsList> createState() => _ConversationsListState();
|
|
}
|
|
|
|
class _ConversationsListState extends State<ConversationsList> {
|
|
late List<dynamic> _conversations;
|
|
bool _isLoading = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadConversations();
|
|
}
|
|
|
|
Future<void> _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),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|