Skip to main content

ChatMessageListVC

Controller that shows list of messages and composer together in the selected channel.

@available(iOSApplicationExtension, unavailable)
open class ChatMessageListVC:
_ViewController,
ThemeProvider,
ChatMessageListScrollOverlayDataSource,
ChatMessageActionsVCDelegate,
ChatMessageContentViewDelegate,
GalleryContentViewDelegate,
GiphyActionContentViewDelegate,
FileActionContentViewDelegate,
LinkPreviewViewDelegate,
UITableViewDataSource,
UITableViewDelegate,
UIGestureRecognizerDelegate,
UIAdaptivePresentationControllerDelegate

Inheritance

_ViewController, FileActionContentViewDelegate, GalleryContentViewDelegate, GiphyActionContentViewDelegate, LinkPreviewViewDelegate, ChatMessageContentViewDelegate, ChatMessageListScrollOverlayDataSource, ChatMessageActionsVCDelegate, ThemeProvider, UIAdaptivePresentationControllerDelegate, UIGestureRecognizerDelegate, UITableViewDataSource, UITableViewDelegate

Properties

dataSource

The object that acts as the data source of the message list.

public weak var dataSource: ChatMessageListVCDataSource?

delegate

The object that acts as the delegate of the message list.

public weak var delegate: ChatMessageListVCDelegate?

client

The root object representing the Stream Chat.

public var client: ChatClient!

router

The router object that handles navigation to other view controllers.

open lazy var router: ChatMessageListRouter 

listView

A View used to display the messages

open private(set) lazy var listView: ChatMessageListView 

dateOverlayView

A View used to display date of currently displayed messages

open private(set) lazy var dateOverlayView: ChatMessageListScrollOverlayView 

typingIndicatorView

A View which displays information about current users who are typing.

open private(set) lazy var typingIndicatorView: TypingIndicatorView = components
.typingIndicatorView
.init()
.withoutAutoresizingMaskConstraints

typingIndicatorViewHeight

The height of the typing indicator view

open private(set) var typingIndicatorViewHeight: CGFloat = 28

isTypingEventsEnabled

A Boolean value indicating whether the typing events are enabled.

open var isTypingEventsEnabled: Bool 

scrollToLatestMessageButton

A button to scroll the collection view to the bottom. Visible when there is unread message and the collection view is not at the bottom already.

open private(set) lazy var scrollToLatestMessageButton: ScrollToLatestMessageButton = components
.scrollToLatestMessageButton
.init()
.withoutAutoresizingMaskConstraints

isScrollToBottomButtonVisible

open var isScrollToBottomButtonVisible: Bool 

Methods

traitCollectionDidChange(_:)

override open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) 

setUp()

override open func setUp() 

setUpLayout()

override open func setUpLayout() 

setUpAppearance()

override open func setUpAppearance() 

cellLayoutOptionsForMessage(at:)

Returns layout options for the message on given indexPath.

open func cellLayoutOptionsForMessage(at indexPath: IndexPath) -> ChatMessageLayoutOptions 

Layout options are used to determine the layout of the message. By default there is one message with all possible layout and layout options determines which parts of the message are visible for the given message.

cellContentClassForMessage(at:)

Returns the content view class for the message at given indexPath

open func cellContentClassForMessage(at indexPath: IndexPath) -> ChatMessageContentView.Type 

attachmentViewInjectorClassForMessage(at:)

Returns the attachment view injector for the message at given indexPath

open func attachmentViewInjectorClassForMessage(at indexPath: IndexPath) -> AttachmentViewInjector.Type? 

setScrollToLatestMessageButton(visible:animated:)

Set the visibility of scrollToLatestMessageButton.

open func setScrollToLatestMessageButton(visible: Bool, animated: Bool = true) 

scrollToLatestMessage()

Action for scrollToLatestMessageButton that scroll to most recent message.

@objc open func scrollToLatestMessage() 

scrollToMostRecentMessage(animated:)

Scrolls to most recent message

open func scrollToMostRecentMessage(animated: Bool = true) 

updateMessages(with:completion:)

