TUIMessageCellConfig.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Created by Tencent on 2023/07/20.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. #import <UIKit/UIKit.h>
  4. @class TUIMessageCellData;
  5. typedef NSString * TUICellDataClassName;
  6. typedef NSString * TUICellClassName;
  7. typedef NSString * TUIBusinessID;
  8. NS_ASSUME_NONNULL_BEGIN
  9. @interface TUIMessageCellConfig : NSObject
  10. /**
  11. * 1.
  12. * Bind the message tableView, and TUIMessageCellConfig will perform built-in and customized cell bindings for the tableView internally.
  13. */
  14. - (void)bindTableView:(UITableView *)tableView;
  15. /**
  16. * 2.
  17. * Bind cell and cellData to the tableView, and the binding can be called externally.
  18. */
  19. - (void)bindMessageCellClass:(Class)cellClass cellDataClass:(Class)cellDataClass reuseID:(NSString *)reuseID;
  20. @end
  21. @interface TUIMessageCellConfig (MessageCellWidth)
  22. + (void)setMaxTextSize:(CGSize)maxTextSz;
  23. @end
  24. @interface TUIMessageCellConfig (MessageCellHeight)
  25. /**
  26. * Get key of cache
  27. */
  28. - (NSString *)getHeightCacheKey:(TUIMessageCellData *)msg;
  29. /**
  30. * Get the height, and the cache will be queried first.
  31. *
  32. */
  33. - (CGFloat)getHeightFromMessageCellData:(TUIMessageCellData *)cellData;
  34. /**
  35. * Get the estimated height, and the cache will be queried first.
  36. */
  37. - (CGFloat)getEstimatedHeightFromMessageCellData:(TUIMessageCellData *)cellData;
  38. /**
  39. * Remove cache
  40. */
  41. - (void)removeHeightCacheOfMessageCellData:(TUIMessageCellData *)cellData;
  42. @end
  43. @interface TUIMessageCellConfig (CustomMessageRegister)
  44. /**
  45. * Register custom message
  46. *
  47. * @param messageCellName cell
  48. * @param messageCellDataName cellData
  49. * @param businessID
  50. */
  51. + (void)registerCustomMessageCell:(TUICellClassName)messageCellName
  52. messageCellData:(TUICellDataClassName)messageCellDataName
  53. forBusinessID:(TUIBusinessID)businessID;
  54. /**
  55. * Register custom message (This is for internal use of TUIKit plugin, please use registerCustomMessageCell:messageCellData:forBusinessID: instead.)
  56. *
  57. * @param messageCellName (custom message cell name)
  58. * @param messageCellDataName (custom message cell data)
  59. * @param businessID (custom message businessID)
  60. * @param isPlugin (From Plugin)
  61. */
  62. + (void)registerCustomMessageCell:(TUICellClassName)messageCellName
  63. messageCellData:(TUICellDataClassName)messageCellDataName
  64. forBusinessID:(TUIBusinessID)businessID
  65. isPlugin:(BOOL)isPlugin;
  66. /**
  67. * Get all custom message UI with enumeration
  68. */
  69. + (void)enumerateCustomMessageInfo:(void(^)(NSString *messageCellName,
  70. NSString *messageCellDataName,
  71. NSString *businessID,
  72. BOOL isPlugin))callback;
  73. /**
  74. * Get the class of custom message cellData based on businessID
  75. */
  76. + (nullable Class)getCustomMessageCellDataClass:(NSString *)businessID;
  77. /**
  78. * Whether the custom message cell data is defined in plugin
  79. */
  80. + (BOOL)isPluginCustomMessageCellData:(TUIMessageCellData *)data;
  81. @end
  82. NS_ASSUME_NONNULL_END