Overview
CometChatCompactMessageComposer is a Component that provides a compact, single-line message input designed for chat applications. It offers a streamlined interface with optional rich text formatting capabilities, supporting bold, italic, strikethrough, code, links, lists, and blockquotes.
Features such as Rich Text Formatting, Attachments, Message Editing, Mentions, Stickers, and Voice Recording are supported.
Usage
Integration
The following code snippet illustrates how you can directly incorporate the CompactMessageComposer component into your view.- Swift
To ensure that the
CometChatCompactMessageComposer is properly configured, passing the controller is mandatory.Actions
Actions dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.setOnSendButtonClick
Theset(onSendButtonClick:) event gets activated when the send message button is clicked. It has a predefined function of sending messages entered in the composer. However, you can override this action with the following code snippet.
- Swift
setOnError
This action doesn’t change the behavior of the component but rather listens for any errors that occur in the CompactMessageComposer component.- Swift
setOnTextChangedListener
Function triggered whenever the message input’s text value changes, enabling dynamic text handling.- Swift
setAttachmentOptions
This action is triggered when the attachment button is clicked. You can override the default attachment sheet behavior with a custom implementation.- Swift
Filters
CompactMessageComposer component does not have any available filters.Events
Events are emitted by aComponent. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.
The CompactMessageComposer Component does not emit any events of its own.
Customization
To fit your app’s design requirements, you can customize the appearance of the CompactMessageComposer component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.Style
Using Style you can customize the look and feel of the component in your app. These parameters typically control elements such as the color, size, shape, and fonts used within the component. Global level styling- Swift
- Swift
CompactMessageComposerStyle:
Functionality
These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements. Below is a list of customizations along with corresponding code snippets:Rich Text Formatting
The CompactMessageComposer includes a built-in rich text editor.enableRichTextFormatting and showRichTextFormattingOptions are true by default, so rich text formatting and the formatting toolbar are enabled out of the box.
enableRichTextFormatting— Master switch that activates formatting. When set tofalse, even manually typed markdown syntax like**text**will be sent as plain text.showRichTextFormattingOptions— Controls the visibility of the formatting toolbar below the input field.
Supported Format Types
Configuration
- Swift
RichTextToolbarStyle
Global level styling- Swift
RichTextToolbarStyle:
Advanced
For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.setTextFormatters
Assigns the list of text formatters. If the provided list is not null, it sets the list. Otherwise, it assigns the default text formatters retrieved from the data source. To configure the existing Mentions look and feel check out CometChatMentionsFormatter Example- Swift
setAttachmentOptions
By usingset(attachmentOptions:), you can set a list of custom CometChatMessageComposerAction for the CompactMessageComposer Component. This will override the existing list of CometChatMessageComposerAction.
- Swift
- Swift
Edit & Reply Mode
The CompactMessageComposer supports editing and replying to messages. You can programmatically put the composer into edit or reply mode. Edit a message- Swift
- Swift
- Swift
Complete Integration Example
- Swift