TUIMessageCellData.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. /**
  4. *
  5. * This file declares the TUIMessageCellData class.
  6. * - The "message unit" data source, as the parent class of various detailed data sources, provides basic templates for the properties and behaviors of various
  7. * "message unit" data sources.
  8. * - The "data source class" in this document is the base class for all message data, and each type of data source inherits from this class or its subclasses.
  9. * - When you want to customize the message, you need to inherit the data source of the customized message from this class or a subclass of this class.
  10. */
  11. #import <TIMCommon/TIMCommonModel.h>
  12. #import <TIMCommon/TIMDefine.h>
  13. #import "TUIMessageCellLayout.h"
  14. @class TUIRelationUserModel;
  15. NS_ASSUME_NONNULL_BEGIN
  16. typedef void (^TDownloadProgress)(NSInteger curSize, NSInteger totalSize);
  17. typedef void (^TDownloadResponse)(int code, NSString *desc, NSString *path);
  18. /**
  19. * The definition of message status
  20. */
  21. typedef NS_ENUM(NSUInteger, TMsgStatus) {
  22. Msg_Status_Init, // message initial
  23. Msg_Status_Sending, // message sending
  24. Msg_Status_Sending_2, // message sending, recommended
  25. Msg_Status_Succ, // message sent successfully
  26. Msg_Status_Fail, // Failed to send message
  27. };
  28. /**
  29. *
  30. * The definition of message direction
  31. * Message direction affects UI styles such as bubble icons, bubble positions, etc.
  32. */
  33. typedef NS_ENUM(NSUInteger, TMsgDirection) {
  34. MsgDirectionIncoming,
  35. MsgDirectionOutgoing,
  36. };
  37. /**
  38. *
  39. * The source of message
  40. * Different display logic can be done according to the source of the message.
  41. */
  42. typedef NS_ENUM(NSUInteger, TMsgSource) {
  43. Msg_Source_Unkown = 0, // 未知
  44. Msg_Source_OnlinePush, // Messages actively pushed in the background
  45. Msg_Source_GetHistory, // SDK actively requests historical messages pulled from the background
  46. };
  47. /**
  48. * 【Module name】TUIMessageCellData
  49. * 【Function description】The data source of the chat message unit cooperates with the message controller to realize the business logic of message sending and
  50. * receiving.
  51. * - It is used to store various data and information required for message management and logic implementation. Including a series of data such as message
  52. * status, message sender ID and avatar.
  53. * - The chat information data unit integrates and calls the IM SDK, and can implement the business logic of the message through the interface provided by the
  54. * SDK.
  55. */
  56. @interface TUIMessageCellData : TUICommonCellData
  57. /**
  58. * Getting cellData according to message
  59. */
  60. + (TUIMessageCellData *)getCellData:(V2TIMMessage *)message;
  61. /**
  62. * Getting the display string according to the message
  63. */
  64. + (NSString *)getDisplayString:(V2TIMMessage *)message;
  65. /**
  66. * Class to get the layout of the message reply custom reference and its data
  67. */
  68. - (Class)getReplyQuoteViewDataClass;
  69. - (Class)getReplyQuoteViewClass;
  70. /**
  71. * Message unique id
  72. */
  73. @property(nonatomic, strong) NSString *msgID;
  74. /**
  75. * Message sender ID
  76. */
  77. @property(nonatomic, strong) NSString *identifier;
  78. /**
  79. * Message display sender name
  80. */
  81. @property(nonatomic, strong, readonly) NSString *senderName;
  82. /**
  83. * Sender's avatar url
  84. */
  85. @property(nonatomic, strong) NSURL *__nullable avatarUrl;
  86. /**
  87. * Sender's avatar
  88. */
  89. @property(nonatomic, strong) UIImage *__nullable avatarImage __attribute__((deprecated("not supported")));
  90. @property (nonatomic, strong) NSString *headdress;//头饰链接
  91. @property (nonatomic, assign) NSInteger headgearType;//头饰 - 头饰类型(0=无资源文件,1=动态webp,2=SVGA,3=VAP)
  92. /**
  93. * Whether to use the receiver's avatar, default is NO
  94. */
  95. @property(nonatomic, assign) BOOL isUseMsgReceiverAvatar;
  96. /**
  97. *
  98. * The flag of showing name
  99. * - In 1 vs 1 chat, the nickname is not displayed in the message by default.
  100. * - In group chat, the nickname is displayed for messages sent by other users in the group.
  101. * - YES: showing nickname; NO: hidden nickname
  102. */
  103. @property(nonatomic, assign) BOOL showName;
  104. /**
  105. * Display user avatar
  106. */
  107. @property(nonatomic, assign) BOOL showAvatar;
  108. /**
  109. * Whether the current message is the same as the sender of the next message
  110. */
  111. @property(nonatomic, assign) BOOL sameToNextMsgSender;
  112. /**
  113. *
  114. * The flag of showing message multiple selection
  115. * - In the message list, the selection button is not displayed by default. When you long press the message to pop up the multi-select button and click it, the
  116. * message list becomes multi-selectable.
  117. * - YES: Enable multiple selection, multiple selection views are displayed; NO: Disable multiple selection, the default view is displayed.
  118. */
  119. @property(nonatomic, assign) BOOL showCheckBox;
  120. /**
  121. * The flag of selected
  122. */
  123. @property(nonatomic, assign) BOOL selected;
  124. /**
  125. * The user list in at message
  126. */
  127. @property(nonatomic, strong) NSMutableArray<NSString *> *atUserList;
  128. /**
  129. * Message direction
  130. * - Message direction affects UI styles such as bubble icons, bubble positions, etc.
  131. */
  132. @property(nonatomic, assign) TMsgDirection direction;
  133. /**
  134. * Message status
  135. */
  136. @property(nonatomic, assign) TMsgStatus status;
  137. /**
  138. * Message source
  139. */
  140. @property(nonatomic, assign) TMsgSource source;
  141. /**
  142. * IMSDK message
  143. * The Message object provided by IM SDK. Contains various member functions for obtaining message information, including obtaining priority, obtaining element
  144. * index, obtaining offline message configuration information, etc. For details, please refer to
  145. * TXIMSDK__Plus_iOS\Frameworks\ImSDK_Plus.framework\Headers\V2TIMMessage.h
  146. */
  147. @property(nonatomic, strong) V2TIMMessage *innerMessage;
  148. /**
  149. * Message unit layout
  150. * It includes UI information such as message margins, bubble padding, avatar margins, and avatar size.
  151. * For details, please refer to Section\Chat\CellLayout\TUIMessageCellLayout.h
  152. */
  153. @property(nonatomic, strong) TUIMessageCellLayout *cellLayout;
  154. /**
  155. * The flag of whether showing read receipts.
  156. */
  157. @property(nonatomic, assign) BOOL showReadReceipt;
  158. /**
  159. * The flag of whether showing message time.
  160. */
  161. @property(nonatomic, assign) BOOL showMessageTime;
  162. /**
  163. * The flag of whether showing the button which indicated how many people modiffied.
  164. */
  165. @property(nonatomic, assign) BOOL showMessageModifyReplies;
  166. /**
  167. * Highlight keywords, when the keyword is not empty, it will be highlighted briefly, mainly used in message search scenarios.
  168. */
  169. @property(nonatomic, copy) NSString *__nullable highlightKeyword;
  170. /**
  171. * Message read receipt
  172. */
  173. @property(nonatomic, strong) V2TIMMessageReceipt *messageReceipt;
  174. /**
  175. * List of Reply Messages for the current message
  176. */
  177. @property(nonatomic, strong) NSArray *messageModifyReplies;
  178. @property(nonatomic, assign) CGSize messageContainerAppendSize;
  179. /// Size for bottom container.
  180. @property(nonatomic, assign) CGSize bottomContainerSize;
  181. /// Placeholder data, to be replaced after data preparation is completed.
  182. @property(nonatomic, strong) TUIMessageCellData* _Nullable placeHolderCellData;
  183. /// Video transcoding progress
  184. @property(nonatomic, assign) CGFloat videoTranscodingProgress;
  185. /// If cell content can be forwarded.
  186. - (BOOL)canForward;
  187. - (BOOL)canLongPress;
  188. - (BOOL)shouldHide;
  189. /// Custom cell refresh when message modified
  190. - (BOOL)customReloadCellWithNewMsg:(V2TIMMessage *)newMessage;
  191. /**
  192. * Initialize the message unit according to the message direction (receive/sent)
  193. * - In addition to the initialization of basic messages, it also includes setting direction variables, nickname fonts, etc. according to the direction.
  194. * - Also provides inheritable behavior for subclasses.
  195. */
  196. - (instancetype)initWithDirection:(TMsgDirection)direction NS_DESIGNATED_INITIALIZER;
  197. - (instancetype)init NS_UNAVAILABLE;
  198. @property(nonatomic, assign) CGSize msgStatusSize;
  199. /**
  200. * TUIChat supports batch retrieval of user information except for the message sender's nickname.
  201. * You can override the requestForAdditionalUserInfo method in your custom TUIMessageCellData to return the user IDs which you want to retrieve, and directly use the additionalUserInfoResult property in your custom TUIMessageCell to render the UI as needed.
  202. * After TUIChat retrieves the information, it will assign it to the additionalUserInfoResult property and asynchronously refresh your cell.
  203. */
  204. - (NSArray<NSString *> *)requestForAdditionalUserInfo;
  205. @property(nonatomic, strong) NSDictionary<NSString *, TUIRelationUserModel *> *additionalUserInfoResult;
  206. @end
  207. NS_ASSUME_NONNULL_END
  208. /**
  209. * 【Module name】TUIMessageCellDataFileUploadProtocol
  210. * 【Function description】File type message, unified upload (send) progress field
  211. */
  212. @protocol TUIMessageCellDataFileUploadProtocol <NSObject>
  213. @required
  214. /**
  215. * The progress of uploading (sending)
  216. */
  217. @property(nonatomic, assign) NSUInteger uploadProgress;
  218. @end
  219. @protocol TUIMessageCellDataFileDownloadProtocol <NSObject>
  220. @required
  221. /**
  222. * The progress of downloading (receving)
  223. */
  224. @property(nonatomic, assign) NSUInteger downladProgress;
  225. /**
  226. * The flag of whether is downloading
  227. * YES: downloading; NO: not download
  228. */
  229. @property(nonatomic, assign) BOOL isDownloading;
  230. @end