70 lines
2.2 KiB
Dart
70 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Bulle de message
|
|
///
|
|
/// Ce widget affiche un message dans une conversation
|
|
/// avec les informations associées
|
|
|
|
class MessageBubble extends StatelessWidget {
|
|
final dynamic message; // TODO: Remplacer par MessageModel
|
|
final bool showSenderInfo;
|
|
final bool showTimestamp;
|
|
final bool showStatus;
|
|
final bool isAnnouncement;
|
|
final double maxWidth;
|
|
|
|
const MessageBubble({
|
|
super.key,
|
|
required this.message,
|
|
this.showSenderInfo = true,
|
|
this.showTimestamp = true,
|
|
this.showStatus = true,
|
|
this.isAnnouncement = false,
|
|
this.maxWidth = 300,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (showSenderInfo) CircleAvatar(child: Text('S')),
|
|
Expanded(
|
|
child: Container(
|
|
constraints: BoxConstraints(maxWidth: maxWidth),
|
|
margin: const EdgeInsets.only(left: 8),
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: isAnnouncement ? Colors.orange.shade100 : Colors.blue.shade100,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (showSenderInfo)
|
|
Text(
|
|
'Expéditeur',
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
Text('Contenu du message...'),
|
|
if (showTimestamp || showStatus)
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
if (showTimestamp) Text('12:34', style: TextStyle(fontSize: 12)),
|
|
if (showStatus) const SizedBox(width: 4),
|
|
if (showStatus) Icon(Icons.check, size: 16),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|