defaultMessageHeaderBuilder function

Widget defaultMessageHeaderBuilder(
  1. BuildContext context,
  2. MeshDocument thread,
  3. MeshElement message, {
  4. String? localParticipantName,
})

Implementation

Widget defaultMessageHeaderBuilder(BuildContext context, MeshDocument thread, MeshElement message, {String? localParticipantName}) {
  final name = message.getAttribute("author_name") ?? "";
  final createdAt = message.getAttribute("created_at") == null ? DateTime.now() : DateTime.parse(message.getAttribute("created_at"));
  if (_shouldShowAuthorNames(thread: thread, localParticipantName: localParticipantName)) {
    return Container(
      padding: EdgeInsets.only(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);
  }
}