audioPlayListViewCell.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. //
  2. // audioPlayListViewCell.m
  3. // Private-X
  4. //
  5. // Created by xd h on 2024/7/15.
  6. //
  7. #import "audioPlayListViewCell.h"
  8. #import "FLAnimatedImage.h"
  9. @interface audioPlayListViewCell ()
  10. @property(nonatomic, strong) FLAnimatedImageView *playingGifView;
  11. @end
  12. @implementation audioPlayListViewCell
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. // Initialization code
  16. }
  17. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  18. {
  19. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  20. if (self)
  21. {
  22. [self drawView];
  23. }
  24. return self;
  25. }
  26. - (void)drawView
  27. {
  28. _cellBgView = [[UIView alloc] init];
  29. [self.contentView addSubview:_cellBgView];
  30. _cellBgView.backgroundColor = [UIColor whiteColor];
  31. [_cellBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.left.mas_equalTo(0.f);
  33. make.top.mas_equalTo(0);
  34. make.bottom.mas_equalTo(0);
  35. make.width.mas_equalTo(SCREEN_W);
  36. }];
  37. /**时间*/
  38. // _timeLabel = [[UILabel alloc] init];
  39. // [_cellBgView addSubview:_timeLabel];
  40. // _timeLabel.font = [UIFont systemFontOfSize:12.f];
  41. // //[titleLabel2 setTextAlignment:(NSTextAlignmentRight)];
  42. // [_timeLabel setTextColor:[UIColor hwColor:@"#828D9A"]];
  43. // [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. // make.right.mas_equalTo(0.f);
  45. // make.left.mas_equalTo(15);
  46. // //make.centerY.equalTo(cellBgView.mas_centerY);
  47. // make.top.mas_equalTo(0);
  48. // make.height.mas_equalTo(20);
  49. // }];
  50. /*图片*/
  51. _mImageView = [[UIImageView alloc] init];
  52. [_mImageView setBackgroundColor:[UIColor clearColor]];
  53. _mImageView.image = [UIImage imageNamed:@"uploadFile_audio"];
  54. [_cellBgView addSubview:_mImageView];
  55. [_mImageView setContentMode:(UIViewContentModeScaleAspectFit)];
  56. [_mImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.left.mas_equalTo(15);
  58. make.width.mas_equalTo(42);
  59. make.height.mas_equalTo(42);
  60. make.centerY.equalTo(self.mas_centerY);
  61. }];
  62. _checkButton = [[UIButton alloc] init];
  63. [_checkButton setImage:[UIImage imageNamed:@"nas_audio_del_icon"] forState:UIControlStateNormal];
  64. //[_checkButton setImage:[UIImage imageNamed:@"upload_file_check"] forState:UIControlStateSelected];
  65. [_cellBgView addSubview:_checkButton];
  66. [_checkButton mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.right.mas_equalTo(-15.f);
  68. make.centerY.equalTo(self.mas_centerY);
  69. make.width.mas_equalTo(36.f);
  70. make.height.mas_equalTo(36.f);
  71. }];
  72. [_checkButton addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventTouchUpInside)];
  73. /**标题*/
  74. _titleLabel = [[UILabel alloc] init];
  75. [_cellBgView addSubview:_titleLabel];
  76. _titleLabel.font = [UIFont boldSystemFontOfSize:14.f];
  77. _titleLabel.numberOfLines = 2;
  78. _titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
  79. [_titleLabel setTextColor:HW0A132BColor];
  80. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.left.equalTo(_mImageView.mas_right).offset(5.f);
  82. make.right.equalTo(_checkButton.mas_left).offset(-5.f);
  83. //make.centerY.equalTo(cellBgView.mas_centerY);
  84. make.top.equalTo(_mImageView.mas_top);
  85. }];
  86. /**副标题*/
  87. _contentLabel = [[UILabel alloc] init];
  88. [_cellBgView addSubview:_contentLabel];
  89. _contentLabel.font = [UIFont systemFontOfSize:12.f];
  90. _contentLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
  91. //[titleLabel2 setTextAlignment:(NSTextAlignmentRight)];
  92. [_contentLabel setTextColor:HW666666Color];
  93. [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.right.mas_equalTo(_titleLabel.mas_right);
  95. make.left.mas_equalTo(_titleLabel.mas_left);
  96. //make.centerY.equalTo(cellBgView.mas_centerY);
  97. make.top.equalTo(_titleLabel.mas_bottom).offset(5.0);
  98. }];
  99. FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"playingAudioGif" withExtension:@"gif"]]];
  100. _playingGifView = [[FLAnimatedImageView alloc] init];
  101. [_playingGifView setContentMode:UIViewContentModeScaleAspectFill];
  102. [_playingGifView setBackgroundColor:[ UIColor clearColor]];
  103. _playingGifView.animatedImage = image;
  104. [_cellBgView addSubview:_playingGifView];
  105. [_playingGifView mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.centerX.mas_equalTo(_checkButton.mas_centerX);
  107. make.centerY.mas_equalTo(_checkButton.mas_centerY);
  108. make.width.mas_equalTo(40);
  109. make.height.mas_equalTo(40);
  110. }];
  111. }
  112. - (void)maskSwitchPressed:(UIButton *)maskSwitch{
  113. maskSwitch.selected = !maskSwitch.selected;
  114. if(_didClickSwitch){
  115. _didClickSwitch(maskSwitch.selected);
  116. }
  117. }
  118. - (void)setCurLastFileModel:(lastFileModel *)curLastFileModel
  119. {
  120. _curLastFileModel = curLastFileModel;
  121. _checkButton.selected = _curLastFileModel.isSelectType;
  122. NSString *filePath = _curLastFileModel.path;
  123. NSString *urlStr = ksharedAppDelegate.NASFileByBoxService;
  124. NSString *fileUrl = [[NSString alloc] initWithFormat:@"%@getThumbnail?path=%@",urlStr,filePath];
  125. _titleLabel.text = _curLastFileModel.name;
  126. NSString *dateStr = _curLastFileModel.time;
  127. //_timeLabel.text = dateStr;
  128. NSString * totalSizeStr = nil;
  129. NSInteger totalSize_k = _curLastFileModel.size / 1024;
  130. if(totalSize_k == 0){
  131. totalSize_k = 1;
  132. }
  133. if(totalSize_k < 1024){
  134. totalSizeStr = [[NSString alloc] initWithFormat:@"%ldKB",totalSize_k];
  135. }
  136. else if( totalSize_k >= 1024 && totalSize_k < 1024*1024){
  137. totalSizeStr = [[NSString alloc] initWithFormat:@"%.2fMB",totalSize_k/1024.0];
  138. }
  139. else{
  140. totalSizeStr = [[NSString alloc] initWithFormat:@"%.2fG",totalSize_k/1024.0/1024.0];
  141. }
  142. // NSString *path = _curLastFileModel.path;
  143. // if([path containsString:@"mnt/media_rw"]){
  144. // path = [path stringByReplacingOccurrencesOfString:@"mnt/media_rw" withString:NSLocalizedString(@"disk_Extra_default_tip",nil)];
  145. // }
  146. // else if([path containsString:@"storage/emulated/0"]){
  147. // path = [path stringByReplacingOccurrencesOfString:@"storage/emulated/0" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  148. // }
  149. // else if([path containsString:@"sdcard"]){
  150. // path = [path stringByReplacingOccurrencesOfString:@"sdcard" withString:NSLocalizedString(@"disk_phone_default_tip",nil)];
  151. // }
  152. //NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",totalSizeStr,path];
  153. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",totalSizeStr,dateStr];
  154. _contentLabel.text = totalStr;
  155. }
  156. - (void)setIsPlayingType:(BOOL)isPlayingType
  157. {
  158. if(isPlayingType){
  159. _checkButton.hidden = YES;
  160. _playingGifView.hidden = NO;
  161. [_titleLabel setTextColor:[UIColor hwColor:@"#01B7EA"]];
  162. [_contentLabel setTextColor:[UIColor hwColor:@"#01B7EA"]];
  163. }
  164. else{
  165. _checkButton.hidden = NO;
  166. _playingGifView.hidden = YES;
  167. [_titleLabel setTextColor:HW0A132BColor];
  168. [_contentLabel setTextColor:HW666666Color];
  169. }
  170. }
  171. @end