//
|
// PBPositionTableViewCell1.m
|
// IphoneBIMe
|
//
|
// Created by zjf on 2019/1/11.
|
// Copyright © 2019 ProBIM. All rights reserved.
|
//
|
|
#import "PBPositionTableViewCell.h"
|
#import "PBIssueAddModel.h"
|
#import "PBViewPointModel.h"
|
|
@interface PBPositionTableViewCell ()
|
@property (nonatomic, weak) UILabel *titleL;
|
@property (nonatomic, weak) UILabel *nameL;
|
@property (nonatomic, weak) UIImageView *imageV;
|
@property (nonatomic, weak) UIButton *selectBtn;
|
@property (nonatomic, weak) UIButton *openBtn;
|
@end
|
@implementation PBPositionTableViewCell
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
[self setupUI];
|
}
|
return self;
|
}
|
- (void)setupUI {
|
UILabel *titleL = [UILabel z_labelWithText:@"图纸定位(选填)" Color:PromptColor isBold:NO Font:TitleFontSize];
|
[self.contentView addSubview:titleL];
|
[titleL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(self.contentView).offset(16);
|
make.left.equalTo(self.contentView).offset(16);
|
make.height.equalTo(@22);
|
}];
|
UIButton *selectBtn = [UIButton z_textButton:@"请选择" fontSize:MarkedFontSize normalColor:TitleColor];
|
[selectBtn addTarget:self action:@selector(selectbtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:selectBtn];
|
[selectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.right.equalTo(self.contentView).offset(-16);
|
make.centerY.equalTo(titleL);
|
}];
|
|
UIImageView *imageV = [[UIImageView alloc] init];
|
[self.contentView addSubview:imageV];
|
[imageV mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo (titleL.mas_bottom).offset(16);
|
make.left.equalTo(self.contentView).offset(16);
|
make.size.mas_equalTo(CGSizeMake(120, 120));
|
}];
|
|
UILabel *nameL = [UILabel z_labelWithText:@"图纸名称" Color:TitleColor isBold:NO Font:TitleFontSize];
|
[self.contentView addSubview:nameL];
|
[nameL mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(imageV);
|
make.left.equalTo(imageV.mas_right).offset(16);
|
make.right.equalTo(self.contentView).offset(-16);
|
make.height.equalTo(@22);
|
}];
|
|
UIButton *openBtn = [UIButton z_textButton:@"打开图纸" fontSize:MarkedFontSize normalColor:IndicatedColor];
|
[openBtn addTarget:self action:@selector(openbtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
[self.contentView addSubview:openBtn];
|
[openBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.right.equalTo(self.contentView).offset(-16);
|
make.bottom.equalTo(imageV);
|
}];
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.right.equalTo(self);
|
make.bottom.equalTo(titleL.mas_bottom).offset(26);
|
}];
|
|
self.titleL = titleL;
|
self.nameL = nameL;
|
self.imageV = imageV;
|
self.selectBtn = selectBtn;
|
self.openBtn = openBtn;
|
}
|
|
- (void)selectbtnAction:(UIButton *)button {
|
if (self.issueAddModel.roleType != CREATOR) {
|
return;
|
}
|
if (self.ChoosePositionBlock) {
|
self.ChoosePositionBlock();
|
}
|
}
|
|
- (void)openbtnAction:(UIButton *)button {
|
if (self.OpenPositionBlock) {
|
self.OpenPositionBlock();
|
}
|
}
|
|
- (void)setIssueAddModel:(PBIssueAddModel *)issueAddModel {
|
_issueAddModel = issueAddModel;
|
self.titleL.text = issueAddModel.title;
|
if (issueAddModel.roleType == CREATOR) {
|
[self.selectBtn setTitleColor:TitleColor forState:UIControlStateNormal];
|
}else {
|
[self.selectBtn setTitleColor:PromptColor forState:UIControlStateNormal];
|
}
|
if ([issueAddModel.key isEqualToString:@"viewPoint"]) {
|
if (issueAddModel.veiwPointModel == nil) {
|
[self.selectBtn setTitle:issueAddModel.prompt forState:UIControlStateNormal];
|
self.nameL.hidden = YES;
|
self.imageV.hidden = YES;
|
self.openBtn.hidden = YES;
|
[self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.right.equalTo(self);
|
make.bottom.equalTo(self.titleL.mas_bottom).offset(26);
|
}];
|
}else {
|
self.nameL.hidden = NO;
|
self.imageV.hidden = NO;
|
self.openBtn.hidden = NO;
|
[self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.right.equalTo(self);
|
make.bottom.equalTo(self.imageV.mas_bottom).offset(26);
|
}];
|
[self.selectBtn setTitle:@"更多操作" forState:UIControlStateNormal];
|
[self.openBtn setTitle:@"打开视点" forState:UIControlStateNormal];
|
self.nameL.text = self.issueAddModel.veiwPointModel.Name;
|
if (issueAddModel.veiwPointModel.Links.count == 0){
|
self.imageV.image = [UIImage imageNamed:@"Issue_viewPoint_fail"];
|
}else {
|
NSString *thumbnail = [issueAddModel.veiwPointModel.Links[0] valueForKey:@"Content"];
|
NSRange range = [thumbnail rangeOfString:@"base64,"];
|
thumbnail = [thumbnail substringFromIndex:range.location + range.length];
|
self.imageV.image = [NSString imageDecoding:thumbnail];
|
}
|
}
|
}else {
|
if (self.issueAddModel.drawingsInfoModel == nil) {
|
[self.selectBtn setTitle:issueAddModel.prompt forState:UIControlStateNormal];
|
self.nameL.hidden = YES;
|
self.imageV.hidden = YES;
|
self.openBtn.hidden = YES;
|
[self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.right.equalTo(self);
|
make.bottom.equalTo(self.titleL.mas_bottom).offset(26);
|
}];
|
}else {
|
self.nameL.hidden = NO;
|
self.imageV.hidden = NO;
|
self.openBtn.hidden = NO;
|
[self.contentView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
make.top.left.right.equalTo(self);
|
make.bottom.equalTo(self.imageV.mas_bottom).offset(26);
|
}];
|
[self.selectBtn setTitle:@"更多操作" forState:UIControlStateNormal];
|
[self.openBtn setTitle:@"打开图纸" forState:UIControlStateNormal];
|
self.nameL.text = self.issueAddModel.drawingsInfoModel.name;
|
self.imageV.image = [NSString imageDecoding:self.issueAddModel.drawingsInfoModel.imagebase64];
|
}
|
}
|
}
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
[super setSelected:selected animated:animated];
|
|
// Configure the view for the selected state
|
}
|
@end
|