80 lines
2.2 KiB
Dart
80 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../widgets/conversations_list.dart';
|
|
import '../widgets/chat_screen.dart';
|
|
|
|
/// Page principale du module chat
|
|
///
|
|
/// Cette page sert de point d'entrée pour le module chat
|
|
/// et gère la navigation entre les conversations
|
|
|
|
class ChatPage extends StatefulWidget {
|
|
const ChatPage({super.key});
|
|
|
|
@override
|
|
State<ChatPage> createState() => _ChatPageState();
|
|
}
|
|
|
|
class _ChatPageState extends State<ChatPage> {
|
|
String? _selectedConversationId;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final isLargeScreen = MediaQuery.of(context).size.width > 900;
|
|
|
|
if (isLargeScreen) {
|
|
// Vue desktop (séparée en deux panneaux)
|
|
return Scaffold(
|
|
body: Row(
|
|
children: [
|
|
// Liste des conversations à gauche
|
|
SizedBox(
|
|
width: 300,
|
|
child: ConversationsList(
|
|
onConversationSelected: (conversation) {
|
|
setState(() {
|
|
_selectedConversationId = 'conversation-id'; // TODO: obtenir l'ID de la conversation
|
|
});
|
|
},
|
|
),
|
|
),
|
|
const VerticalDivider(width: 1),
|
|
// Conversation sélectionnée à droite
|
|
Expanded(
|
|
child: _selectedConversationId != null
|
|
? ChatScreen(conversationId: _selectedConversationId!)
|
|
: const Center(child: Text('Sélectionnez une conversation')),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else {
|
|
// Vue mobile
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Chat'),
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.add),
|
|
onPressed: () {
|
|
// TODO: Créer une nouvelle conversation
|
|
},
|
|
),
|
|
],
|
|
),
|
|
body: ConversationsList(
|
|
onConversationSelected: (conversation) {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => ChatScreen(
|
|
conversationId: 'conversation-id', // TODO: obtenir l'ID de la conversation
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|