EaseMessageCell.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /************************************************************
  2. * * Hyphenate CONFIDENTIAL
  3. * __________________
  4. * Copyright (C) 2016 Hyphenate Inc. All rights reserved.
  5. *
  6. * NOTICE: All information contained herein is, and remains
  7. * the property of Hyphenate Inc.
  8. * Dissemination of this information or reproduction of this material
  9. * is strictly forbidden unless prior written permission is obtained
  10. * from Hyphenate Inc.
  11. */
  12. #import <UIKit/UIKit.h>
  13. #import "IModelChatCell.h"
  14. #import "IMessageModel.h"
  15. #import "EaseBubbleView.h"
  16. /** @brief 缩略图宽度(当缩略图宽度为0或者宽度大于高度时) */
  17. #define kEMMessageImageSizeWidth 120
  18. /** @brief 缩略图高度(当缩略图高度为0或者宽度小于高度时) */
  19. #define kEMMessageImageSizeHeight 120
  20. /** @brief 位置消息cell的高度 */
  21. #define kEMMessageLocationHeight 95
  22. /** @brief 语音消息cell的高度 */
  23. #define kEMMessageVoiceHeight 23
  24. extern CGFloat const EaseMessageCellPadding;
  25. typedef enum{
  26. EaseMessageCellEvenVideoBubbleTap, /** @brief 视频消息cell点击 */
  27. EaseMessageCellEventLocationBubbleTap, /** @brief 位置消息cell点击 */
  28. EaseMessageCellEventImageBubbleTap, /** @brief 图片消息cell点击 */
  29. EaseMessageCellEventAudioBubbleTap, /** @brief 语音消息cell点击 */
  30. EaseMessageCellEventFileBubbleTap, /** @brief 文件消息cell点击 */
  31. EaseMessageCellEventCustomBubbleTap, /** @brief 自定义gif图片消息cell点击 */
  32. }EaseMessageCellTapEventType;
  33. @protocol EaseMessageCellDelegate;
  34. @interface EaseMessageCell : UITableViewCell<IModelChatCell>
  35. {
  36. UIButton *_statusButton;
  37. UILabel *_hasRead;
  38. EaseBubbleView *_bubbleView;
  39. UIActivityIndicatorView *_activity;
  40. NSLayoutConstraint *_statusWidthConstraint;
  41. }
  42. @property (weak, nonatomic) id<EaseMessageCellDelegate> delegate;
  43. @property (nonatomic, strong) UIActivityIndicatorView *activity;
  44. @property (strong, nonatomic) UIImageView *avatarView;
  45. @property (strong, nonatomic) UILabel *nameLabel;
  46. @property (strong, nonatomic) UIButton *statusButton;
  47. @property (strong, nonatomic) UILabel *hasRead;
  48. /** @brief 气泡视图 */
  49. @property (strong, nonatomic) EaseBubbleView *bubbleView;
  50. @property (strong, nonatomic) id<IMessageModel> model;
  51. /*
  52. * 状态按钮尺寸
  53. */
  54. @property (nonatomic) CGFloat statusSize UI_APPEARANCE_SELECTOR; //default 20;
  55. /*
  56. * 加载尺寸
  57. */
  58. @property (nonatomic) CGFloat activitySize UI_APPEARANCE_SELECTOR; //default 20;
  59. /*
  60. * 聊天气泡的最大宽度
  61. */
  62. @property (nonatomic) CGFloat bubbleMaxWidth UI_APPEARANCE_SELECTOR; //default 200;
  63. @property (nonatomic) UIEdgeInsets bubbleMargin UI_APPEARANCE_SELECTOR; //default UIEdgeInsetsMake(8, 0, 8, 0);
  64. @property (nonatomic) UIEdgeInsets leftBubbleMargin UI_APPEARANCE_SELECTOR; //default UIEdgeInsetsMake(8, 15, 8, 10);
  65. @property (nonatomic) UIEdgeInsets rightBubbleMargin UI_APPEARANCE_SELECTOR; //default UIEdgeInsetsMake(8, 10, 8, 15);
  66. /*
  67. * 发送者气泡图片
  68. */
  69. @property (strong, nonatomic) UIImage *sendBubbleBackgroundImage UI_APPEARANCE_SELECTOR;
  70. /*
  71. * 接收者气泡图片
  72. */
  73. @property (strong, nonatomic) UIImage *recvBubbleBackgroundImage UI_APPEARANCE_SELECTOR;
  74. /*
  75. * 消息显示字体
  76. */
  77. @property (nonatomic) UIFont *messageTextFont UI_APPEARANCE_SELECTOR; //default [UIFont systemFontOfSize:15];
  78. /*
  79. * 消息显示颜色
  80. */
  81. @property (nonatomic) UIColor *messageTextColor UI_APPEARANCE_SELECTOR; //default [UIColor blackColor];
  82. /*
  83. * 位置消息显示字体
  84. */
  85. @property (nonatomic) UIFont *messageLocationFont UI_APPEARANCE_SELECTOR; //default [UIFont systemFontOfSize:12];
  86. /*
  87. * 位置消息显示颜色
  88. */
  89. @property (nonatomic) UIColor *messageLocationColor UI_APPEARANCE_SELECTOR; //default [UIColor whiteColor];
  90. /*
  91. * 发送者语音消息播放图片
  92. */
  93. @property (nonatomic) NSArray *sendMessageVoiceAnimationImages UI_APPEARANCE_SELECTOR;
  94. /*
  95. * 接收者语音消息播放图片
  96. */
  97. @property (nonatomic) NSArray *recvMessageVoiceAnimationImages UI_APPEARANCE_SELECTOR;
  98. /*
  99. * 语音消息显示颜色
  100. */
  101. @property (nonatomic) UIColor *messageVoiceDurationColor UI_APPEARANCE_SELECTOR; //default [UIColor grayColor];
  102. /*
  103. * 语音消息显示字体
  104. */
  105. @property (nonatomic) UIFont *messageVoiceDurationFont UI_APPEARANCE_SELECTOR; //default [UIFont systemFontOfSize:12];
  106. /*
  107. * 语音消息显示宽度
  108. */
  109. @property (nonatomic) CGFloat voiceCellWidth UI_APPEARANCE_SELECTOR; //default 75;
  110. /*
  111. * 文件消息名称显示字体
  112. */
  113. @property (nonatomic) UIFont *messageFileNameFont UI_APPEARANCE_SELECTOR; //default [UIFont systemFontOfSize:13];
  114. /*
  115. * 文件消息名称显示颜色
  116. */
  117. @property (nonatomic) UIColor *messageFileNameColor UI_APPEARANCE_SELECTOR; //default [UIColor blackColor];
  118. /*
  119. * 文件消息显示字体
  120. */
  121. @property (nonatomic) UIFont *messageFileSizeFont UI_APPEARANCE_SELECTOR; //default [UIFont systemFontOfSize:11];
  122. /*
  123. * 文件消息显示颜色
  124. */
  125. @property (nonatomic) UIColor *messageFileSizeColor UI_APPEARANCE_SELECTOR; //default [UIColor grayColor];
  126. /*
  127. * @param cell
  128. * @param
  129. * @param 消息model
  130. */
  131. - (instancetype)initWithStyle:(UITableViewCellStyle)style
  132. reuseIdentifier:(NSString *)reuseIdentifier
  133. model:(id<IMessageModel>)model;
  134. /*
  135. *
  136. *
  137. * @param 消息model
  138. *
  139. * @result
  140. */
  141. + (NSString *)cellIdentifierWithModel:(id<IMessageModel>)model;
  142. /*
  143. *
  144. *
  145. * @param 消息model
  146. *
  147. * @result cell高度
  148. */
  149. + (CGFloat)cellHeightWithModel:(id<IMessageModel>)model;
  150. @end
  151. @protocol EaseMessageCellDelegate <NSObject>
  152. @optional
  153. /*
  154. * 消息点击回调
  155. *
  156. * @param 消息model
  157. */
  158. - (void)messageCellSelected:(id<IMessageModel>)model;
  159. /*
  160. * 状态按钮点击回调
  161. *
  162. * @param 消息model
  163. * @param 当前cell
  164. */
  165. - (void)statusButtonSelcted:(id<IMessageModel>)model withMessageCell:(EaseMessageCell*)messageCell;
  166. /*
  167. * 头像点击回调
  168. *
  169. * @param 消息model
  170. */
  171. - (void)avatarViewSelcted:(id<IMessageModel>)model;
  172. @end