//
|
// PBDocListTableViewCell.m
|
// IphoneBIMe
|
//
|
// Created by zjf on 2018/7/31.
|
// Copyright © 2018年 ProBIM. All rights reserved.
|
//
|
|
#import "PBDocListTableViewCell.h"
|
#import "PBDocModel.h"
|
|
@interface PBDocListTableViewCell()
|
@property (nonatomic, weak) UIImageView *docTypeImageV;
|
@property (nonatomic, weak) UILabel *docNameL;
|
@property (nonatomic, weak) UILabel *creatTimeL;
|
@property (nonatomic, weak) UILabel *docSizeL;
|
@end
|
|
@implementation PBDocListTableViewCell
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
[self setupUI];
|
}
|
return self;
|
}
|
|
- (void)setupUI {
|
UIImageView *docTypeImageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
|
[self.contentView addSubview:docTypeImageV];
|
[docTypeImageV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.centerY.equalTo(self.contentView);
|
make.left.equalTo(self.contentView).offset(25);
|
make.size.mas_equalTo(CGSizeMake(24, 24));
|
}];
|
|
UILabel *docNameL = [UILabel z_labelWithText:@"" Color:PBColor(40, 58, 79) isBold:YES Font:16];
|
docNameL.numberOfLines = 0;
|
[self.contentView addSubview:docNameL];
|
[docNameL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(self.contentView).offset(9);
|
make.left.equalTo(docTypeImageV.mas_right).offset(15);
|
make.right.equalTo(self.contentView).offset(-25);
|
}];
|
|
UILabel *creatTimeL = [UILabel z_labelWithText:@"" Color:PBColor(166, 174, 182) isBold:YES Font:12];
|
[self.contentView addSubview:creatTimeL];
|
[creatTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(docNameL.mas_bottom).offset(8);
|
make.left.equalTo(docNameL);
|
make.right.equalTo(docNameL).offset(-80);
|
make.height.equalTo(@16);
|
}];
|
|
UILabel *docSizeL = [UILabel z_labelWithText:@"" Color:PBColor(97, 111, 125) isBold:YES Font:12];
|
docSizeL.textAlignment = NSTextAlignmentRight;
|
[self.contentView addSubview:docSizeL];
|
[docSizeL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(creatTimeL);
|
make.right.equalTo(self.contentView).offset(-20);
|
make.size.mas_equalTo(CGSizeMake(100, 20));
|
make.bottom.equalTo(self.contentView).offset(-12);
|
}];
|
|
self.docTypeImageV = docTypeImageV;
|
self.docNameL = docNameL;
|
self.creatTimeL = creatTimeL;
|
self.docSizeL = docSizeL;
|
}
|
|
- (void)setDocModel:(PBDocModel *)docModel {
|
_docModel = docModel;
|
UIImage *image;
|
NSString *fileSize;
|
if ([docModel.FileSize isEqualToString:@"0"]) {
|
image = [UIImage imageNamed:@"Doc_type_folder"];
|
fileSize = nil;
|
}else {
|
NSString *type = [docModel.FileExtensions stringByReplacingOccurrencesOfString:@"." withString:@""];
|
NSString *imageName = [NSString stringWithFormat:@"Doc_type_%@",[type lowercaseString]];
|
image = [UIImage imageNamed:imageName];
|
if (image == nil) {
|
image = [UIImage imageNamed:@"Doc_type_ unknown"];
|
}
|
|
fileSize = [NSByteCountFormatter stringFromByteCount:[docModel.FileSize doubleValue] countStyle:NSByteCountFormatterCountStyleBinary];
|
}
|
_docTypeImageV.image = image;
|
_docSizeL.text = fileSize;
|
_docNameL.text = docModel.FileName;
|
NSRange range = [docModel.CreateDate rangeOfString:@":"];
|
NSString *date = [docModel.CreateDate substringToIndex:range.location + 3];
|
_creatTimeL.text = date;
|
|
}
|
|
- (void)awakeFromNib {
|
[super awakeFromNib];
|
// Initialization code
|
}
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
[super setSelected:selected animated:animated];
|
|
// Configure the view for the selected state
|
}
|
|
@end
|