defaultMessageHeaderBuilder function
Widget
defaultMessageHeaderBuilder(
- BuildContext context,
- MeshDocument thread,
- MeshElement message
Implementation
Widget defaultMessageHeaderBuilder(BuildContext context, MeshDocument thread, MeshElement message) {
final name = message.attributes["author_name"] ?? "";
final createdAt = message.attributes["created_at"] == null ? DateTime.now() : DateTime.parse(message.attributes["created_at"]);
final members = thread.root.getElementsByTagName("members").firstOrNull?.getElementsByTagName("member") ?? [];
if (members.length > 2) {
return Container(
padding: EdgeInsets.only(top: 16, left: 8, right: 8),
width: ((message.getAttribute("text") as String?)?.isEmpty ?? true) ? 250 : double.infinity,
child: SelectionArea(
child: Row(
children: [
Text(
name.split("@").first,
style: ShadTheme.of(context).textTheme.small.copyWith(color: ShadTheme.of(context).colorScheme.foreground),
overflow: TextOverflow.ellipsis,
),
Spacer(),
Text(
timeAgo(createdAt),
style: ShadTheme.of(context).textTheme.small.copyWith(color: ShadTheme.of(context).colorScheme.mutedForeground),
overflow: TextOverflow.ellipsis,
),
],
),
),
);
} else {
return SizedBox(height: 0);
}
}