123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- //
- // audioPlayListViewCell.m
- // Private-X
- //
- // 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;
- }
- - (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];
- }
- }
- @end
|