|
@@ -0,0 +1,267 @@
|
|
|
+//
|
|
|
+// lastFileTableViewCell.m
|
|
|
+// 双子星云手机
|
|
|
+//
|
|
|
+// Created by xd h on 2024/7/9.
|
|
|
+//
|
|
|
+
|
|
|
+#import "lastFileTableViewCell.h"
|
|
|
+#import <SDWebImage/SDWebImage.h>
|
|
|
+
|
|
|
+@implementation lastFileTableViewCell
|
|
|
+
|
|
|
+
|
|
|
+- (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(16.f);
|
|
|
+ make.top.mas_equalTo(0);
|
|
|
+ make.bottom.mas_equalTo(0);
|
|
|
+ make.width.mas_equalTo(SCREEN_W - 2*16.f);
|
|
|
+ }];
|
|
|
+
|
|
|
+ /**时间*/
|
|
|
+ _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_image"];
|
|
|
+ [_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:@"upload_file_uncheck"] 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);
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (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];
|
|
|
+
|
|
|
+ UIImage *placeholderImage = nil;
|
|
|
+ if([_curLastFileModel.type isEqualToString:@"video"])
|
|
|
+ {
|
|
|
+ placeholderImage = [UIImage imageNamed:@"uploadFile_Video"];
|
|
|
+ }
|
|
|
+ else if([_curLastFileModel.type isEqualToString:@"jpg"])
|
|
|
+ {
|
|
|
+ placeholderImage = [UIImage imageNamed:@"uploadFile_image"];
|
|
|
+
|
|
|
+ //iOS格式的图片 代理拿不到缩略图
|
|
|
+ if([filePath rangeOfString:@".HEIC"].location != NSNotFound
|
|
|
+ ||[filePath rangeOfString:@".heic"].location != NSNotFound){
|
|
|
+ fileUrl = [[NSString alloc] initWithFormat:@"%@getFile?path=%@",urlStr,filePath];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if([_curLastFileModel.type isEqualToString:@"audio"])
|
|
|
+ {
|
|
|
+ _mImageView.image = [UIImage imageNamed:@"uploadFile_audio"];
|
|
|
+ }
|
|
|
+ else if([_curLastFileModel.type isEqualToString:@"dir"])
|
|
|
+ {
|
|
|
+ _checkButton.hidden = YES;
|
|
|
+ _mImageView.image = [UIImage imageNamed:@"uploadFile_dir"];
|
|
|
+ }
|
|
|
+ //else if([curNASFileAndFolderDataModel.type isEqualToString:@"doc"])
|
|
|
+// {
|
|
|
+// //uploadFile_TXT uploadFile_pdf uploadFile_xlsx uploadFile_doc
|
|
|
+// NSArray *nameArr= [curNASFileAndFolderDataModel.name componentsSeparatedByString:@"."];
|
|
|
+// if (nameArr.count >= 2) {
|
|
|
+// NSString *lastName = nameArr.lastObject;
|
|
|
+//
|
|
|
+// lastName = [lastName lowercaseString];
|
|
|
+//
|
|
|
+// if ([lastName rangeOfString:@"txt"].location != NSNotFound) {
|
|
|
+// mImageView.image = [UIImage imageNamed:@"uploadFile_TXT"];
|
|
|
+// }
|
|
|
+// else if ([lastName rangeOfString:@"pdf"].location != NSNotFound) {
|
|
|
+// mImageView.image = [UIImage imageNamed:@"uploadFile_pdf"];
|
|
|
+// }
|
|
|
+// else if ([lastName rangeOfString:@"xlsx"].location != NSNotFound) {
|
|
|
+// mImageView.image = [UIImage imageNamed:@"uploadFile_xlsx"];
|
|
|
+// }
|
|
|
+// else if ([lastName rangeOfString:@"doc"].location != NSNotFound) {
|
|
|
+// mImageView.image = [UIImage imageNamed:@"uploadFile_doc"];
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// mImageView.image = [UIImage imageNamed:@"uploadFile_other"];
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+ else{
|
|
|
+ _mImageView.image = [UIImage imageNamed:@"uploadFile_other"];
|
|
|
+ }
|
|
|
+
|
|
|
+ if([_curLastFileModel.type isEqualToString:@"video"]
|
|
|
+ ||([_curLastFileModel.type isEqualToString:@"jpg"])){
|
|
|
+ fileUrl = [fileUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
|
|
+
|
|
|
+ [_mImageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:placeholderImage 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);
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ }];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //时间戳转换为日期
|
|
|
+// NSString *timeStr = [[NSString alloc] initWithFormat:@"%ld",curNASFileAndFolderDataModel.time];
|
|
|
+// NSString *dateStr = [iTools getDateStringWithTimeStr:timeStr];
|
|
|
+
|
|
|
+ _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:@"%.1fMB",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];
|
|
|
+ _contentLabel.text = totalStr;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)hideCheckButtonBy:(BOOL)isHide{
|
|
|
+ _checkButton.hidden = isHide;
|
|
|
+ if(isHide){
|
|
|
+ [_titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(_mImageView.mas_right).offset(5.f);
|
|
|
+ make.right.mas_equalTo(-5.f);
|
|
|
+ //make.centerY.equalTo(cellBgView.mas_centerY);
|
|
|
+ make.top.equalTo(_mImageView.mas_top);
|
|
|
+ }];
|
|
|
+
|
|
|
+ /**副标题*/
|
|
|
+ [_contentLabel mas_remakeConstraints:^(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);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@end
|