Updates the collection view data with given changes.

open func updateMessages(with changes: [ListChange<ChatMessage>], completion: (() -> Void)? = nil) 

handleTap(_:)

Handles tap action on the table view.

@objc open func handleTap(_ gesture: UITapGestureRecognizer) 

Default implementation will dismiss the keyboard if it is open

handleLongPress(_:)

Handles long press action on collection view.

@objc open func handleLongPress(_ gesture: UILongPressGestureRecognizer) 

Default implementation will convert the gesture location to collection view's indexPath and then call selection action on the selected cell.

didSelectMessageCell(at:)

The message cell was select and should show the available message actions.

open func didSelectMessageCell(at indexPath: IndexPath) 

Parameters

  • indexPath: The index path that the message was selected.

showThread(messageId:)

Opens thread detail for given MessageId.

open func showThread(messageId: MessageId) 

showTypingIndicator(typingUsers:)

Shows typing Indicator.

open func showTypingIndicator(typingUsers: [ChatUser]) 

Parameters

  • typingUsers: typing users gotten from channelController

hideTypingIndicator()

Hides typing Indicator.

open func hideTypingIndicator() 

numberOfSections(in:)

open func numberOfSections(in tableView: UITableView) -> Int 

tableView(_:numberOfRowsInSection:)

open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int 

tableView(_:cellForRowAt:)

open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 

tableView(_:willDisplay:forRowAt:)

open func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) 

scrollViewDidScroll(_:)

open func scrollViewDidScroll(_ scrollView: UIScrollView) 

scrollOverlay(_:textForItemAt:)

open func scrollOverlay(
_ overlay: ChatMessageListScrollOverlayView,
textForItemAt indexPath: IndexPath
) -> String?

chatMessageActionsVC(_:message:didTapOnActionItem:)

open func chatMessageActionsVC(
_ vc: ChatMessageActionsVC,
message: ChatMessage,
didTapOnActionItem actionItem: ChatMessageActionItem
)

chatMessageActionsVCDidFinish(_:)

open func chatMessageActionsVCDidFinish(_ vc: ChatMessageActionsVC) 

messageContentViewDidTapOnErrorIndicator(_:)

open func messageContentViewDidTapOnErrorIndicator(_ indexPath: IndexPath?) 

messageContentViewDidTapOnThread(_:)

open func messageContentViewDidTapOnThread(_ indexPath: IndexPath?) 

messageContentViewDidTapOnQuotedMessage(_:)

open func messageContentViewDidTapOnQuotedMessage(_ indexPath: IndexPath?) 

messageContentViewDidTapOnAvatarView(_:)

open func messageContentViewDidTapOnAvatarView(_ indexPath: IndexPath?) 

galleryMessageContentView(at:didTapAttachmentPreview:previews:)

open func galleryMessageContentView(
at indexPath: IndexPath?,
didTapAttachmentPreview attachmentId: AttachmentId,
previews: [GalleryItemPreview]
)

galleryMessageContentView(at:didTakeActionOnUploadingAttachment:)

open func galleryMessageContentView(
at indexPath: IndexPath?,
didTakeActionOnUploadingAttachment attachmentId: AttachmentId
)

didTapOnLinkAttachment(_:at:)

open func didTapOnLinkAttachment(
_ attachment: ChatMessageLinkAttachment,
at indexPath: IndexPath?
)

didTapOnAttachment(_:at:)

open func didTapOnAttachment(
_ attachment: ChatMessageFileAttachment,
at indexPath: IndexPath?
)

didTapOnAttachmentAction(_:at:)

Executes the provided action on the message

open func didTapOnAttachmentAction(
_ action: AttachmentAction,
at indexPath: IndexPath
)

gestureRecognizer(_:shouldReceive:)

open func gestureRecognizer(
_ gestureRecognizer: UIGestureRecognizer,
shouldReceive touch: UITouch
) -> Bool

presentationControllerShouldDismiss(_:)

public func presentationControllerShouldDismiss(_ presentationController: UIPresentationController) -> Bool 

Did you find this page helpful?