// // 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; @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.messageTitle mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.contentView.mas_top).offset(16.); make.left.mas_equalTo(self.contentView.mas_left).offset(16.); make.height.mas_equalTo(22); }]; [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.messageTitle.mas_bottom).offset(10.); make.left.mas_equalTo(self.messageTitle.mas_left); make.width.mas_equalTo(50); make.height.mas_equalTo(30); }]; [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.messageTitle.mas_left); make.bottom.mas_equalTo(self.messageImageView.mas_bottom); make.right.mas_equalTo(self.messageTitle.mas_right); make.height.mas_equalTo(22); }]; [self.messageImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.contentView.mas_top).offset(16.); make.left.mas_equalTo(self.messageTitle.mas_right).offset(10.); make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-16.); make.right.mas_equalTo(self.contentView.mas_right).offset(-16.); make.width.mas_equalTo(self.messageImageView.mas_height).multipliedBy(5/3.); }]; } #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; } if (time && time.length > 0) { self.timeLabel.text = time; } if (messageUrl && messageUrl.length > 0) { NSLog(@"#######cell image url:%@", messageUrl); [self.messageImageView sd_setImageWithURL:[NSURL URLWithString:messageUrl] placeholderImageScale:[UIImage imageNamed:@""]]; } } #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; } return _messageTitle; } - (UILabel *)statusLabel { if (!_statusLabel) { _statusLabel=[[UILabel alloc] init]; _statusLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_12); _statusLabel.textColor = HDLEZ_COLOR_TEXT_LIGHT_GRAY; _statusLabel.layer.cornerRadius = 5; _statusLabel.layer.borderColor = HDLEZ_COLOR_TEXT_GRAY.CGColor; _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_GRAY; _timeLabel.textAlignment = NSTextAlignmentRight; } return _timeLabel; } - (UIImageView *)messageImageView { if (!_messageImageView) { _messageImageView = [[UIImageView alloc] init]; _messageImageView.backgroundColor = HDLEZ_COLOR_TEXT_LIGHT_GRAY; } return _messageImageView; } @end