TUIChatConfig_Classic.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. //
  2. // TUIChatConfig_Classic.h
  3. // TUIChat
  4. //
  5. // Created by Tencent on 2024/7/16.
  6. // Copyright © 2024 Tencent. All rights reserved.
  7. #import <Foundation/Foundation.h>
  8. #import "UIAlertController+TUICustomStyle.h"
  9. #import "TUIChatShortcutMenuView.h"
  10. #import "TUIInputMoreCellData.h"
  11. #import <TIMCommon/TIMCommonModel.h>
  12. #import <TIMCommon/TUIMessageCellLayout.h>
  13. #import "TUIChatConfig.h"
  14. NS_ASSUME_NONNULL_BEGIN
  15. @class TUIMessageCellData;
  16. typedef NS_ENUM(NSInteger, TUIAvatarStyle_Classic) {
  17. TUIAvatarStyleRectangle,
  18. TUIAvatarStyleCircle,
  19. TUIAvatarStyleRoundedRectangle,
  20. };
  21. typedef NS_OPTIONS(NSInteger, TUIChatItemWhenLongPressMessage_Classic) {
  22. TUIChatItemWhenLongPressMessage_Classic_None = 0,
  23. TUIChatItemWhenLongPressMessage_Classic_Reply = 1 << 0,
  24. TUIChatItemWhenLongPressMessage_Classic_EmojiReaction = 1 << 1,
  25. TUIChatItemWhenLongPressMessage_Classic_Quote = 1 << 2,
  26. TUIChatItemWhenLongPressMessage_Classic_Pin = 1 << 3,
  27. TUIChatItemWhenLongPressMessage_Classic_Recall = 1 << 4,
  28. TUIChatItemWhenLongPressMessage_Classic_Translate = 1 << 5,
  29. TUIChatItemWhenLongPressMessage_Classic_Convert = 1 << 6,
  30. TUIChatItemWhenLongPressMessage_Classic_Forward = 1 << 7,
  31. TUIChatItemWhenLongPressMessage_Classic_Select = 1 << 8,
  32. TUIChatItemWhenLongPressMessage_Classic_Copy = 1 << 9,
  33. TUIChatItemWhenLongPressMessage_Classic_Delete = 1 << 10,
  34. };
  35. @protocol TUIChatConfigDelegate_Classic <NSObject>
  36. /**
  37. * Tells the delegate a user's avatar in the chat list is clicked.
  38. * Returning YES indicates this event has been intercepted, and Chat will not process it further.
  39. * Returning NO indicates this event is not intercepted, and Chat will continue to process it.
  40. */
  41. - (BOOL)onUserAvatarClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  42. /**
  43. * Tells the delegate a user's avatar in the chat list is long pressed.
  44. * Returning YES indicates that this event has been intercepted, and Chat will not process it further.
  45. * Returning NO indicates that this event is not intercepted, and Chat will continue to process it.
  46. */
  47. - (BOOL)onUserAvatarLongPressed:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  48. /**
  49. * Tells the delegate a message in the chat list is clicked.
  50. * Returning YES indicates that this event has been intercepted, and Chat will not process it further.
  51. * Returning NO indicates that this event is not intercepted, and Chat will continue to process it.
  52. */
  53. - (BOOL)onMessageClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  54. /**
  55. * Tells the delegate a message in the chat list is long pressed.
  56. * Returning YES indicates that this event has been intercepted, and Chat will not process it further.
  57. * Returning NO indicates that this event is not intercepted, and Chat will continue to process it.
  58. */
  59. - (BOOL)onMessageLongPressed:(UIView *)view messageCellData:(TUIMessageCellData *)celldata;
  60. @end
  61. @interface TUIChatConfig_Classic : NSObject
  62. + (TUIChatConfig_Classic *)sharedConfig;
  63. /**
  64. * The object that acts as the delegate of the TUIChatMessageConfig_Minimalist.
  65. */
  66. @property (nonatomic, weak) id<TUIChatConfigDelegate_Classic> delegate;
  67. /**
  68. * Customize the backgroud color of message list interface.
  69. * This configuration takes effect in all message list interfaces.
  70. */
  71. @property (nonatomic, strong) UIColor *backgroudColor;
  72. /**
  73. * Customize the backgroud image of message list interface.
  74. * This configuration takes effect in all message list interfaces.
  75. */
  76. @property (nonatomic, strong) UIImage *backgroudImage;
  77. /**
  78. * Customize the style of avatar.
  79. * The default value is TUIAvatarStyleCircle.
  80. * This configuration takes effect in all avatars.
  81. */
  82. @property (nonatomic, assign) TUIAvatarStyle_Classic avatarStyle;
  83. /**
  84. * Customize the corner radius of the avatar.
  85. * This configuration takes effect in all avatars.
  86. */
  87. @property (nonatomic, assign) CGFloat avatarCornerRadius;
  88. /**
  89. * Display the group avatar in the nine-square grid style.
  90. * The default value is YES.
  91. * This configuration takes effect in all groups.
  92. */
  93. @property (nonatomic, assign) BOOL enableGroupGridAvatar;
  94. /**
  95. * Default avatar image.
  96. * This configuration takes effect in all avatars.
  97. */
  98. @property (nonatomic, strong) UIImage *defaultAvatarImage;
  99. /**
  100. * Enable the display "Alice is typing..." on one-to-one chat interface.
  101. * The default value is YES.
  102. * This configuration takes effect in all one-to-one chat message list interfaces.
  103. */
  104. @property (nonatomic, assign) BOOL enableTypingIndicator;
  105. /**
  106. * When sending a message, set this flag to require message read receipt.
  107. * The default value is NO.
  108. * This configuration takes effect in all chat message list interfaces.
  109. */
  110. @property (nonatomic, assign) BOOL isMessageReadReceiptNeeded;
  111. /**
  112. * Hide the "Video Call" button in the message list header.
  113. * The default value is NO.
  114. */
  115. @property (nonatomic, assign) BOOL hideVideoCallButton;
  116. /**
  117. * Hide the "Audio Call" button in the message list header.
  118. * The default value is NO.
  119. */
  120. @property (nonatomic, assign) BOOL hideAudioCallButton;
  121. /**
  122. * Turn on audio and video call floating windows,
  123. * The default value is YES.
  124. */
  125. @property (nonatomic, assign) BOOL enableFloatWindowForCall;
  126. /**
  127. * Enable multi-terminal login function for audio and video calls
  128. * The default value is NO.
  129. */
  130. @property (nonatomic, assign) BOOL enableMultiDeviceForCall;
  131. /**
  132. * Set this parameter when the sender sends a message, and the receiver will not update the unread count after receiving the message.
  133. * The default value is NO.
  134. */
  135. @property (nonatomic, assign) BOOL isExcludedFromUnreadCount;
  136. /**
  137. * Set this parameter when the sender sends a message, and the receiver will not update the last message of the conversation after receiving the message.
  138. * The default value is NO.
  139. */
  140. @property (nonatomic, assign) BOOL isExcludedFromLastMessage;
  141. /**
  142. * Time interval within which a message can be recalled after being sent.
  143. * The default value is 120 seconds.
  144. * If you want to adjust this configuration, please modify the setting on Chat Console synchronously: https://trtc.io/document/34419?platform=web&product=chat&menulabel=uikit#message-recall-settings
  145. */
  146. @property (nonatomic, assign) NSUInteger timeIntervalForAllowedMessageRecall;
  147. /**
  148. * Maximum audio recording duration, no more than 60s.
  149. * The default value is 60 seconds.
  150. */
  151. @property (nonatomic, assign) CGFloat maxAudioRecordDuration;
  152. /**
  153. * Maximum video recording duration, no more than 15s.
  154. * The default value is 15 seconds.
  155. */
  156. @property (nonatomic, assign) CGFloat maxVideoRecordDuration;
  157. /**
  158. * Enable custom ringtone.
  159. * This config takes effect only for Android devices.
  160. */
  161. @property (nonatomic, assign) BOOL enableAndroidCustomRing;
  162. /**
  163. * Hide the items in the pop-up menu when user presses the message.
  164. */
  165. + (void)hideItemsWhenLongPressMessage:(TUIChatItemWhenLongPressMessage_Classic)items;
  166. /**
  167. * Call this method to use speakers instead of handsets by default when playing voice messages.
  168. */
  169. + (void)setPlayingSoundMessageViaSpeakerByDefault;
  170. /**
  171. * Add a custom view at the top of the chat interface.
  172. * This view will be displayed at the top of the message list and will not slide up.
  173. */
  174. + (void)setCustomTopView:(UIView *)view;
  175. /**
  176. * Register custom message.
  177. * - Parameters:
  178. * - businessID: Customized message‘s businessID, which is unique.
  179. * - cellName: Customized message's MessagCell class name.
  180. * - cellDataName: Customized message's MessagCellData class name.
  181. */
  182. - (void)registerCustomMessage:(NSString *)businessID
  183. messageCellClassName:(NSString *)cellName
  184. messageCellDataClassName:(NSString *)cellDataName;
  185. @end
  186. @interface TUIChatConfig_Classic (MessageStyle)
  187. /**
  188. * The color of send text message.
  189. */
  190. @property(nonatomic, assign) UIColor *sendTextMessageColor;
  191. /**
  192. * The font of send text message.
  193. */
  194. @property(nonatomic, assign) UIFont *sendTextMessageFont;
  195. /**
  196. * The color of receive text message.
  197. */
  198. @property(nonatomic, assign) UIColor *receiveTextMessageColor;
  199. /**
  200. * The font of receive text message.
  201. */
  202. @property(nonatomic, assign) UIFont *receiveTextMessageFont;
  203. /**
  204. * The text color of system message.
  205. */
  206. @property (nonatomic, strong) UIColor *systemMessageTextColor;
  207. /**
  208. * The font of system message.
  209. */
  210. @property (nonatomic, strong) UIFont *systemMessageTextFont;
  211. /**
  212. * The background color of system message.
  213. */
  214. @property (nonatomic, strong) UIColor *systemMessageBackgroundColor;
  215. /**
  216. * The font of user's nickname of received messages.
  217. */
  218. @property (nonatomic, strong) UIFont *receiveNicknameFont;
  219. /**
  220. * The color of user's nickname of received messages.
  221. */
  222. @property (nonatomic, strong) UIColor *receiveNicknameColor;
  223. @end
  224. @interface TUIChatConfig_Classic (MessageLayout)
  225. /**
  226. * Text message cell layout of my sent message.
  227. */
  228. @property(nonatomic, assign, readonly) TUIMessageCellLayout *sendTextMessageLayout;
  229. /**
  230. * Text message cell layout of my received message.
  231. */
  232. @property(nonatomic, assign, readonly) TUIMessageCellLayout *receiveTextMessageLayout;
  233. /**
  234. * Image message cell layout of my sent message.
  235. */
  236. @property(nonatomic, assign, readonly) TUIMessageCellLayout *sendImageMessageLayout;
  237. /**
  238. * Image message cell layout of my received message.
  239. */
  240. @property(nonatomic, assign, readonly) TUIMessageCellLayout *receiveImageMessageLayout;
  241. /**
  242. * Voice message cell layout of my sent message.
  243. */
  244. @property(nonatomic, assign, readonly) TUIMessageCellLayout *sendVoiceMessageLayout;
  245. /**
  246. * Voice message cell layout of my received message.
  247. */
  248. @property(nonatomic, assign, readonly) TUIMessageCellLayout *receiveVoiceMessageLayout;
  249. /**
  250. * Video message cell layout of my sent message.
  251. */
  252. @property(nonatomic, assign, readonly) TUIMessageCellLayout *sendVideoMessageLayout;
  253. /**
  254. * Video message cell layout of my received message.
  255. */
  256. @property(nonatomic, assign, readonly) TUIMessageCellLayout *receiveVideoMessageLayout;
  257. /**
  258. * Other message cell layout of my sent message.
  259. */
  260. @property(nonatomic, assign, readonly) TUIMessageCellLayout *sendMessageLayout;
  261. /**
  262. * Other message cell layout of my received message.
  263. */
  264. @property(nonatomic, assign, readonly) TUIMessageCellLayout *receiveMessageLayout;
  265. /**
  266. * System message cell layout.
  267. */
  268. @property(nonatomic, assign, readonly) TUIMessageCellLayout *systemMessageLayout;
  269. @end
  270. @interface TUIChatConfig_Classic (MessageBubble)
  271. /**
  272. * Enable the message display in the bubble style.
  273. * The default value is YES.
  274. */
  275. @property(nonatomic, assign) BOOL enableMessageBubbleStyle;
  276. /**
  277. * Set the background image of the sent message bubble in consecutive message.
  278. */
  279. @property (nonatomic, strong) UIImage *sendBubbleBackgroundImage;
  280. /**
  281. * Set the background image of the sent message bubble in highlight status.
  282. */
  283. @property (nonatomic, strong) UIImage *sendHighlightBubbleBackgroundImage;
  284. /**
  285. * Set the light background image when the sent message bubble needs to flicker.
  286. */
  287. @property (nonatomic, strong) UIImage *sendAnimateLightBubbleBackgroundImage;
  288. /**
  289. * Set the dark background image when the sent message bubble needs to flicker.
  290. */
  291. @property (nonatomic, strong) UIImage *sendAnimateDarkBubbleBackgroundImage;
  292. /**
  293. * Set the background image of the sent error message bubble.
  294. */
  295. @property (nonatomic, strong) UIImage *sendErrorBubbleBackgroundImage;
  296. /**
  297. * Set the background image of the received message bubble in consecutive message.
  298. */
  299. @property (nonatomic, strong) UIImage *receiveBubbleBackgroundImage;
  300. /**
  301. * Set the background image of the received message bubble in highlight status.
  302. */
  303. @property (nonatomic, strong) UIImage *receiveHighlightBubbleBackgroundImage;
  304. /**
  305. * Set the light background image when the received message bubble needs to flicker.
  306. */
  307. @property (nonatomic, strong) UIImage *receiveAnimateLightBubbleBackgroundImage;
  308. /**
  309. * Set the dark background image when the received message bubble needs to flicker.
  310. */
  311. @property (nonatomic, strong) UIImage *receiveAnimateDarkBubbleBackgroundImage;
  312. /**
  313. * Set the background image of the received error message bubble.
  314. */
  315. @property (nonatomic, strong) UIImage *receiveErrorBubbleBackgroundImage;
  316. @end
  317. @interface TUIChatConfig_Classic (InputBar)
  318. /**
  319. * DataSource for inputBar.
  320. */
  321. @property (nonatomic, weak) id<TUIChatInputBarConfigDataSource> inputBarDataSource;
  322. /**
  323. * DataSource for shortcutView above inputBar.
  324. */
  325. @property (nonatomic, weak) id<TUIChatShortcutViewDataSource> shortcutViewDataSource;
  326. /**
  327. * Show the input bar in the message list interface.
  328. * The default value is YES.
  329. */
  330. @property(nonatomic, assign) BOOL showInputBar;
  331. /**
  332. * Hide items in more menu.
  333. */
  334. + (void)hideItemsInMoreMenu:(TUIChatInputBarMoreMenuItem)items;
  335. /**
  336. * Add sticker group.
  337. */
  338. - (void)addStickerGroup:(TUIFaceGroup *)group;
  339. @end
  340. NS_ASSUME_NONNULL_END