The CometChatReactions component is designed to visually represent the reactions received by a message. Each reaction appears in a horizontal alignment beneath the message to indicate which emojis users have used to react.The number of visible reactions depends on the width of the view. For example, if a message has 5 reactions but the CometChatReactions view can only accommodate 4 reactions within its width, the first three reactions will be displayed visibly. Additionally, an element will be added at the end of the row to indicate the number of other unique reactions that are not immediately visible. This element informs users of the total count of different reactions beyond those initially shown.
The CometChatReactions component is a standard UIView that displays a list of reactions as its children. In the provided UI example, it is utilized within the footer view of the CometChatMessageBubble. However, it is versatile and can be incorporated anywhere a UIView can be placed. The minimum requirement for this component to function is to provide the reactions to display, which can be passed using the baseMessage property.Swift
let cometChatReaction = CometChatReactions() .set(message: forMessage) .build()self.addSubViews(cometChatReaction)
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.
1. onReactionsPressed
The onReactionsPressed event is triggered when a user interacts with a reaction by pressing it, typically to indicate a response or provide feedback.
Swift
let reactionsConfiguration = ReactionsConfiguration().set(onReactionsPressed: { reaction, baseMessage in})
Example In this example, we are using the onReactionsPressed action.
Filters empower you to customize the displayed data within a component’s list by applying specific criteria. This capability allows for a more tailored and personalized view of the content. Filters are implemented using RequestBuilders of Chat SDK.The Reactions component does not provide any exposed filtering options.
Events are triggered by a component, enabling you to enhance its functionality. These events are global in scope, making them applicable across multiple areas of your application, and they can be added or removed as required.The Reactions component does not provide any available events.
For customization aligned with your app’s design, you can adjust the appearance of the Reaction component using our accessible methods. These methods enable you to tailor the experience and behavior to suit your specific needs.
Through Style, you can customize the visual presentation of the component in your app. This includes controlling elements such as color, size, shape, and fonts to achieve the desired look and feel.
1. Reactions Style
The ReactionsStyle class encapsulates properties that facilitate customization of the CometChatReactions component’s visual appearance.
Swift
let reactionsStyle = ReactionsStyle() .set(countFont: CometChatTheme.typography.text2) .set(reactionBorderWidth: 3) .set(background: .black)
ExampleHere, we are applying the reactionsStyle to customize the appearance.
These functional customizations provide ways to enhance the component’s overall experience. They allow for text modification, custom icon setting, and UI element visibility toggling.
If you want to customize the properties of the Reaction onReactionsPressed Component inside Reactions Component, you need use the ReactionsConfiguration object.
Swift
Swift
let reactionsConfiguration = ReactionsConfiguration() .set(onReactionsPressed: { reaction, baseMessage in})
If you want to customize the properties of the Reaction onReactionsLongPressed Component inside Reactions Component, you need use the ReactionsConfiguration object.
Swift
Swift
let reactionsConfiguration = ReactionsConfiguration() .set (onReactionsLongPressed:{ reaction, baseMessage in })