getListItem method
Widget
getListItem(
- Conversation conversation,
- CometChatConversationsController controller,
- CometChatTheme theme,
- BuildContext context,
Implementation
Widget getListItem(
Conversation conversation,
CometChatConversationsController controller,
CometChatTheme theme,
BuildContext context) {
User? conversationWithUser;
Group? conversationWithGroup;
if (conversation.conversationWith is User) {
conversationWithUser = conversation.conversationWith as User;
} else {
conversationWithGroup = conversation.conversationWith as Group;
}
return GestureDetector(
onTap: () {
if (conversationWithGroup != null && navigateToGroupScreen != null) {
navigateToGroupScreen!(conversationWithGroup.metadata?['reference']);
}
else if (onItemTap != null) {
onItemTap!(conversation);
controller.activeConversation = conversation.conversationId;
}
else {
controller.onTap(conversation);
_isSelectionOn.value = true;
}
},
onLongPress: () {
if (conversationWithGroup != null && navigateToGroupScreen != null) {
navigateToGroupScreen!(conversationWithGroup.metadata?['reference']);
}
else if (onItemTap != null) {
onItemTap!(conversation);
controller.activeConversation = conversation.conversationId;
}
else {
controller.onTap(conversation);
_isSelectionOn.value = true;
}
},
child: CometChatListItem(
chatConversationItem: chatConversationItem,
unreadMessageCount: conversation.unreadMessageCount ?? 0,
lastMessage: conversation.lastMessage,
lastMessageText: MessagesDataSource().getConversationSubtitleText(conversation, context) ?? '',
id: conversation.conversationId,
status: conversationWithUser?.status != null && conversationWithUser?.status ==
UserStatusConstants.online ? true : false,
avatarName: conversationWithUser?.name ?? conversationWithGroup?.name,
avatarURL: conversationWithUser?.avatar ?? conversationWithGroup?.icon,
title: conversationWithUser?.name ?? conversationWithGroup?.name,
isGroupChat: conversationWithGroup != null,
key: UniqueKey(),
options: options != null
? options!(conversation, controller, context)
: ConversationUtils.getDefaultOptions(
conversation, controller, context, theme),
),
);
}