Skip to main content

composer-vc-properties

content

The content of the composer.

public var content: Content 

mentionSymbol

A symbol that is used to recognise when the user is mentioning a user.

open var mentionSymbol = "@"

commandSymbol

A symbol that is used to recognise when the user is typing a command.

open var commandSymbol = "/"

isCommandsEnabled

A Boolean value indicating whether the commands are enabled.

open var isCommandsEnabled: Bool 

isMentionsEnabled

A Boolean value indicating whether the user mentions are enabled.

open var isMentionsEnabled: Bool 

isAttachmentsEnabled

A Boolean value indicating whether the attachments are enabled.

open var isAttachmentsEnabled: Bool 

mentionAllAppUsers

When enabled mentions search users across the entire app instead of searching

open private(set) lazy var mentionAllAppUsers: Bool = components.mentionAllAppUsers

userSearchController

A controller to search users and that is used to populate the mention suggestions.

open var userSearchController: ChatUserSearchController!

channelController

A controller that manages the channel that the composer is creating content for.

open var channelController: ChatChannelController?

channelConfig

The channel configuration. If it's a new channel, an empty configuration should be created. (Not yet supported right now)

public var channelConfig: ChannelConfig? 

mentionSuggester

The component responsible for mention suggestions.

open lazy var mentionSuggester 

commandSuggester

The component responsible for autocomplete command suggestions.

open lazy var commandSuggester 

composerView

The view of the composer.

open private(set) lazy var composerView: ComposerView = components
.messageComposerView.init()
.withoutAutoresizingMaskConstraints

suggestionsVC

The view controller that shows the suggestions when the user is typing.

open private(set) lazy var suggestionsVC: ChatSuggestionsVC 

attachmentsVC

The view controller that shows the suggestions when the user is typing.

open private(set) lazy var attachmentsVC: AttachmentsPreviewVC 

mediaPickerVC

The view controller for selecting image attachments.

open private(set) lazy var mediaPickerVC: UIViewController 

filePickerVC

The view controller for selecting file attachments.

open private(set) lazy var filePickerVC: UIViewController 

attachmentsPickerActions

Returns actions for attachments picker.

open var attachmentsPickerActions: [UIAlertAction] 

voiceRecordingVC

The view controller for recording VoiceRecordings.

open private(set) lazy var voiceRecordingVC: VoiceRecordingVC

Methods

setUp()

override open func setUp() 

setUpLayout()

override open func setUpLayout() 

viewDidDisappear(_:)

override open func viewDidDisappear(_ animated: Bool) 

updateContent()

override open func updateContent() 

setupAttachmentsView()

open func setupAttachmentsView() 

publishMessage(sender:)

@objc open func publishMessage(sender: UIButton) 

showMediaPicker()

Shows a photo/media picker.

open func showMediaPicker() 

showFilePicker()

Shows a document picker.

open func showFilePicker() 

showAttachmentsPicker(sender:)

Action that handles tap on attachments button in composer.

@objc open func showAttachmentsPicker(sender: UIButton) 

shrinkInput(sender:)

@objc open func shrinkInput(sender: UIButton) 

showAvailableCommands(sender:)

@objc open func showAvailableCommands(sender: UIButton) 

clearContent(sender:)

@objc open func clearContent(sender: UIButton) 

createNewMessage(text:)

Creates a new message and notifies the delegate that a new message was created.

open func createNewMessage(text: String) 

Parameters

  • text: The text content of the message.

editMessage(withId:newText:)

Updates an existing message.

open func editMessage(withId id: MessageId, newText: String) 

Parameters

  • id: The id of the editing message.
  • newText: The new text content of the message.

typingMention(in:)

Returns a potential user mention in case the user is currently typing a username.

open func typingMention(in textView: UITextView) -> (String, NSRange)? 

Parameters

  • textView: The text view of the message input view where the user is typing.

Returns

A tuple with the potential user mention and the position of the mention so it can be autocompleted.

typingCommand(in:)

Returns a potential command in case the user is currently typing a command.

open func typingCommand(in textView: UITextView) -> String? 

Parameters

  • textView: The text view of the message input view where the user is typing.

Returns

A string of the corresponding potential command.

showCommandSuggestions(for:)

Shows the command suggestions for the potential command the current user is typing.

open func showCommandSuggestions(for typingCommand: String) 

Parameters

  • typingCommand: The potential command that the current user is typing.

queryForMentionSuggestionsSearch(typingMention:)

Returns the query to be used for searching users for the given typing mention.

open func queryForMentionSuggestionsSearch(typingMention term: String) -> UserListQuery 

This function is called in showMentionSuggestions to retrieve the query that will be used to search the users. You should override this if you want to change the user searching logic.

Parameters

  • typingMention: The potential user mention the current user is typing.

Returns

_UserListQuery instance that will be used for searching users.

showMentionSuggestions(for:mentionRange:)

Shows the mention suggestions for the potential mention the current user is typing.

open func showMentionSuggestions(for typingMention: String, mentionRange: NSRange) 

Parameters

  • typingMention: The potential user mention the current user is typing.
  • mentionRange: The position where the current user is typing a mention to it can be replaced with the suggestion.

mentionText(for:)

Provides the mention text for composer text field, when the user selects a mention suggestion.

open func mentionText(for user: ChatUser) -> String 

showSuggestions()

Shows the suggestions view

open func showSuggestions() 

dismissSuggestions()

Dismisses the suggestions view.

open func dismissSuggestions() 

addAttachmentToContent(from:type:)

Creates and adds an attachment from the given URL to the content

open func addAttachmentToContent(from url: URL, type: AttachmentType) throws 

Parameters

  • url: The URL of the attachment
  • type: The type of the attachment

textViewDidChange(_:)

open func textViewDidChange(_ textView: UITextView) 

textView(_:shouldChangeTextIn:replacementText:)

open func textView(
_ textView: UITextView,
shouldChangeTextIn range: NSRange,
replacementText text: String
) -> Bool

imagePickerController(_:didFinishPickingMediaWithInfo:)

open func imagePickerController(
_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]
)

documentPicker(_:didPickDocumentsAt:)

open func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) 

showAttachmentExceedsMaxSizeAlert()

open func showAttachmentExceedsMaxSizeAlert() 

inputTextView(_:didPasteImage:)

open func inputTextView(_ inputTextView: InputTextView, didPasteImage image: UIImage)

Did you find this page helpful?