// // shareSecretTableViewCell.m // 双子星云手机 // // Created by xd h on 2024/5/17. // #import "shareSecretTableViewCell.h" #import @interface shareSecretTableViewCell () @property(nonatomic,strong)UIImageView *mImageView; @property(nonatomic,strong)UILabel *titleLabel; @property(nonatomic,strong)UILabel *titleLabel2; @end @implementation shareSecretTableViewCell - (void)awakeFromNib { [super awakeFromNib]; // Initialization code } - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self drawView]; } return self; } - (void)drawView { /*图片*/ _mImageView = [[UIImageView alloc] init]; [_mImageView setBackgroundColor:[UIColor clearColor]]; _mImageView.image = [UIImage imageNamed:@"uploadFile_file_icon"]; [self.contentView addSubview:_mImageView]; [_mImageView setContentMode:(UIViewContentModeScaleAspectFit)]; [_mImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.width.mas_equalTo(36); make.height.mas_equalTo(36); make.centerY.equalTo(self.mas_centerY); }]; /**标题*/ _titleLabel = [[UILabel alloc] init]; [self.contentView addSubview:_titleLabel]; _titleLabel.font = [UIFont boldSystemFontOfSize:14.f]; _titleLabel.numberOfLines = 2; [_titleLabel setTextColor:HW0A132BColor]; [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_mImageView.mas_right).offset(5.f); make.right.mas_equalTo(-5.f); make.centerY.equalTo(self.mas_centerY).offset(-10); //make.top.mas_equalTo(5.f); }]; /**副标题*/ _titleLabel2 = [[UILabel alloc] init]; [self.contentView addSubview:_titleLabel2]; _titleLabel2.font = [UIFont systemFontOfSize:12.f]; //[titleLabel2 setTextAlignment:(NSTextAlignmentRight)]; [_titleLabel2 setTextColor:HW666666Color]; [_titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_mImageView.mas_right).offset(5.f); make.right.mas_equalTo(-5.f); //make.centerY.equalTo(self.mas_centerY); make.top.equalTo(_titleLabel.mas_bottom).offset(5); }]; } - (void)setDataModel:(NASFilePicDataArrModel *)dataModel { UIImage *defaultImage = [UIImage imageNamed:@"uploadFile_image"]; if(0)//([self.fileType isEqualToString:@"video"]) { defaultImage = [UIImage imageNamed:@"uploadFile_Video"]; _mImageView.image = defaultImage; } else { NSString *filePath = dataModel.path; NSString *urlStr = ksharedAppDelegate.NASFileByBoxService; NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath]; //iOS格式的图片 代理拿不到缩略图 if([filePath rangeOfString:@".HEIC"].location != NSNotFound ||[filePath rangeOfString:@".heic"].location != NSNotFound){ fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath]; } [_mImageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:defaultImage completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) { // if(image){ // HLog(@"11图片1:%@",imageURL.absoluteString); // } // else{ // HLog(@"11图片0:%@",imageURL.absoluteString); // } }]; } _titleLabel.text = dataModel.name; NSString * totalSizeStr = nil; NSInteger totalSize_k = dataModel.size / 1024; if(totalSize_k < 1024){ totalSizeStr = [[NSString alloc] initWithFormat:@"%ldKB",totalSize_k]; } else if( totalSize_k >= 1024 && totalSize_k < 1024*1024){ totalSizeStr = [[NSString alloc] initWithFormat:@"%.2fMB",totalSize_k/1024.0]; } else{ totalSizeStr = [[NSString alloc] initWithFormat:@"%.2fG",totalSize_k/1024.0/1024.0]; } _titleLabel2.text = [[NSString alloc] initWithFormat:@"%@ %@",totalSizeStr,dataModel.time]; } @end