萤石云 iOSSDK,移植跨平台相关工程
Davin
2023-07-10 0de4cf306d8e13fd57b3e04bfb81362a10f12a4d
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//
//  HDLEZVideoDoorMsgCell.m
//  EZSDK
//
//  Created by Davin on 2023/6/15.
//
 
#import "HDLEZVideoDoorMsgCell.h"
 
@interface HDLEZVideoDoorMsgCell ()
 
@property (strong, nonatomic) UILabel *messageTitle;
@property (strong, nonatomic) UILabel *statusLabel;
@property (strong, nonatomic) UILabel *timeLabel;
@property (strong, nonatomic) UIImageView *messageImageView;
@property (strong, nonatomic) UIView *separatorLine;
 
@end
 
@implementation HDLEZVideoDoorMsgCell
 
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubviews];
    }
    return self;
}
 
- (void)createSubviews {
    self.contentView.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:self.messageTitle];
    [self.contentView addSubview:self.statusLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.messageImageView];
    [self.contentView addSubview:self.separatorLine];
    
    [self.messageTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).offset(24.);
        make.left.mas_equalTo(self.contentView.mas_left).offset(16.);
    }];
    
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.messageTitle.mas_top).offset(0.);
        make.left.mas_equalTo(self.messageTitle.mas_right).offset(8.);
        make.right.mas_lessThanOrEqualTo(self.messageImageView.mas_left).offset(-8.);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(20);
    }];
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.messageTitle.mas_bottom).offset(4.);
        make.left.mas_equalTo(self.messageTitle.mas_left);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-12.);
        make.height.mas_equalTo(17);
    }];
    
    [self.messageImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView.mas_right).offset(-16.);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.width.mas_equalTo(72.);
        make.height.mas_equalTo(41.);
    }];
    
    [self.separatorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.messageTitle.mas_left);
        make.bottom.mas_equalTo(self.contentView.mas_bottom);
        make.right.mas_equalTo(self.messageImageView.mas_right);
        make.height.mas_equalTo(0.5);
    }];
}
 
#pragma mark - PublishMethod
- (void)configMessageInfoWithTitle:(NSString *)title deviceStatus:(NSString *)deviceStatus messageTime:(NSString *)time messageImage:(NSString *)messageUrl {    
    if (title && title.length > 0) {
        self.messageTitle.text = title;
    }
    
    if (deviceStatus && deviceStatus.length > 0) {
        self.statusLabel.text = deviceStatus;
        [self.statusLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(40.);
        }];
        self.statusLabel.backgroundColor = [deviceStatus isEqualToString:@"已接"] ? HDLEZHEXCOLOR(0x00C22D, 1.) : HDLEZHEXCOLOR(0xFF4747, 1.);
    } else {
        [self.statusLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(0.);
        }];
    }
    
    if (time && time.length > 0) {
        self.timeLabel.text = time;
    }
    if (messageUrl && messageUrl.length > 0) {
        [self.messageImageView sd_setImageWithURL:[NSURL URLWithString:messageUrl] placeholderImageScale:[UIImage imageNamed:@"hdl_ez_msg_placeholder"]];
        [self.messageImageView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(72.);
        }];
    } else {
        [self.messageImageView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(0.);
        }];
    }
}
 
- (void)showSpearator:(BOOL)isShow {
    self.separatorLine.hidden = !isShow;
}
 
#pragma mark - Getter
- (UILabel *)messageTitle {
    if (!_messageTitle) {
        _messageTitle=[[UILabel alloc] init];
        _messageTitle.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_14);
        _messageTitle.textColor=HDLEZ_COLOR_TITLE_BLACK;
        _messageTitle.numberOfLines = 2;
    }
    return _messageTitle;
}
 
- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel=[[UILabel alloc] init];
        _statusLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12);
        _statusLabel.textColor = HDLEZ_COLOR_TEXT_WHITE;
        _statusLabel.textAlignment = NSTextAlignmentCenter;
        _statusLabel.layer.cornerRadius = 4;
        _statusLabel.clipsToBounds = YES;
    }
    return _statusLabel;
}
 
- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel=[[UILabel alloc] init];
        _timeLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12);
        _timeLabel.textColor=HDLEZ_COLOR_TEXT_LIGHT_GRAY;
    }
    return _timeLabel;
}
 
- (UIImageView *)messageImageView {
    if (!_messageImageView) {
        _messageImageView = [[UIImageView alloc] init];
        _messageImageView.contentMode = UIViewContentModeScaleAspectFill;
        _messageImageView.backgroundColor = HDLEZ_COLOR_TEXT_LIGHT_GRAY;
        _messageImageView.layer.cornerRadius = 4;
        _messageImageView.clipsToBounds = YES;
    }
    return _messageImageView;
}
 
- (UIView *)separatorLine {
    if (!_separatorLine) {
        _separatorLine = [[UIView alloc] init];
        _separatorLine.backgroundColor = HDLEZ_COLOR_BACKGROUND_LINE;
    }
    return _separatorLine;
}
 
@end