TUIFaceView.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. /**
  4. * 【模块说明】
  5. * - 本文件声明了 TUIFaceViewDelegate 协议以及 TUIFaceGroup 和 TUIFaceView 两个类。
  6. * - 本文件用于实现聊天窗口中的表情浏览视图,即在默认状态下点击笑脸图标打开的界面。
  7. * - 通过本视图,您可以查看并使用您的所有表情,在不同的表情分组间进行浏览,进一步进行表情的选择与发送。
  8. * - 本视图已经整合了字符串类型的表情(如[微笑])的编辑功能。
  9. *
  10. * 【功能描述】
  11. * - TUIFaceView:表情视图,展示各个分组的表情,并提供表情的选取、删除功能。
  12. * - TUIFaceGroup:表情组。包括表情组的初始化、单个表情的定位等。
  13. *
  14. *
  15. * 【Module Description】
  16. * - This file declares the TUIFaceViewDelegate protocol and two classes, TUIFaceGroup and TUIFaceView.
  17. * - This file is used to implement the emoticon browsing view in the chat window, that is, the interface opened by clicking the smiley face icon in the
  18. * default state.
  19. * - Through this view, you can view and use all your emoticons, browse between different emoji groups, and further select and send emoticon message.
  20. * - This view has integrated the editing function of string-type expressions (such as [Smile]).
  21. *
  22. * 【Function description】
  23. * - TUIFaceView: Emoji view, which displays the emoticons of each group, and provides functions for selecting and deleting emoticons.
  24. * - TUIFaceGroup: Emoticons group. Including the initialization of the emoticons group, the positioning of a single emoticon, etc.
  25. */
  26. #import <TIMCommon/TIMCommonModel.h>
  27. #import <UIKit/UIKit.h>
  28. @class TUIFaceView;
  29. /////////////////////////////////////////////////////////////////////////////////
  30. //
  31. // TUIFaceViewDelegate
  32. //
  33. /////////////////////////////////////////////////////////////////////////////////
  34. @protocol TUIFaceViewDelegate <NSObject>
  35. /**
  36. * 滑动到指定表情分组后的回调。
  37. * - 您可以通过该回调响滑动操作,进而更新表情视图的信息,展示出新表情组内的表情。
  38. *
  39. * @param faceView 委托者,表情视图。通常情况下表情视图有且仅有一个。
  40. * @param index 滑动到的表情组的索引。
  41. */
  42. /**
  43. * The callback after sliding to the specified emoticons group.
  44. * - You can use this callback to respond to the swipe operation, and then update the information of the emoticon view to display the emoticons in the new
  45. * emoticon group.
  46. *
  47. * @param faceView Delegator, emoticon view. Usually, the expression view has one and only one.
  48. * @param index The index of the emoji group to which slide.
  49. */
  50. - (void)faceView:(TUIFaceView *)faceView scrollToFaceGroupIndex:(NSInteger)index;
  51. /**
  52. * 选择某一具体表情后的回调(索引定位)。
  53. * 您可以通过该回调实现:
  54. * - 当点击字符串类型的表情(如[微笑])时,将表情添加到输入条。
  55. * - 当点击其他类型的表情时,直接发送该表情。
  56. *
  57. * @param faceView 委托者,表情视图。通常情况下表情视图有且仅有一个。
  58. * @param indexPath 索引路径,用于定位表情。index.section:表情所在分组;index.row:表情所在行。
  59. */
  60. /**
  61. * The Callback after selecting a specific emoticon (index positioning).
  62. * You can use this callback to achieve:
  63. * - When a string type emoticon (such as [smile]) is clicked, add the emoticon to the input bar.
  64. * - When clicking on another type of emoji, send that emoji directly.
  65. *
  66. * @param faceView Delegator, emoticon view. Usually, the expression view has one and only one.
  67. * @param indexPath Index path, used to locate expressions. index.section: the group where the expression is located; index.row: the row where the expression
  68. * is located.
  69. */
  70. - (void)faceView:(TUIFaceView *)faceView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
  71. /**
  72. * 点击表情视图中 删除 按钮后的操作回调。
  73. * 您可以通过该回调实现:在 inputBar 中删除整个表情字符串,比如,对于“[微笑]”,直接删除中括号以及括号中间的内容,而不是仅删除最右侧”]“。
  74. *
  75. * @param faceView 委托者,表情视图,通常情况下表情视图有且仅有一个。
  76. */
  77. /**
  78. * The action callback after clicking the delete button in the emoji view.
  79. * You can use this callback to delete the entire emoji string in the inputBar, for example, for "[smile]", delete the square brackets and the content between
  80. * the brackets directly, instead of only deleting the rightmost "]".
  81. *
  82. * @param faceView Delegator, emoticon view. Usually, the expression view has one and only one.
  83. */
  84. - (void)faceViewDidBackDelete:(TUIFaceView *)faceView;
  85. @end
  86. /////////////////////////////////////////////////////////////////////////////////
  87. //
  88. // TUIFaceView
  89. //
  90. /////////////////////////////////////////////////////////////////////////////////
  91. /**
  92. * 【模块名称】TUIFaceView
  93. * 【功能说明】用于实现聊天窗口中的表情浏览视图,即在默认状态下点击笑脸图标打开的界面。
  94. * - 通过本视图,您可以查看所有可用的表情,支持表情分组,以及表情的选择和发送。
  95. * - 本视图已经整合了字符串类型的表情(如[微笑])的编辑功能,以及图像类表情的选取与发送功能。
  96. *
  97. * 【Module name】TUIFaceView
  98. * 【Function description】It is used to realize the emoticon browsing view in the chat window, that is, the interface opened by clicking the smiley face icon
  99. * in the default state.
  100. * - Through this view, you can view all available emoticons, support emoticon grouping, select and send emoticons.
  101. * - This view has integrated the editing functions of string-type emoticons (such as [smile]), and the selection and sending functions of image-type
  102. * emoticons.
  103. */
  104. @interface TUIFaceView : UIView
  105. /**
  106. * 线视图
  107. * 视图中的分界线,区分表情和其他视图。
  108. *
  109. * Line view
  110. * The separtor which distinguish emoticons from other views
  111. */
  112. @property(nonatomic, strong) UIView *lineView;
  113. /**
  114. * 表情视图的 CollectionView
  115. * 包含多行表情,并配合 faceFlowLayout 进行灵活统一的视图布局。
  116. *
  117. * The collectionView of emoticon view
  118. * Contains multiple lines of expressions, and cooperates with faceFlowLayout for flexible and unified view layout.
  119. */
  120. @property(nonatomic, strong) UICollectionView *faceCollectionView;
  121. /**
  122. * faceCollectionView 的流水布局
  123. * 配合 faceCollectionView,使表情视图更加美观。支持设置布局方向、行间距、cell 间距等。
  124. *
  125. * The flow layout of @faceCollectionView
  126. * Cooperating with faceCollectionView to make the expression view more beautiful. Supported setting layout direction, line spacing, cell spacing, etc.
  127. */
  128. @property(nonatomic, strong) UICollectionViewFlowLayout *faceFlowLayout;
  129. /**
  130. * 分页控制
  131. * 用于实现表情的多页浏览,能够滑动切换表情页,在表情页下方以小圆点形式显示总页数以及当前页数等功能。
  132. *
  133. * Page control
  134. * It is used to realize multi-page browsing of emoticons, can slide to switch emoticon pages, and display the total number of pages and the current number of
  135. * pages in the form of small dots below the emoticon page.
  136. */
  137. @property(nonatomic, strong) UIPageControl *pageControl;
  138. /**
  139. *
  140. * faceView 中的数据。
  141. * 在此 NSMutableArray 中存放的对象为 TUIFaceGroup,即表情组。
  142. *
  143. * The data of @faceView
  144. * The object stored in this NSMutableArray is TUIFaceGroup, that is, the expression group.
  145. */
  146. @property(nonatomic, strong, readonly) NSMutableArray *faceGroups;
  147. @property(nonatomic, strong, readonly) NSMutableArray *sectionIndexInGroup;
  148. @property(nonatomic, strong, readonly) NSMutableArray *pageCountInGroup;
  149. @property(nonatomic, strong, readonly) NSMutableArray *groupIndexInSection;
  150. @property(nonatomic, strong, readonly) NSMutableDictionary *itemIndexs;
  151. /**
  152. * 委托变量,被委托者
  153. * 需要实现 TUIFaceViewDelegate 协议中要求的功能。
  154. *
  155. * Delegate variable, delegated
  156. * Need to implement the functionality required in the @TUIFaceViewDelegate protocol.
  157. */
  158. @property(nonatomic, weak) id<TUIFaceViewDelegate> delegate;
  159. /**
  160. * 滑动到指定表情分组。
  161. * 根据用户点击的表情分组的下标,切换表情分组。
  162. *
  163. * @param index 目的分组的索引,从0开始。
  164. */
  165. /**
  166. * Swipe to the specified expression group.
  167. * Switch the emoticon group according to the subscript of the emoticon group clicked by the user.
  168. *
  169. * @param index The index of the destination group, starting from 0.
  170. */
  171. - (void)scrollToFaceGroupIndex:(NSInteger)index;
  172. /**
  173. * 设置数据。
  174. * 用来进行 TUIFaceView 的初始化或在需要时更新 faceView 中的数据。
  175. *
  176. * @param data 需要设置的数据(TUIFaceGroup)。在此 NSMutableArray 中存放的对象为 TUIFaceGroup,即表情组。
  177. */
  178. /**
  179. * Setting data
  180. * Used to initialize TUIFaceView or update data in faceView when needed.
  181. *
  182. * @param data The data that needs to be set (TUIFaceGroup). The object stored in this NSMutableArray is TUIFaceGroup, that is, the emoticon group.
  183. */
  184. - (void)setData:(NSMutableArray *)data;
  185. @end