TUIFaceView.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. /**
  4. *
  5. * 【Module Description】
  6. * - This file declares the TUIFaceViewDelegate protocol and two classes, TUIFaceGroup and TUIFaceView.
  7. * - 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
  8. * default state.
  9. * - Through this view, you can view and use all your emoticons, browse between different emoji groups, and further select and send emoticon message.
  10. * - This view has integrated the editing function of string-type expressions (such as [Smile]).
  11. *
  12. * 【Function description】
  13. * - TUIFaceView: Emoji view, which displays the emoticons of each group, and provides functions for selecting and deleting emoticons.
  14. * - TUIFaceGroup: Emoticons group. Including the initialization of the emoticons group, the positioning of a single emoticon, etc.
  15. */
  16. #import <TIMCommon/TIMCommonModel.h>
  17. #import <UIKit/UIKit.h>
  18. @class TUIFaceView;
  19. /////////////////////////////////////////////////////////////////////////////////
  20. //
  21. // TUIFaceViewDelegate
  22. //
  23. /////////////////////////////////////////////////////////////////////////////////
  24. @protocol TUIFaceViewDelegate <NSObject>
  25. /**
  26. * The callback after sliding to the specified emoticons group.
  27. * - 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
  28. * emoticon group.
  29. *
  30. * @param faceView Delegator, emoticon view. Usually, the expression view has one and only one.
  31. * @param index The index of the emoji group to which slide.
  32. */
  33. - (void)faceView:(TUIFaceView *)faceView scrollToFaceGroupIndex:(NSInteger)index;
  34. /**
  35. * The Callback after selecting a specific emoticon (index positioning).
  36. * You can use this callback to achieve:
  37. * - When a string type emoticon (such as [smile]) is clicked, add the emoticon to the input bar.
  38. * - When clicking on another type of emoji, send that emoji directly.
  39. *
  40. * @param faceView Delegator, emoticon view. Usually, the expression view has one and only one.
  41. * @param indexPath Index path, used to locate expressions. index.section: the group where the expression is located; index.row: the row where the expression
  42. * is located.
  43. */
  44. - (void)faceView:(TUIFaceView *)faceView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
  45. /**
  46. * The action callback after clicking the delete button in the emoji view.
  47. * 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
  48. * the brackets directly, instead of only deleting the rightmost "]".
  49. *
  50. * @param faceView Delegator, emoticon view. Usually, the expression view has one and only one.
  51. */
  52. - (void)faceViewDidBackDelete:(TUIFaceView *)faceView;
  53. @end
  54. /////////////////////////////////////////////////////////////////////////////////
  55. //
  56. // TUIFaceView
  57. //
  58. /////////////////////////////////////////////////////////////////////////////////
  59. /**
  60. * 【Module name】TUIFaceView
  61. * 【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
  62. * in the default state.
  63. * - Through this view, you can view all available emoticons, support emoticon grouping, select and send emoticons.
  64. * - This view has integrated the editing functions of string-type emoticons (such as [smile]), and the selection and sending functions of image-type
  65. * emoticons.
  66. */
  67. @interface TUIFaceView : UIView
  68. /**
  69. * Line view
  70. * The separtor which distinguish emoticons from other views
  71. */
  72. @property(nonatomic, strong) UIView *lineView;
  73. /**
  74. * The collectionView of emoticon view
  75. * Contains multiple lines of expressions, and cooperates with faceFlowLayout for flexible and unified view layout.
  76. */
  77. @property(nonatomic, strong) UICollectionView *faceCollectionView;
  78. /**
  79. * The flow layout of @faceCollectionView
  80. * Cooperating with faceCollectionView to make the expression view more beautiful. Supported setting layout direction, line spacing, cell spacing, etc.
  81. */
  82. @property(nonatomic, strong) UICollectionViewFlowLayout *faceFlowLayout;
  83. /**
  84. * Page control
  85. * 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
  86. * pages in the form of small dots below the emoticon page.
  87. */
  88. @property(nonatomic, strong) UIPageControl *pageControl;
  89. /**
  90. * The data of @faceView
  91. * The object stored in this NSMutableArray is TUIFaceGroup, that is, the expression group.
  92. */
  93. @property(nonatomic, strong, readonly) NSMutableArray *faceGroups;
  94. @property(nonatomic, strong, readonly) NSMutableArray *sectionIndexInGroup;
  95. @property(nonatomic, strong, readonly) NSMutableArray *pageCountInGroup;
  96. @property(nonatomic, strong, readonly) NSMutableArray *groupIndexInSection;
  97. @property(nonatomic, strong, readonly) NSMutableDictionary *itemIndexs;
  98. /**
  99. * Delegate variable, delegated
  100. * Need to implement the functionality required in the @TUIFaceViewDelegate protocol.
  101. */
  102. @property(nonatomic, weak) id<TUIFaceViewDelegate> delegate;
  103. /**
  104. * Swipe to the specified expression group.
  105. * Switch the emoticon group according to the subscript of the emoticon group clicked by the user.
  106. *
  107. * @param index The index of the destination group, starting from 0.
  108. */
  109. - (void)scrollToFaceGroupIndex:(NSInteger)index;
  110. /**
  111. * Setting data
  112. * Used to initialize TUIFaceView or update data in faceView when needed.
  113. *
  114. * @param data The data that needs to be set (TUIFaceGroup). The object stored in this NSMutableArray is TUIFaceGroup, that is, the emoticon group.
  115. */
  116. - (void)setData:(NSMutableArray *)data;
  117. @end