// // audioPlayListViewCell.m // 双子星云手机 // // Created by xd h on 2024/7/15. // #import "audioPlayListViewCell.h" #import "FLAnimatedImage.h" @interface audioPlayListViewCell () @property(nonatomic, strong) FLAnimatedImageView *playingGifView; @end @implementation audioPlayListViewCell - (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 { _cellBgView = [[UIView alloc] init]; [self.contentView addSubview:_cellBgView]; _cellBgView.backgroundColor = [UIColor whiteColor]; [_cellBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0.f); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); make.width.mas_equalTo(SCREEN_W); }]; /**时间*/ // _timeLabel = [[UILabel alloc] init]; // [_cellBgView addSubview:_timeLabel]; // _timeLabel.font = [UIFont systemFontOfSize:12.f]; // //[titleLabel2 setTextAlignment:(NSTextAlignmentRight)]; // [_timeLabel setTextColor:[UIColor hwColor:@"#828D9A"]]; // [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.mas_equalTo(0.f); // make.left.mas_equalTo(15); // //make.centerY.equalTo(cellBgView.mas_centerY); // make.top.mas_equalTo(0); // make.height.mas_equalTo(20); // }]; /*图片*/ _mImageView = [[UIImageView alloc] init]; [_mImageView setBackgroundColor:[UIColor clearColor]]; _mImageView.image = [UIImage imageNamed:@"uploadFile_audio"]; [_cellBgView addSubview:_mImageView]; [_mImageView setContentMode:(UIViewContentModeScaleAspectFit)]; [_mImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); make.width.mas_equalTo(42); make.height.mas_equalTo(42); make.centerY.equalTo(self.mas_centerY); }]; _checkButton = [[UIButton alloc] init]; [_checkButton setImage:[UIImage imageNamed:@"nas_audio_del_icon"] forState:UIControlStateNormal]; //[_checkButton setImage:[UIImage imageNamed:@"upload_file_check"] forState:UIControlStateSelected]; [_cellBgView addSubview:_checkButton]; [_checkButton mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-15.f); make.centerY.equalTo(self.mas_centerY); make.width.mas_equalTo(36.f); make.height.mas_equalTo(36.f); }]; [_checkButton addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventTouchUpInside)]; /**标题*/ _titleLabel = [[UILabel alloc] init]; [_cellBgView addSubview:_titleLabel]; _titleLabel.font = [UIFont boldSystemFontOfSize:14.f]; _titleLabel.numberOfLines = 2; _titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; [_titleLabel setTextColor:HW0A132BColor]; [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_mImageView.mas_right).offset(5.f); make.right.equalTo(_checkButton.mas_left).offset(-5.f); //make.centerY.equalTo(cellBgView.mas_centerY); make.top.equalTo(_mImageView.mas_top); }]; /**副标题*/ _contentLabel = [[UILabel alloc] init]; [_cellBgView addSubview:_contentLabel]; _contentLabel.font = [UIFont systemFontOfSize:12.f]; _contentLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; //[titleLabel2 setTextAlignment:(NSTextAlignmentRight)]; [_contentLabel setTextColor:HW666666Color]; [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(_titleLabel.mas_right); make.left.mas_equalTo(_titleLabel.mas_left); //make.centerY.equalTo(cellBgView.mas_centerY); make.top.equalTo(_titleLabel.mas_bottom).offset(5.0); }]; FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"playingAudioGif" withExtension:@"gif"]]]; _playingGifView = [[FLAnimatedImageView alloc] init]; [_playingGifView setContentMode:UIViewContentModeScaleAspectFill]; [_playingGifView setBackgroundColor:[ UIColor clearColor]]; _playingGifView.animatedImage = image; [_cellBgView addSubview:_playingGifView]; [_playingGifView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(_checkButton.mas_centerX); make.centerY.mas_equalTo(_checkButton.mas_centerY); make.width.mas_equalTo(40); make.height.mas_equalTo(40); }]; } - (void)maskSwitchPressed:(UIButton *)maskSwitch{ maskSwitch.selected = !maskSwitch.selected; if(_didClickSwitch){ _didClickSwitch(maskSwitch.selected); } } - (void)setCurLastFileModel:(lastFileModel *)curLastFileModel { _curLastFileModel = curLastFileModel; _checkButton.selected = _curLastFileModel.isSelectType; NSString *filePath = _curLastFileModel.path; NSString *urlStr = ksharedAppDelegate.NASFileByBoxService; //NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath]; _titleLabel.text = _curLastFileModel.name; NSString *dateStr = _curLastFileModel.time; //_timeLabel.text = dateStr; NSString * totalSizeStr = nil; NSInteger totalSize_k = _curLastFileModel.size / 1024; if(totalSize_k == 0){ totalSize_k = 1; } 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]; } // NSString *path = _curLastFileModel.path; // if([path containsString:@"mnt/media_rw"]){ // path = [path stringByReplacingOccurrencesOfString:@"mnt/media_rw" withString:NSLocalizedString(@"disk_Extra_default_tip",nil)]; // } // else if([path containsString:@"storage/emulated/0"]){ // path = [path stringByReplacingOccurrencesOfString:@"storage/emulated/0" withString:NSLocalizedString(@"disk_phone_default_tip",nil)]; // } // else if([path containsString:@"sdcard"]){ // path = [path stringByReplacingOccurrencesOfString:@"sdcard" withString:NSLocalizedString(@"disk_phone_default_tip",nil)]; // } //NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",totalSizeStr,path]; NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",totalSizeStr,dateStr]; _contentLabel.text = totalStr; if (_curLastFileModel.isOffLineType && !_curLastFileModel.isDownDoneType) { _titleLabel.textColor = HW666666Color; } else{ [_titleLabel setTextColor:HW0A132BColor]; } } - (void)setIsPlayingType:(BOOL)isPlayingType { if(isPlayingType){ _checkButton.hidden = YES; _playingGifView.hidden = NO; [_titleLabel setTextColor:[UIColor hwColor:@"#01B7EA"]]; [_contentLabel setTextColor:[UIColor hwColor:@"#01B7EA"]]; } else{ _checkButton.hidden = NO; _playingGifView.hidden = YES; [_titleLabel setTextColor:HW0A132BColor]; [_contentLabel setTextColor:HW666666Color]; } if (_curLastFileModel.isOffLineType && !_curLastFileModel.isDownDoneType) { _titleLabel.textColor = HW666666Color; } else{ [_titleLabel setTextColor:HW0A132BColor]; } } @end