TUIChatConfig.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. //
  2. // TUIChatConfig.h
  3. // TUIChat
  4. //
  5. // Created by wyl on 2022/6/10.
  6. // Copyright © 2023 Tencent. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <TIMCommon/TIMCommonModel.h>
  10. #import <TIMCommon/TUIMessageCellData.h>
  11. #import "TUIChatConversationModel.h"
  12. NS_ASSUME_NONNULL_BEGIN
  13. @class TUIChatEventConfig;
  14. typedef NS_ENUM(NSUInteger, TUIChatRegisterCustomMessageStyleType) {
  15. TUIChatRegisterCustomMessageStyleTypeClassic = 0,
  16. TUIChatRegisterCustomMessageStyleTypeMinimalist = 1,
  17. };
  18. @class TUICustomActionSheetItem;
  19. @class TUIChatConversationModel;
  20. typedef NS_OPTIONS(NSInteger, TUIChatInputBarMoreMenuItem) {
  21. TUIChatInputBarMoreMenuItem_None = 0,
  22. TUIChatInputBarMoreMenuItem_CustomMessage = 1 << 0,
  23. TUIChatInputBarMoreMenuItem_TakePhoto = 1 << 1,
  24. TUIChatInputBarMoreMenuItem_RecordVideo = 1 << 2,
  25. TUIChatInputBarMoreMenuItem_Album = 1 << 3,
  26. TUIChatInputBarMoreMenuItem_File = 1 << 4,
  27. TUIChatInputBarMoreMenuItem_Room = 1 << 5,
  28. TUIChatInputBarMoreMenuItem_Poll = 1 << 6,
  29. TUIChatInputBarMoreMenuItem_GroupNote = 1 << 7,
  30. TUIChatInputBarMoreMenuItem_VideoCall = 1 << 8,
  31. TUIChatInputBarMoreMenuItem_AudioCall = 1 << 9,
  32. };
  33. @protocol TUIChatInputBarConfigDataSource <NSObject>
  34. @optional
  35. /**
  36. * Implement this method to hide items in more menu of the specified model.
  37. */
  38. - (TUIChatInputBarMoreMenuItem)inputBarShouldHideItemsInMoreMenuOfModel:(TUIChatConversationModel *)model;
  39. /**
  40. * Implement this method to add new items to the more menu of the specified model only for the classic version.
  41. */
  42. - (NSArray<TUIInputMoreCellData *> *)inputBarShouldAddNewItemsToMoreMenuOfModel:(TUIChatConversationModel *)model;
  43. /**
  44. * Implement this method to add new items to the more list of the specified model only for the minimalist version.
  45. */
  46. - (NSArray<TUICustomActionSheetItem *> *)inputBarShouldAddNewItemsToMoreListOfModel:(TUIChatConversationModel *)model;
  47. @end
  48. @protocol TUIChatShortcutViewDataSource <NSObject>
  49. @optional
  50. - (NSArray<TUIChatShortcutMenuCellData *> *)itemsInShortcutViewOfModel:(TUIChatConversationModel *)model;
  51. - (UIColor *)shortcutViewBackgroundColorOfModel:(TUIChatConversationModel *)model;
  52. - (CGFloat)shortcutViewHeightOfModel:(TUIChatConversationModel *)model;
  53. @end
  54. @interface TUIChatConfig : NSObject
  55. + (TUIChatConfig *)defaultConfig;
  56. @property(nonatomic, strong) NSArray<TUIFaceGroup *> *chatContextEmojiDetailGroups;
  57. /**
  58. * A read receipt is required to send a message, default is No
  59. */
  60. @property(nonatomic, assign) BOOL msgNeedReadReceipt;
  61. /**
  62. * Display the video call button, if the TUICalling component is integrated, the default is YES
  63. */
  64. @property(nonatomic, assign) BOOL enableVideoCall;
  65. /**
  66. * Whether to display the audio call button, if the TUICalling component is integrated, the default is YES
  67. */
  68. @property(nonatomic, assign) BOOL enableAudioCall;
  69. /**
  70. * Display custom welcome message button, default YES
  71. */
  72. @property(nonatomic, assign) BOOL enableWelcomeCustomMessage;
  73. /**
  74. * In the chat interface, long press the pop-up box to display the emoji interactive message function, the default is YES
  75. */
  76. @property(nonatomic, assign) BOOL enablePopMenuEmojiReactAction;
  77. /**
  78. * Chat long press the pop-up box to display the message reply function entry, the default is YES
  79. */
  80. @property(nonatomic, assign) BOOL enablePopMenuReplyAction;
  81. /**
  82. * Chat long press the pop-up box to display the entry of the message reference function, the default is YES
  83. */
  84. @property(nonatomic, assign) BOOL enablePopMenuReferenceAction;
  85. @property(nonatomic, assign) BOOL enablePopMenuPinAction;
  86. @property(nonatomic, assign) BOOL enablePopMenuRecallAction;
  87. @property(nonatomic, assign) BOOL enablePopMenuTranslateAction;
  88. @property(nonatomic, assign) BOOL enablePopMenuConvertAction;
  89. @property(nonatomic, assign) BOOL enablePopMenuForwardAction;
  90. @property(nonatomic, assign) BOOL enablePopMenuSelectAction;
  91. @property(nonatomic, assign) BOOL enablePopMenuCopyAction;
  92. @property(nonatomic, assign) BOOL enablePopMenuDeleteAction;
  93. @property(nonatomic, assign) BOOL enablePopMenuInfoAction;
  94. @property(nonatomic, assign) BOOL enablePopMenuAudioPlaybackAction;
  95. /**
  96. * Whether the C2C chat dialog box displays "The other party is typing...", the default is YES
  97. */
  98. @property(nonatomic, assign) BOOL enableTypingStatus;
  99. /**
  100. * Whether the chat dialog box displays "InputBar", the default is YES
  101. */
  102. @property(nonatomic, assign) BOOL enableMainPageInputBar;
  103. /**
  104. * Setup the backgroud color of chat page
  105. */
  106. @property(nonatomic, strong) UIColor *backgroudColor;
  107. /**
  108. * Setup the backgroud image of chat page
  109. */
  110. @property(nonatomic, strong) UIImage *backgroudImage;
  111. /**
  112. * Whether to turn on audio and video call suspension windows, default is YES
  113. */
  114. @property(nonatomic, assign) BOOL enableFloatWindowForCall;
  115. /**
  116. * Whether to enable multi-terminal login function for audio and video calls, default is NO
  117. */
  118. @property(nonatomic, assign) BOOL enableMultiDeviceForCall;
  119. /**
  120. * Set whether to enable incoming banner when user received audio and video calls, default is false
  121. */
  122. @property(nonatomic, assign) BOOL enableIncomingBanner;
  123. /**
  124. * Set whether to enable the virtual background for audio and video calls, default value is false
  125. */
  126. @property(nonatomic, assign) BOOL enableVirtualBackgroundForCall;
  127. /**
  128. * The time interval for message recall, in seconds, default is 120 seconds. If you want to adjust this configuration, please modify the IM console settings
  129. * synchronously.
  130. * https://cloud.tencent.com/document/product/269/38656#.E6.B6.88.E6.81.AF.E6.92.A4.E5.9B.9E.E8.AE.BE.E7.BD.AE
  131. */
  132. @property(nonatomic, assign) NSUInteger timeIntervalForMessageRecall;
  133. /**
  134. 不超过 60s
  135. */
  136. @property (nonatomic, assign) CGFloat maxAudioRecordDuration;
  137. /**
  138. 不超过 15s
  139. */
  140. @property (nonatomic, assign) CGFloat maxVideoRecordDuration;
  141. @property(nonatomic, assign) BOOL showRoomButton;
  142. @property(nonatomic, assign) BOOL showPollButton;
  143. @property(nonatomic, assign) BOOL showGroupNoteButton;
  144. @property(nonatomic, assign) BOOL showRecordVideoButton;
  145. @property(nonatomic, assign) BOOL showTakePhotoButton;
  146. @property(nonatomic, assign) BOOL showAlbumButton;
  147. @property(nonatomic, assign) BOOL showFileButton;
  148. /**
  149. * This class is used to register event listeners for Chat from external sources, to listen for various events in Chat and respond accordingly,
  150. * such as listening for avatar click events, long-press message events, etc.
  151. * You need to set a delegate for the implementation method: TUIChatConfig.defaultConfig.eventConfig.chatEventListener = "YourDelegateViewController".
  152. * YourDelegateViewController needs to conform to the <TUIChatEventListener> protocol and implement the protocol method.
  153. * Taking - (BOOL)onUserIconClicked:messageCellData: as an example, returning NO indicates an insertion behavior,
  154. * which is not intercepted and will be further processed by the Chat module.
  155. * Taking - (BOOL)onUserIconClicked:messageCellData: as an example, returning YES indicates an override behavior,
  156. * which will be intercepted and only the overridden method will be executed. The Chat module will not continue to process it.
  157. */
  158. @property(nonatomic, strong) TUIChatEventConfig * eventConfig;
  159. /**
  160. * DataSource for inputBar.
  161. */
  162. @property (nonatomic, weak) id<TUIChatInputBarConfigDataSource> inputBarDataSource;
  163. /**
  164. * DataSource for shortcutView above inputBar.
  165. */
  166. @property (nonatomic, weak) id<TUIChatShortcutViewDataSource> shortcutViewDataSource;
  167. @end
  168. NS_ASSUME_NONNULL_END
  169. NS_ASSUME_NONNULL_BEGIN
  170. @protocol TUIChatEventListener <NSObject>
  171. /**
  172. * This callback is triggered when a user avatar in the chat list interface is clicked. Returning YES indicates that this event has been intercepted,
  173. * and Chat will not process it further. Returning NO indicates that this event is not intercepted, and Chat will continue to process it.
  174. */
  175. - (BOOL)onUserIconClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  176. /**
  177. * This callback is triggered when a user avatar in the chat list interface is long-pressed. Returning YES indicates that this event has been intercepted,
  178. * and Chat will not process it further. Returning NO indicates that this event is not intercepted, and Chat will continue to process it.
  179. */
  180. - (BOOL)onUserIconLongClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  181. /**
  182. * This callback is triggered when a message in the chat list interface is clicked. Returning YES indicates that this event has been intercepted,
  183. * and Chat will not process it further. Returning NO indicates that this event is not intercepted, and Chat will continue to process it.
  184. */
  185. - (BOOL)onMessageClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  186. /**
  187. * This callback is triggered when a message in the chat list interface is long-pressed. Returning YES indicates that this event has been intercepted,
  188. * and Chat will not process it further. Returning NO indicates that this event is not intercepted, and Chat will continue to process it.
  189. */
  190. - (BOOL)onMessageLongClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  191. @end
  192. @interface TUIChatEventConfig : NSObject
  193. @property (nonatomic,weak)id <TUIChatEventListener>chatEventListener;
  194. @end
  195. // Regiser custom message category
  196. // You can call this method like :
  197. //
  198. // [TUIChatConfig.defaultConfig registerCustomMessage:@"YourBusinessID"
  199. // messageCellClassName:@"YourCustomCellNameString"
  200. // messageCellDataClassName:@"YourCustomCellDataNameString"];
  201. @interface TUIChatConfig (CustomMessageRegiser)
  202. /**
  203. * Register custom message , by default, register to the classic UI.
  204. * param businessID Custom message businessID (note that it must be unique)
  205. * param cellName Custom message messagCell type
  206. * param cellDataName Custom message MessagCellData type
  207. */
  208. - (void)registerCustomMessage:(NSString *)businessID
  209. messageCellClassName:(NSString *)cellName
  210. messageCellDataClassName:(NSString *)cellDataName;
  211. /**
  212. * Register custom message
  213. * param businessID Custom message businessID (note that it must be unique)
  214. * param cellName Custom message messagCell type
  215. * param cellDataName Custom message MessagCellData type
  216. * param styleType UI style corresponding to this custom message, for example TUIChatRegisterCustomMessageStyleTypeClassic
  217. */
  218. - (void)registerCustomMessage:(NSString *)businessID
  219. messageCellClassName:(NSString *)cellName
  220. messageCellDataClassName:(NSString *)cellDataName
  221. styleType:(TUIChatRegisterCustomMessageStyleType)styleType;
  222. @end
  223. NS_ASSUME_NONNULL_END