zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//
//  PBTableHeaderView.m
//  IphoneBIMe
//
//  Created by zjf on 2018/8/14.
//  Copyright © 2018年 ProBIM. All rights reserved.
//
 
#import "PBTableHeaderView.h"
#import "PBViewPointModel.h"
 
 
 
@interface PBTableHeaderView()
@property (nonatomic, weak) UILabel *viewPointNameL;
@property (nonatomic, weak) UILabel *viewPointDesceL;
@property (nonatomic, weak) UIImageView *viewPointImageV;
@property (nonatomic, weak) UIButton *loadViewPointBtn;
@end
@implementation PBTableHeaderView
 
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    UILabel *titleL = [UILabel z_labelWithText:@"关联图片" Color:TitleColor isBold:NO Font:TitleFontSize];
    [self addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(16);
        make.left.equalTo(self).offset(16);
    }];
    
//    UILabel *modelNameL = [UILabel z_labelWithText:@"模型名称-视点" Color:DescColor isBold:NO Font:TitleFontSize];
//    modelNameL.textAlignment = NSTextAlignmentRight;
//    [self addSubview:modelNameL];
//    [modelNameL mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(titleL);
//        make.right.equalTo(self).offset(-16);
//        make.left.equalTo(titleL.mas_right).offset(30);
//    }];
    
    UIImageView *viewPointImageV = [[UIImageView alloc] init];
    viewPointImageV.backgroundColor = [UIColor grayColor];
    [self addSubview:viewPointImageV];
    [viewPointImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleL.mas_bottom).offset(16);
        make.left.equalTo(titleL);
        make.size.mas_equalTo(CGSizeMake(120, 120));
    }];
    
    UILabel *viewPointNameL = [UILabel z_labelWithText:@"视点名称XXXX" Color:TitleColor isBold:NO Font:TitleFontSize];
    [self addSubview:viewPointNameL];
    [viewPointNameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewPointImageV);
        make.right.equalTo(self).offset(-16);
        make.left.equalTo(viewPointImageV.mas_right).offset(16);
    }];
    
    UILabel *viewPointDesceL = [UILabel z_labelWithText:@"<无描述>" Color:DescColor isBold:NO Font:DescFontSize];
    viewPointDesceL.numberOfLines = 0;
    [self addSubview:viewPointDesceL];
    [viewPointDesceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewPointNameL.mas_bottom).offset(10);
        make.right.equalTo(self).offset(-16);
        make.left.equalTo(viewPointNameL);
        make.bottom.equalTo(viewPointImageV).offset(-35);
    }];
    UIButton *loadViewPointBtn = [UIButton z_textButton:@"加载模型" fontSize:MarkedFontSize normalColor:IndicatedColor];
    [loadViewPointBtn addTarget:self action:@selector(loadViewPoint) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:loadViewPointBtn];
    [loadViewPointBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(75, 25));
        make.right.equalTo(self).offset(-16);
        make.bottom.equalTo(viewPointImageV);
    }];
    
    UIView *bottomV = [[UIView alloc] init];
    bottomV.backgroundColor = [UIColor z_colorWithR:242 G:242 B:242];
    [self addSubview:bottomV];
    [bottomV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self);
        make.height.equalTo(@10);
    }];
    self.viewPointImageV = viewPointImageV;
    self.viewPointNameL = viewPointNameL;
    self.viewPointDesceL = viewPointDesceL;
    self.loadViewPointBtn = loadViewPointBtn;
}
 
- (void)setViewPointModel:(PBViewPointModel *)viewPointModel {
    _viewPointModel = viewPointModel;
    NSString *thumbnail = viewPointModel.Snapshot;
    NSRange range = [thumbnail rangeOfString:@"base64,"];
    thumbnail = [thumbnail substringFromIndex:range.location + range.length];
    UIImage *image = [NSString imageDecoding:thumbnail];
    self.viewPointImageV.image = image;
    self.viewPointNameL.text = viewPointModel.Name;
    NSDictionary *dict = [NSString convertTodictionaryOrArr:viewPointModel.Tag];
    NSString *desc = [dict valueForKey:@"description"];
    self.viewPointDesceL.text = [desc isEqualToString:@""] ? @"<无描述>" : desc;
}
- (void)loadViewPoint {
    if (self.loadViewPointBlock) {
        self.loadViewPointBlock(_viewPointModel);
    }
}
- (void)setIsAddIssue:(BOOL)isAddIssue {
    _isAddIssue = isAddIssue;
    if (isAddIssue) {
        self.loadViewPointBtn.hidden = YES;
    }else {
        self.loadViewPointBtn.hidden = NO;
    }
}
@end