getDefaultItem method
Widget
getDefaultItem(
- Conversation conversation,
- CometChatConversationsController controller,
- CometChatTheme theme,
- BuildContext context,
Implementation
Widget getDefaultItem(
Conversation conversation,
CometChatConversationsController controller,
CometChatTheme theme,
BuildContext context) {
Widget? subtitle;
Widget? tail;
Color? backgroundColor;
Widget? icon;
if (subtitleView != null) {
subtitle = subtitleView!(context, conversation);
} else {
subtitle = getDefaultSubtitle(theme,
context: context,
conversation: conversation,
showTypingIndicator:
controller.typingMap.containsKey(conversation.conversationId),
hideThreadIndicator: controller.getHideThreadIndicator(conversation),
controller: controller);
}
if (tailView != null) {
tail = tailView!(conversation);
} else {
tail = Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: getTime(theme, conversation)),
Flexible(child: getUnreadCount(theme, conversation)),
],
);
}
User? conversationWithUser;
Group? conversationWithGroup;
if (conversation.conversationWith is User) {
conversationWithUser = conversation.conversationWith as User;
} else {
conversationWithGroup = conversation.conversationWith as Group;
}
StatusIndicatorUtils statusIndicatorUtils =
StatusIndicatorUtils.getStatusIndicatorFromParams(
isSelected:
controller.selectionMap[conversation.conversationId] != null,
theme: theme,
user: conversationWithUser,
group: conversationWithGroup,
onlineStatusIndicatorColor: conversationsStyle.onlineStatusColor ??
theme.palette.getSuccess(),
privateGroupIcon: privateGroupIcon,
protectedGroupIcon: protectedGroupIcon,
privateGroupIconBackground:
conversationsStyle.privateGroupIconBackground,
protectedGroupIconBackground:
conversationsStyle.protectedGroupIconBackground,
disableUsersPresence: disableUsersPresence);
backgroundColor = statusIndicatorUtils.statusIndicatorColor;
icon = statusIndicatorUtils.icon;
return GestureDetector(
onTap: () {
if (activateSelection == ActivateSelection.onClick ||
(activateSelection == ActivateSelection.onLongClick &&
controller.selectionMap.isNotEmpty) &&
!(selectionMode == null ||
selectionMode == SelectionMode.none)) {
controller.onTap(conversation);
if (controller.selectionMap.isEmpty) {
_isSelectionOn.value = false;
} else if (activateSelection == ActivateSelection.onClick &&
controller.selectionMap.isNotEmpty &&
_isSelectionOn.value == false) {
_isSelectionOn.value = true;
}
} else if (onItemTap != null) {
onItemTap!(conversation);
controller.activeConversation = conversation.conversationId;
}
},
onLongPress: () {
if (activateSelection == ActivateSelection.onLongClick &&
controller.selectionMap.isEmpty &&
!(selectionMode == null || selectionMode == SelectionMode.none)) {
controller.onTap(conversation);
_isSelectionOn.value = true;
} else if (onItemLongPress != null) {
onItemLongPress!(conversation);
controller.activeConversation = conversation.conversationId;
}
},
child: CometChatListItem(
id: conversation.conversationId,
avatarName: conversationWithUser?.name ?? conversationWithGroup?.name,
avatarURL: conversationWithUser?.avatar ?? conversationWithGroup?.icon,
title: conversationWithUser?.name ?? conversationWithGroup?.name,
key: UniqueKey(),
subtitleView: subtitle,
tailView: tail,
avatarStyle: avatarStyle ?? const AvatarStyle(),
statusIndicatorColor: backgroundColor,
statusIndicatorIcon: icon,
statusIndicatorStyle:
statusIndicatorStyle ?? const StatusIndicatorStyle(),
theme: theme,
hideSeparator: hideSeparator,
style: ListItemStyle(
background: listItemStyle?.background ?? Colors.transparent,
titleStyle: listItemStyle?.titleStyle ??
TextStyle(
fontSize: theme.typography.name.fontSize,
fontWeight: theme.typography.name.fontWeight,
fontFamily: theme.typography.name.fontFamily,
color: theme.palette.getAccent()),
height: listItemStyle?.height ?? 72,
border: listItemStyle?.border,
borderRadius: listItemStyle?.borderRadius,
gradient: listItemStyle?.gradient,
separatorColor: listItemStyle?.separatorColor,
width: listItemStyle?.width,
margin: listItemStyle?.margin,
padding: listItemStyle?.padding,
),
options: options != null
? options!(conversation, controller, context)
: ConversationUtils.getDefaultOptions(
conversation, controller, context, theme),
),
);
}