Add sender avatar display and member list enhancements in chat group
This commit is contained in:
@@ -381,15 +381,53 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
|||||||
textColor = isDark ? Colors.white : Colors.black87;
|
textColor = isDark ? Colors.white : Colors.black87;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trouver le membre qui a envoyé le message pour récupérer sa photo
|
||||||
|
final senderMember = widget.group.members.firstWhere(
|
||||||
|
(m) => m.userId == message.senderId,
|
||||||
|
orElse: () => null as dynamic,
|
||||||
|
) as dynamic;
|
||||||
|
|
||||||
return Align(
|
return Align(
|
||||||
alignment: isMe ? Alignment.centerRight : Alignment.centerLeft,
|
alignment: isMe ? Alignment.centerRight : Alignment.centerLeft,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onLongPress: () => _showMessageOptions(context, message, isMe, currentUserId),
|
onLongPress: () => _showMessageOptions(context, message, isMe, currentUserId),
|
||||||
child: Container(
|
child: Padding(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 8,
|
||||||
|
vertical: 4,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: isMe ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
// Avatar du sender (seulement pour les autres messages)
|
||||||
|
if (!isMe) ...[
|
||||||
|
CircleAvatar(
|
||||||
|
radius: 16,
|
||||||
|
backgroundImage: (senderMember != null &&
|
||||||
|
senderMember.profilePictureUrl != null &&
|
||||||
|
senderMember.profilePictureUrl!.isNotEmpty)
|
||||||
|
? NetworkImage(senderMember.profilePictureUrl!)
|
||||||
|
: null,
|
||||||
|
child: (senderMember == null ||
|
||||||
|
senderMember.profilePictureUrl == null ||
|
||||||
|
senderMember.profilePictureUrl!.isEmpty)
|
||||||
|
? Text(
|
||||||
|
message.senderName.isNotEmpty
|
||||||
|
? message.senderName[0].toUpperCase()
|
||||||
|
: '?',
|
||||||
|
style: const TextStyle(fontSize: 12),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
],
|
||||||
|
|
||||||
|
Container(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 4),
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: MediaQuery.of(context).size.width * 0.7,
|
maxWidth: MediaQuery.of(context).size.width * 0.65,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: bubbleColor,
|
color: bubbleColor,
|
||||||
@@ -454,6 +492,9 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -642,11 +683,26 @@ class _ChatGroupContentState extends State<ChatGroupContent> {
|
|||||||
itemCount: widget.group.members.length,
|
itemCount: widget.group.members.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final member = widget.group.members[index];
|
final member = widget.group.members[index];
|
||||||
|
final initials = member.pseudo.isNotEmpty
|
||||||
|
? member.pseudo[0].toUpperCase()
|
||||||
|
: (member.firstName.isNotEmpty
|
||||||
|
? member.firstName[0].toUpperCase()
|
||||||
|
: '?');
|
||||||
|
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: CircleAvatar(
|
leading: CircleAvatar(
|
||||||
child: Text(member.pseudo.substring(0, 1).toUpperCase()),
|
backgroundImage: (member.profilePictureUrl != null &&
|
||||||
|
member.profilePictureUrl!.isNotEmpty)
|
||||||
|
? NetworkImage(member.profilePictureUrl!)
|
||||||
|
: null,
|
||||||
|
child: (member.profilePictureUrl == null || member.profilePictureUrl!.isEmpty)
|
||||||
|
? Text(initials)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
title: Text(member.pseudo),
|
title: Text(member.pseudo),
|
||||||
|
subtitle: member.role == 'admin'
|
||||||
|
? const Text('Administrateur', style: TextStyle(fontSize: 12))
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user