QYCustomModel.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // QYCustomModel.h
  3. // QYSDK
  4. //
  5. // Created by Netease on 2018/11/22.
  6. // Copyright © 2018 Netease. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. @class QYCustomMessage;
  11. /**
  12. * model布局协议
  13. */
  14. @protocol QYCustomModelLayoutDataSource <NSObject>
  15. @required
  16. /**
  17. * model对应的cell复用标识(必须)
  18. */
  19. - (NSString *)cellReuseIdentifier;
  20. @optional
  21. /**
  22. * 视图大小
  23. * @discussion
  24. * 1. 若显示气泡,则contentView位于气泡内部,气泡有默认最大宽度bubbleMaxWidth
  25. * 2. 若不显示气泡,仅显示头像,则contentView位于头像另一侧
  26. * 3. 若不显示头像及气泡,则contentView为整个cell,宽度固定为table宽度
  27. * @param bubbleMaxWidth 气泡最大宽度
  28. */
  29. - (CGSize)contentSizeForBubbleMaxWidth:(CGFloat)bubbleMaxWidth;
  30. /**
  31. * 是否显示头像,默认显示
  32. */
  33. - (BOOL)needShowAvatar;
  34. /**
  35. * 是否显示气泡,默认显示
  36. */
  37. - (BOOL)needShowBubble;
  38. /**
  39. * 内容视图距离气泡的内间距,默认UIEdgeInsetsZero
  40. */
  41. - (UIEdgeInsets)contentViewInsets;
  42. /**
  43. * 气泡距离整个cell的内间距,默认UIEdgeInsetsZero
  44. */
  45. - (UIEdgeInsets)bubbleViewInsets;
  46. /**
  47. * 头像与气泡间距,默认5pt
  48. */
  49. - (CGFloat)avatarBubbleSpace;
  50. @end
  51. /**
  52. * 自定义消息数据源基类(即用于消息列表刷新的数据源)
  53. * 使用方法:针对需自定义的消息数据源,写子类继承QYCustomModel,并实现QYCustomModelLayoutDataSource协议
  54. */
  55. @interface QYCustomModel : NSObject <QYCustomModelLayoutDataSource>
  56. /**
  57. * 消息数据
  58. */
  59. @property (nonatomic, strong, readonly) QYCustomMessage *message;
  60. @end