TUIImageMessageCellData.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. #import <TIMCommon/TUIBubbleMessageCellData.h>
  4. #import "TUIChatDefine.h"
  5. #import "TUIMessageItem.h"
  6. NS_ASSUME_NONNULL_BEGIN
  7. /////////////////////////////////////////////////////////////////////////////////
  8. //
  9. // TUIImageMessageCellData
  10. //
  11. /////////////////////////////////////////////////////////////////////////////////
  12. /**
  13. *
  14. * 【Module name】 TUIImageMessageCellData
  15. * 【Function description】It is used to realize the picture bubble in the chat window, including the display of picture message sending progress.
  16. * At the same time, this module already supports three different types of "thumbnail", "large image" and "original image", and
  17. * has handled the business logic of displaying the corresponding image type under appropriate circumstances:
  18. * 1. Thumbnail - By default, you see thumbnails in the chat window, which is smaller and saves traffic.
  19. * 2. Large image - If the user clicks on the thumbnail, they see a larger image with a better resolution.
  20. * 3. Original image - If the sender chooses to send the original image, the recipient will see the "original image" button which can click to download the
  21. * image with the original size.
  22. */
  23. @interface TUIImageMessageCellData : TUIBubbleMessageCellData <TUIMessageCellDataFileUploadProtocol>
  24. @property(nonatomic, strong) UIImage *thumbImage;
  25. @property(nonatomic, strong) UIImage *originImage;
  26. @property(nonatomic, strong) UIImage *largeImage;
  27. /**
  28. *
  29. * The file storage path
  30. *
  31. * @note
  32. * @path is maintained by the program by default, you can directly obtain the demo storage path by importing TIMDefine.h and referencing TUIKit_Image_Path
  33. * Other routes are also available if you have further individual needs
  34. */
  35. @property(nonatomic, strong) NSString *path;
  36. @property(nonatomic, assign) NSInteger length;
  37. /**
  38. *
  39. * The set of image items
  40. *
  41. * @note
  42. * There are usually three imageItems stored in @items, namely thumb (thumb image), origin (original image), and large (large image), which is convenient to
  43. * obtain images flexibly according to needs.
  44. *
  45. */
  46. @property(nonatomic, strong) NSMutableArray *items;
  47. /**
  48. * The progress of loading thumbnail
  49. */
  50. @property(nonatomic, assign) NSUInteger thumbProgress;
  51. /**
  52. * The progress of loading origin image
  53. */
  54. @property(nonatomic, assign) NSUInteger originProgress;
  55. /**
  56. * The progress of loading large image
  57. */
  58. @property(nonatomic, assign) NSUInteger largeProgress;
  59. /**
  60. * The progress of uploading (sending)
  61. */
  62. @property(nonatomic, assign) NSUInteger uploadProgress;
  63. @property(nonatomic, assign) BOOL isSuperLongImage;
  64. /**
  65. * Downloading image.
  66. * This method integrates and calls the IM SDK, and obtains images from sever through the interface provided by the SDK.
  67. * 1. Before downloading the file from server, it will try to read file from local when the file exists in the local.
  68. * 2. If the file is not exist in the local, it will download from server through the api named @getImage which provided by the class of TIMImage in the IMSDK.
  69. * - The download progress (percentage value) is updated through the callback of the IMSDK.
  70. * - There are two parameters which is @curSize and @totalSize in the callback of IMSDK. The progress value equals to curSize * 100 / totalSize.
  71. * - The type of items in the image message is TIMElem. You can obtain image list from the paramter named imageList provided by TIMElem, which including
  72. * original image、large image and thumbnail and you can obtain the image from it with the @imageType.
  73. * 3. The image obtained through the SDK interface is a binary file, which needs to be decoded first, converted to CGIamge for decoding, and then packaged as a
  74. * UIImage before it can be used.
  75. * 4. When finished download, the image will be storaged to the @path.
  76. */
  77. - (void)downloadImage:(TUIImageType)type;
  78. - (void)downloadImage:(TUIImageType)type finish:(TUIImageMessageDownloadCallback)finish;
  79. /**
  80. *
  81. * Decode the image and assign the image to a variable of the corresponding type (@thumbImage, @largeImage or @originImage).
  82. */
  83. - (void)decodeImage:(TUIImageType)type;
  84. /**
  85. *
  86. * Getting image file path
  87. */
  88. - (NSString *)getImagePath:(TUIImageType)type isExist:(BOOL *)isExist;
  89. @end
  90. NS_ASSUME_NONNULL_END