shareSecretTableViewCell.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //
  2. // shareSecretTableViewCell.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/17.
  6. //
  7. #import "shareSecretTableViewCell.h"
  8. #import <SDWebImage/SDWebImage.h>
  9. @interface shareSecretTableViewCell ()
  10. @property(nonatomic,strong)UIImageView *mImageView;
  11. @property(nonatomic,strong)UILabel *titleLabel;
  12. @property(nonatomic,strong)UILabel *titleLabel2;
  13. @end
  14. @implementation shareSecretTableViewCell
  15. - (void)awakeFromNib {
  16. [super awakeFromNib];
  17. // Initialization code
  18. }
  19. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  20. {
  21. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  22. if (self)
  23. {
  24. [self drawView];
  25. }
  26. return self;
  27. }
  28. - (void)drawView
  29. {
  30. /*图片*/
  31. _mImageView = [[UIImageView alloc] init];
  32. [_mImageView setBackgroundColor:[UIColor clearColor]];
  33. _mImageView.image = [UIImage imageNamed:@"uploadFile_file_icon"];
  34. [self.contentView addSubview:_mImageView];
  35. [_mImageView setContentMode:(UIViewContentModeScaleAspectFit)];
  36. [_mImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.mas_equalTo(15);
  38. make.width.mas_equalTo(36);
  39. make.height.mas_equalTo(36);
  40. make.centerY.equalTo(self.mas_centerY);
  41. }];
  42. /**标题*/
  43. _titleLabel = [[UILabel alloc] init];
  44. [self.contentView addSubview:_titleLabel];
  45. _titleLabel.font = [UIFont boldSystemFontOfSize:14.f];
  46. _titleLabel.numberOfLines = 2;
  47. [_titleLabel setTextColor:HW0A132BColor];
  48. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.equalTo(_mImageView.mas_right).offset(5.f);
  50. make.right.mas_equalTo(-5.f);
  51. make.centerY.equalTo(self.mas_centerY).offset(-10);
  52. //make.top.mas_equalTo(5.f);
  53. }];
  54. /**副标题*/
  55. _titleLabel2 = [[UILabel alloc] init];
  56. [self.contentView addSubview:_titleLabel2];
  57. _titleLabel2.font = [UIFont systemFontOfSize:12.f];
  58. //[titleLabel2 setTextAlignment:(NSTextAlignmentRight)];
  59. [_titleLabel2 setTextColor:HW666666Color];
  60. [_titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.equalTo(_mImageView.mas_right).offset(5.f);
  62. make.right.mas_equalTo(-5.f);
  63. //make.centerY.equalTo(self.mas_centerY);
  64. make.top.equalTo(_titleLabel.mas_bottom).offset(5);
  65. }];
  66. }
  67. - (void)setDataModel:(NASFilePicDataArrModel *)dataModel
  68. {
  69. UIImage *defaultImage = [UIImage imageNamed:@"uploadFile_image"];
  70. if(0)//([self.fileType isEqualToString:@"video"])
  71. {
  72. defaultImage = [UIImage imageNamed:@"uploadFile_Video"];
  73. _mImageView.image = defaultImage;
  74. }
  75. else
  76. {
  77. NSString *filePath = dataModel.path;
  78. NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
  79. NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
  80. //iOS格式的图片 代理拿不到缩略图
  81. if([filePath rangeOfString:@".HEIC"].location != NSNotFound
  82. ||[filePath rangeOfString:@".heic"].location != NSNotFound){
  83. fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
  84. }
  85. [_mImageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:defaultImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
  86. // if(image){
  87. // HLog(@"11图片1:%@",imageURL.absoluteString);
  88. // }
  89. // else{
  90. // HLog(@"11图片0:%@",imageURL.absoluteString);
  91. // }
  92. }];
  93. }
  94. _titleLabel.text = dataModel.name;
  95. NSString * totalSizeStr = nil;
  96. NSInteger totalSize_k = dataModel.size / 1024;
  97. if(totalSize_k < 1024){
  98. totalSizeStr = [[NSString alloc] initWithFormat:@"%ldKB",totalSize_k];
  99. }
  100. else if( totalSize_k >= 1024 && totalSize_k < 1024*1024){
  101. totalSizeStr = [[NSString alloc] initWithFormat:@"%.2fMB",totalSize_k/1024.0];
  102. }
  103. else{
  104. totalSizeStr = [[NSString alloc] initWithFormat:@"%.2fG",totalSize_k/1024.0/1024.0];
  105. }
  106. _titleLabel2.text = [[NSString alloc] initWithFormat:@"%@ %@",totalSizeStr,dataModel.time];
  107. }
  108. @end