TUIMessageCell.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. /**
  4. *
  5. *
  6. * This document declares the modules and components used to implement the message unit.
  7. * The message unit (TUIMessageCell) is a general term for the bubble message/picture message/emoticon message/video message displayed in the chat view.
  8. * The above messages are implemented by inheriting from this class or a subclass of this class. If you want to customize the message, you also need to
  9. * implement it by inheriting from this class or a subclass of this class. The XXXX message unit (TUIXXXXMessageCell) is mainly responsible for displaying on
  10. * the page and responding to user interaction events. For data processing and acquisition in the message unit, please refer to
  11. * TUIChat\CellData\TUIXXXXMessageCellData.h according to the specific message unit
  12. *
  13. * The interaction callbacks provided by the TUIMessageCellDelegate protocol include: long press, resend, click on the message, click on the avatar, etc.
  14. * The TUIMessageCell class stores message-related information, such as the sender's avatar, sender's nickname, and message content (supports various formats
  15. * such as text, pictures, and videos). At the same time, TUIMessageeCell, as a parent class, provides basic properties and behavior templates for subclass
  16. * messages.
  17. */
  18. #import <UIKit/UIKit.h>
  19. #import "TUIFitButton.h"
  20. #import "TUIMessageCellData.h"
  21. #import "TUISecurityStrikeView.h"
  22. @class TUIMessageCell;
  23. @protocol TUIMessageCellProtocol <NSObject>
  24. @required
  25. + (CGFloat)getHeight:(TUIMessageCellData *)data withWidth:(CGFloat)width;
  26. + (CGFloat)getEstimatedHeight:(TUIMessageCellData *)data;
  27. + (CGSize)getContentSize:(TUIMessageCellData *)data;
  28. @end
  29. /////////////////////////////////////////////////////////////////////////////////
  30. //
  31. // TUIMessageCellDelegate
  32. //
  33. /////////////////////////////////////////////////////////////////////////////////
  34. @protocol TUIMessageCellDelegate <NSObject>
  35. /**
  36. * Callback for long press message
  37. * You can use this callback to implement secondary operations such as delete and recall (when the sender of the message long-presses his own message) on top
  38. * of the long-pressed message.
  39. */
  40. - (void)onLongPressMessage:(TUIMessageCell *)cell;
  41. /**
  42. * Callback for clicking retryView
  43. * You can use this callback to implement: resend the message.
  44. */
  45. - (void)onRetryMessage:(TUIMessageCell *)cell;
  46. /**
  47. * Callback for clicking message cell
  48. * Usually:
  49. * - Clicking on the sound message means playing voice
  50. * - Clicking on the file message means opening the file
  51. * - Clicking on the picture message means showing the larger image
  52. * - Clicking on the video message means playing the video.
  53. * Usually, it only provides a reference for the function implementation, and you can implement the delegate function according to your needs.
  54. */
  55. - (void)onSelectMessage:(TUIMessageCell *)cell;
  56. /**
  57. * Callback for clicking avatar view of the messageCell
  58. * You can use this callback to implement: in response to the user's click, jump to the detailed information interface of the corresponding user.
  59. */
  60. - (void)onSelectMessageAvatar:(TUIMessageCell *)cell;
  61. /**
  62. * Callback for long pressing avatar view of messageCell
  63. */
  64. - (void)onLongSelectMessageAvatar:(TUIMessageCell *)cell;
  65. /**
  66. * Callback for clicking read receipt label
  67. */
  68. - (void)onSelectReadReceipt:(TUIMessageCellData *)cell;
  69. /**
  70. * Clicking the x-person reply button to jump to the multi-person reply details page
  71. */
  72. - (void)onJumpToRepliesDetailPage:(TUIMessageCellData *)data;
  73. - (void)onJumpToMessageInfoPage:(TUIMessageCellData *)data selectCell:(TUIMessageCell *)cell;
  74. @end
  75. /////////////////////////////////////////////////////////////////////////////////
  76. //
  77. // TUIMessageCell
  78. //
  79. /////////////////////////////////////////////////////////////////////////////////
  80. @interface TUIMessageCell : TUICommonTableViewCell <TUIMessageCellProtocol>
  81. /**
  82. * Icon that identifies the message selected
  83. * In the multi-selection scenario, it is used to identify whether the message is selected
  84. */
  85. @property(nonatomic, strong) UIImageView *selectedIcon;
  86. /**
  87. * Message selection view
  88. * When multiple selection is activated, the view will be overlaid on this cell, and clicking on the view will trigger the check/uncheck of the message
  89. */
  90. @property(nonatomic, strong) UIButton *selectedView;
  91. /**
  92. *
  93. * The icon view of displays user's avatar
  94. */
  95. @property(nonatomic, strong) UIImageView *avatarView;
  96. /**
  97. *
  98. * The label of displays user's displayname
  99. */
  100. @property(nonatomic, strong) UILabel *nameLabel;
  101. /**
  102. * Container view
  103. * It wraps various views of MesageCell as the "bottom" of MessageCell, which is convenient for view management and layout.
  104. */
  105. @property(nonatomic, strong) UIView *container;
  106. /**
  107. * Activity indicator
  108. * A circling icon is provided while the message is being sent to indicate that the message is being sent.
  109. */
  110. @property(nonatomic, strong) UIActivityIndicatorView *indicator;
  111. /**
  112. * Retry view, displayed after sending failed, click on this view to trigger onRetryMessage: callback.
  113. */
  114. @property(nonatomic, strong) UIImageView *retryView;
  115. /**
  116. * security Strike View
  117. */
  118. @property (nonatomic, strong) TUISecurityStrikeView * securityStrikeView;
  119. /**
  120. * Message reply details button
  121. */
  122. @property(nonatomic, strong) TUIFitButton *messageModifyRepliesButton;
  123. /**
  124. * The message data class which stores the information required in the messageCell, including sender ID, sender avatar, message sending status, message bubble
  125. * icon, etc. For details of messageData, please refer to: TUIChat\Cell\CellData\TUIMessageCellData.h
  126. */
  127. @property(readonly) TUIMessageCellData *messageData;
  128. /**
  129. * A control that identifies whether a message has been read
  130. */
  131. @property(nonatomic, strong) UILabel *readReceiptLabel;
  132. /**
  133. * The message time label control, which is not displayed by default, is located at the far right of the message cell
  134. * In the message forwarding scenario, open the forwarded message list, and the time of the current message will be displayed on the far right of the message.
  135. */
  136. @property(nonatomic, strong) UILabel *timeLabel;
  137. /**
  138. * Whether to disable the default selection behavior encapsulated in TUIKit, such as group live broadcast by default to create live room and other behaviors,
  139. * default: NO
  140. */
  141. @property(nonatomic, assign) BOOL disableDefaultSelectAction;
  142. @property(nonatomic, weak) id<TUIMessageCellDelegate> delegate;
  143. /**
  144. *
  145. * Whether the highlight flashing animation is in progress
  146. */
  147. @property(nonatomic, assign) BOOL highlightAnimating;
  148. - (void)fillWithData:(TUICommonCellData *)data;
  149. /**
  150. * Set the highlighting effect after matching the keyword, mainly used for jumping after message search, subclass rewriting
  151. * The base class provides the default highlighting effect, and the subclass can implement it freely
  152. *
  153. * @param keyword Highlight keywords
  154. */
  155. - (void)highlightWhenMatchKeyword:(NSString *)keyword;
  156. /**
  157. * Returns the view for highlighting
  158. */
  159. - (UIView *)highlightAnimateView;
  160. /**
  161. * Update the content of the read label
  162. */
  163. - (void)updateReadLabelText;
  164. /// Preset bottom container in cell, which can be added custom view/viewControllers.
  165. @property(nonatomic, strong) UIView *bottomContainer;
  166. /// When bottom container is layout ready, notify it to add custom extensions.
  167. - (void)notifyBottomContainerReadyOfData:(TUIMessageCellData *)cellData;
  168. /// Callback of SelectCell
  169. @property(nonatomic, copy) TUIValueCallbck pluginMsgSelectCallback;
  170. @end
  171. @interface TUIMessageCell (TUILayoutConfiguration)
  172. /**
  173. * The color of the label that displays the recipient's nickname
  174. * Used when the nickname needs to be displayed and the message direction is MsgDirectionIncoming
  175. */
  176. @property(nonatomic, class) UIColor *incommingNameColor;
  177. /**
  178. *
  179. * The font of the label that displays the recipient's nickname
  180. * Used when the nickname needs to be displayed and the message direction is MsgDirectionIncoming
  181. *
  182. */
  183. @property(nonatomic, class) UIFont *incommingNameFont;
  184. /**
  185. * The color of the label showing the sender's nickname
  186. * Used when the nickname needs to be displayed and the message direction is MsgDirectionOutgoing.
  187. */
  188. @property(nonatomic, class) UIColor *outgoingNameColor;
  189. /**
  190. *
  191. * The font of the label that displays the sender's nickname
  192. * Used when the nickname needs to be displayed and the message direction is MsgDirectionOutgoing.
  193. */
  194. @property(nonatomic, class) UIFont *outgoingNameFont;
  195. @end