getTime method

Widget getTime(
  1. CometChatTheme theme,
  2. Conversation conversation
)

Implementation

Widget getTime(CometChatTheme theme, Conversation conversation) {
  DateTime? lastMessageTime =
      conversation.lastMessage?.updatedAt ?? conversation.lastMessage?.sentAt;
  if (lastMessageTime == null) return const SizedBox();

  String? customDateString;

  if (datePattern != null) {
    customDateString = datePattern!(conversation);
  }

  return CometChatDate(
    date: lastMessageTime,
    style: DateStyle(
        background: dateStyle?.background ?? theme.palette.getBackground(),
        textStyle: dateStyle?.textStyle ??
            TextStyle(
                color: theme.palette.getAccent500(),
                fontSize: theme.typography.subtitle1.fontSize,
                fontWeight: theme.typography.subtitle1.fontWeight,
                fontFamily: theme.typography.subtitle1.fontFamily),
        border: dateStyle?.border ??
            Border.all(color: theme.palette.getBackground(), width: 0),
        borderRadius: dateStyle?.borderRadius,
        contentPadding: dateStyle?.contentPadding,
        gradient: dateStyle?.gradient,
        height: dateStyle?.height,
        isTransparentBackground: dateStyle?.isTransparentBackground,
        width: dateStyle?.width),
    customDateString: customDateString,
    pattern: DateTimePattern.dayDateTimeFormat,
  );
}