TUIBaseChatViewController.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. /**
  4. * 腾讯云通讯服务界面组件 TUIKIT - 聊天界面组件
  5. *
  6. * 本文件主要声明用于实现聊天界面的组件,支持 1v1 单聊和群聊天两种模式,其中包括:
  7. * - 消息展示区:也就是气泡展示区。
  8. * - 消息输入区:也就是让用户输入消息文字、发表情以及图片和视频的部分。
  9. *
  10. * TUIBaseChatViewController 类用于实现聊天视图的总控制器,负责将输入、消息控制器、更多视图等进行统一控制。
  11. * 本文件中声明的类与协议,能够有效的帮助您实现自定义消息格式。
  12. *
  13. * Tencent Cloud Communication Service Interface Component TUIKIT - Chat Interface Component
  14. *
  15. * This document mainly declares the components used to implement the chat interface, which supports two modes of 1v1 single chat and group chat, including:
  16. * - Message display area: that is, the bubble display area.
  17. * - Message input area: that is, the part that allows users to input message text, emoticons, pictures and videos.
  18. *
  19. * The TUIBaseChatViewController class is used to implement the general controller of the chat view, which is responsible for unified control of input, message
  20. * controller, and more views. The classes and protocols declared in this file can effectively help you implement custom message formats.
  21. *
  22. */
  23. #import <TIMCommon/TIMCommonModel.h>
  24. #import <UIKit/UIKit.h>
  25. #import "TUIBaseMessageController.h"
  26. #import "TUIChatConversationModel.h"
  27. #import "TUIInputController.h"
  28. @class TUIBaseChatViewController;
  29. /////////////////////////////////////////////////////////////////////////////////
  30. //
  31. // TUIBaseChatViewController
  32. //
  33. /////////////////////////////////////////////////////////////////////////////////
  34. /**
  35. * 【模块名称】聊天界面组件(TUIBaseChatViewController)
  36. *
  37. * 【功能说明】负责实现聊天界面的 UI 组件,包括消息展示区和消息输入区。
  38. *
  39. * TUIBaseChatViewController
  40. * 类用于实现聊天视图的总控制器,负责将聊天消息控制器(TUIBaseMessageController)、信息输入控制器(TUIInputController)和更多视图进行统一控制。
  41. *
  42. * 聊天消息控制器负责在您接收到新消息或者发送消息时在 UI 作出响应,并响应您在消息气泡上的交互操作,详情参考:Section\Chat\TUIBaseMessageController.h
  43. * 信息输入控制器负责接收您的输入,向你提供输入内容的编辑功能并进行消息的发送,详情参考:Section\Chat\Input\TUIInputController.h
  44. * 本类中包含了“更多”视图,即在您点击 UI 中“+”按钮时,能够显示出更多按钮来满足您的进一步操作,详情参考:Section\Chat\TUIMoreView.h
  45. *
  46. * Q: 如何实现自定义的个性化消息气泡功能?
  47. * A: 如果您想要实现 TUIKit 不支持的消息气泡样式,比如在消息气泡中添加投票链接等,可以参考文档:
  48. * https://cloud.tencent.com/document/product/269/37067
  49. *
  50. * 【Module name】TUIBaseChatViewController
  51. * 【Function description】Responsible for implementing the UI components of the chat interface, including the message display area and the message input area.
  52. *
  53. * The TUIBaseChatViewController class is used to implement the overall controller of the chat view, and is responsible for unified control of the chat message
  54. * controller (TUIBaseMessageController), the information input controller (TUIInputController) and more views.
  55. *
  56. * The chat message controller is responsible for responding in the UI when you receive a new message or sending a message, and respond to your interactions on
  57. * the message bubble, see: Section\Chat\TUIBaseMessageController.h The information input controller is responsible for receiving your input, providing you with
  58. * the editing function of the input content and sending messages. For details, please refer to: Section\Chat\Input\TUIInputController.h This class contains the
  59. * "more" view, that is, when you click the "+" button in the UI, more buttons can be displayed to satisfy your further operations. For details, please refer
  60. * to: Section\Chat\TUIMoreView.h
  61. *
  62. * Q: How to implement custom messages?
  63. * A: If you want to implement a message style that TUIKit does not support, such as adding a voting link to the message style, you can refer to the
  64. * documentation: https://cloud.tencent.com/document/product/269/37067
  65. */
  66. @interface TUIBaseChatViewController : UIViewController
  67. @property(nonatomic, strong) TUIChatConversationModel *conversationData;
  68. /**
  69. * 高亮文本
  70. * 在搜索场景下,当 highlightKeyword 不为空时,且与 locateMessage 匹配时,打开聊天会话页面会高亮显示当前的 cell
  71. *
  72. * Highlight text
  73. * In the search scenario, when highlightKeyword is not empty and matches @locateMessage, opening the chat session page will highlight the current cell
  74. */
  75. @property(nonatomic, copy) NSString *highlightKeyword;
  76. /**
  77. * 定位消息
  78. * 在搜索场景下,当 locateMessage 不为空时,打开聊天会话页面会自动定位到此处
  79. *
  80. * Locate message
  81. * In the search scenario, when locateMessage is not empty, opening the chat session page will automatically scroll to here
  82. */
  83. @property(nonatomic, strong) V2TIMMessage *locateMessage;
  84. /**
  85. * 未读数展示 view
  86. * View for displaying unread count number
  87. */
  88. @property TUIUnReadView *unRead;
  89. /**
  90. * TUIKit 聊天消息控制器
  91. * 负责消息气泡的展示,同时负责响应用户对于消息气泡的交互,比如:点击消息发送者头像、轻点消息、长按消息等操作。
  92. * 聊天消息控制器的详细信息请参考 TUIChat\UI\Chat\TUIBaseMessageController.h
  93. *
  94. * TUIKit message controller
  95. * It is responsible for the display of message bubbles, and at the same time, it is responsible for responding to the user's interaction with the message
  96. * bubbles, such as: clicking on the avatar of the message sender, tapping the message, and long-pressing the message. For more information about the chat
  97. * message controller, please refer to TUIChat\UI\Chat\TUIBaseMessageController.h
  98. */
  99. @property TUIBaseMessageController *messageController;
  100. /**
  101. * TUIKit 信息输入控制器
  102. * 负责接收用户输入,同时显示“+”按钮与语音输入按钮、表情按钮等。
  103. * 同时 TUIInputController 整合了消息的发送功能,您可以直接使用 TUIInputController 进行消息的输入采集与发送。
  104. * 信息输入控制器的详细信息请参考 TUIChat\UI\Input\TUIInputController.h
  105. *
  106. * TUIKit input controller
  107. * Responsible for receiving user input, and displaying the "+" button, voice input button, emoticon button, etc.
  108. * At the same time, TUIInputController integrates the message sending function, and you can directly use TUIInputController to collect and send message input.
  109. * Please refer to TUIChat\UI\Input\TUIInputController.h for details of the message input controller
  110. */
  111. @property TUIInputController *inputController;
  112. /**
  113. * 更多菜单视图数据的数据组
  114. * 更多菜单视图包括:拍摄、图片、视频、文件。详细信息请参考 Section\Chat\TUIMoreView.h
  115. *
  116. * Data group for more menu view data
  117. * More menu views include: Capture, Picture, Video, File. See Section\Chat\TUIMoreView.h for details
  118. */
  119. @property NSArray<TUIInputMoreCellData *> *moreMenus;
  120. /**
  121. * 是否需要滑动到底部
  122. * 通常用于跳转到其他界面,返回后需要滑动到底部的场景
  123. *
  124. * Need to scroll to the bottom
  125. * It is usually used to push to another VC and need to scroll to the bottom after returning.
  126. */
  127. @property(nonatomic, assign) BOOL needScrollToBottom;
  128. - (void)sendMessage:(V2TIMMessage *)message;
  129. - (void)sendMessage:(V2TIMMessage *)message placeHolderCellData:(TUIMessageCellData *)placeHolderCellData;
  130. /**
  131. * 在聊天界面顶部添加自定义视图,该视图会常驻在消息列表顶部,不会随着消息列表上滑而上滑。
  132. * 不设置则默认不显示。
  133. */
  134. + (void)setCustomTopView:(UIView *)view;
  135. /**
  136. * 获取聊天界面顶部的自定义视图。
  137. */
  138. + (UIView *)customTopView;
  139. // 新增
  140. - (void)checkTitle:(BOOL)force;
  141. // 多选
  142. - (void)onSelectMessageMenu:(NSInteger)menuType withData:(TUIMessageCellData *)data;
  143. - (void)messageController:(TUIBaseMessageController *)controller onRelyMessage:(nonnull TUIMessageCellData *)data;
  144. - (void)messageController:(TUIBaseMessageController *)controller onReferenceMessage:(TUIMessageCellData *)data;
  145. - (void)messageController:(TUIBaseMessageController *)controller modifyMessage:(nonnull TUIMessageCellData *)cellData reactEmoji:(NSString *)emojiName;
  146. - (void)messageController:(TUIBaseMessageController *)controller onReEditMessage:(TUIMessageCellData *)data;
  147. @end