// // AppointDriverCell.m // LN_School // // Created by 张嵘 on 2019/8/1. // Copyright © 2019 Danson. All rights reserved. // #import "AppointDriverCell.h" #import "AppointDriverModel.h" @interface AppointDriverCell () @property (nonatomic, readwrite, strong) UILabel *codeLabel; @property (nonatomic, readwrite, strong) UIButton *studyStatusBtn; @property (nonatomic, readwrite, strong) UIImageView *centerLineView; @property (nonatomic, readwrite, strong) UIImageView *coachIconImageView; @property (nonatomic, readwrite, strong) UILabel *studentNameLabel; @property (nonatomic, readwrite, strong) UIImageView *objectIconImageView; @property (nonatomic, readwrite, strong) UILabel *objectLabel; @property (nonatomic, readwrite, strong) UILabel *objectStatusLabel; @property (nonatomic, readwrite, strong) UIImageView *dateIconImageView; @property (nonatomic, readwrite, strong) UILabel *dateLabel; @property (nonatomic, readwrite, strong) UIButton *studyBtn; @end @implementation AppointDriverCell #pragma mark - Life Cycle - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.contentView.backgroundColor = UIColor.whiteColor; [self.contentView addSubview:self.codeLabel]; [self.contentView addSubview:self.studyStatusBtn]; [self.contentView addSubview:self.centerLineView]; [self.contentView addSubview:self.coachIconImageView]; [self.contentView addSubview:self.studentNameLabel]; [self.contentView addSubview:self.objectIconImageView]; [self.contentView addSubview:self.objectLabel]; [self.contentView addSubview:self.objectStatusLabel]; [self.contentView addSubview:self.dateIconImageView]; [self.contentView addSubview:self.dateLabel]; [self.contentView addSubview:self.studyBtn]; } return self; } - (void)layoutSubviews { [super layoutSubviews]; [_studyStatusBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.mas_offset(16); make.size.mas_equalTo(CGSizeMake([@" 未学习 " widthForFont:[UIFont systemFontOfSize:16]], (self.bounds.size.height - 5 * 16) / 4.f)); }]; [_codeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(_studyStatusBtn.mas_right).mas_equalTo(8); make.centerY.mas_equalTo(_studyStatusBtn); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width - 32 - 8 - [@" 未学习 " widthForFont:[UIFont systemFontOfSize:16]], (self.bounds.size.height - 6 * 16) / 4.f)); }]; [_centerLineView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_codeLabel.mas_bottom).mas_offset(16); make.left.mas_equalTo(_studyStatusBtn); make.right.mas_offset(0); make.height.mas_equalTo(1); }]; [_coachIconImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_centerLineView.mas_bottom).mas_offset(16); make.left.mas_equalTo(_studyStatusBtn); make.size.mas_equalTo(CGSizeMake((self.bounds.size.height - 6 * 16) / 5.f , (self.bounds.size.height - 6 * 16) / 5.f)); }]; [_studentNameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(_coachIconImageView); make.left.mas_equalTo(_coachIconImageView.mas_right).mas_offset(8); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 2 - 8 - _coachIconImageView.frame.size.width), (self.bounds.size.height - 6 * 16) / 4.f)); }]; [_objectIconImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_coachIconImageView.mas_bottom).mas_offset(16); make.left.mas_equalTo(_coachIconImageView); make.size.mas_equalTo(CGSizeMake((self.bounds.size.height - 6 * 16) / 5.f , (self.bounds.size.height - 6 * 16) / 5.f)); }]; [_objectLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(_objectIconImageView); make.left.mas_equalTo(_coachIconImageView.mas_right).mas_offset(8); make.size.mas_equalTo(CGSizeMake([@"科目:" widthForFont:[UIFont systemFontOfSize:15]] + 1, (self.bounds.size.height - 6 * 16) / 4.f)); }]; [_objectStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(_objectIconImageView); make.left.mas_equalTo(_objectLabel.mas_right).mas_offset(0); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 2 - 8 - _coachIconImageView.frame.size.width - [@"科目:" widthForFont:[UIFont systemFontOfSize:15]]), (self.bounds.size.height - 6 * 16) / 4.f)); }]; [_dateIconImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_objectIconImageView.mas_bottom).mas_offset(16); make.left.mas_equalTo(_objectIconImageView); make.size.mas_equalTo(CGSizeMake((self.bounds.size.height - 6 * 16) / 5.f , (self.bounds.size.height - 6 * 16) / 5.f)); }]; [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(_dateIconImageView); make.left.mas_equalTo(_dateIconImageView.mas_right).mas_offset(8); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 2 - 8 - _coachIconImageView.frame.size.width), (self.bounds.size.height - 6 * 16) / 4.f)); }]; [_studyBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(_objectIconImageView); make.right.mas_offset(-16); make.size.mas_equalTo(CGSizeMake([@" 开始上课 " widthForFont:[UIFont systemFontOfSize:16]], (self.bounds.size.height - 7 * 16) / 2.f)); _studyBtn.layer.cornerRadius = (self.bounds.size.height - 7 * 16) / 4.f; _studyBtn.layer.masksToBounds = YES; }]; } #pragma mark - HDUpdateUIProtocol - (void)updateCellUI:(__kindof HDCellModel *)model { AppointDriverModel *appointDriverModel = model.orgData; _codeLabel.text = [NSString stringWithFormat:@"%@", appointDriverModel.code]; [_studyStatusBtn setTitle:[NSString stringWithFormat:@"%@", appointDriverModel.passStatus] forState:UIControlStateNormal]; _studyStatusBtn.backgroundColor = [appointDriverModel.passStatus isEqualToString:@"未学习"]? RQPinkGreenColor : RQOrangeColor; _studentNameLabel.text = [NSString stringWithFormat:@"学员:%@", appointDriverModel.studentName]; _objectStatusLabel.text = [NSString stringWithFormat:@"%@", appointDriverModel.objectStatus]; _dateLabel.text = [NSString stringWithFormat:@"时间:%@", appointDriverModel.date]; _studyBtn.hidden = [appointDriverModel.passStatus isEqualToString:@"已学习"]; } #pragma mark - Lazy Load - (UILabel *)codeLabel { if (!_codeLabel) { _codeLabel = [[UILabel alloc] init]; _codeLabel.text = @""; _codeLabel.textAlignment = NSTextAlignmentLeft; _codeLabel.textColor = RQContentTextColor; _codeLabel.numberOfLines = 0; _codeLabel.font = [UIFont systemFontOfSize:15]; } return _codeLabel; } - (UIButton *)studyStatusBtn { if (!_studyStatusBtn) { _studyStatusBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_studyStatusBtn setTitle:@"未学习" forState:UIControlStateNormal]; _studyStatusBtn.titleLabel.textAlignment = NSTextAlignmentCenter; _studyStatusBtn.titleLabel.textColor = UIColor.whiteColor; _studyStatusBtn.backgroundColor = RQPinkGreenColor; _studyStatusBtn.titleLabel.numberOfLines = 0; _studyStatusBtn.titleLabel.font = [UIFont systemFontOfSize:16]; _studyStatusBtn.layer.cornerRadius = 3; _studyStatusBtn.layer.masksToBounds = YES; } return _studyStatusBtn; } - (UIImageView *)centerLineView { if (!_centerLineView) { _centerLineView = [[UIImageView alloc] init]; _centerLineView.backgroundColor = RQBackGroundColor; } return _centerLineView; } - (UIImageView *)coachIconImageView { if (!_coachIconImageView) { _coachIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"coachIcon"]]; } return _coachIconImageView; } - (UILabel *)studentNameLabel { if (!_studentNameLabel) { _studentNameLabel = [[UILabel alloc] init]; _studentNameLabel.text = @"学员:张小丽"; _studentNameLabel.textAlignment = NSTextAlignmentLeft; _studentNameLabel.textColor = RQTitleTextColor; _studentNameLabel.numberOfLines = 0; _studentNameLabel.font = [UIFont systemFontOfSize:15]; } return _studentNameLabel; } - (UIImageView *)objectIconImageView { if (!_objectIconImageView) { _objectIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"objectIcon"]]; } return _objectIconImageView; } - (UILabel *)objectLabel { if (!_objectLabel) { _objectLabel = [[UILabel alloc] init]; _objectLabel.text = @"科目:"; _objectLabel.textAlignment = NSTextAlignmentLeft; _objectLabel.textColor = RQTitleTextColor; _objectLabel.numberOfLines = 0; _objectLabel.font = [UIFont systemFontOfSize:15]; } return _objectLabel; } - (UILabel *)objectStatusLabel { if (!_objectStatusLabel) { _objectStatusLabel = [[UILabel alloc] init]; _objectStatusLabel.text = @"90"; _objectStatusLabel.textAlignment = NSTextAlignmentLeft; _objectStatusLabel.textColor = RQTitleTextColor; _objectStatusLabel.numberOfLines = 0; _objectStatusLabel.font = [UIFont systemFontOfSize:15]; } return _objectStatusLabel; } - (UIImageView *)dateIconImageView { if (!_dateIconImageView) { _dateIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dateIcon"]]; } return _dateIconImageView; } - (UILabel *)dateLabel { if (!_dateLabel) { _dateLabel = [[UILabel alloc] init]; _dateLabel.text = @"时间:2019-09-09"; _dateLabel.textAlignment = NSTextAlignmentLeft; _dateLabel.textColor = RQTitleTextColor; _dateLabel.numberOfLines = 0; _dateLabel.font = [UIFont systemFontOfSize:15]; } return _dateLabel; } - (UIButton *)studyBtn { if (!_studyBtn) { _studyBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_studyBtn setTitle:@"开始上课" forState:UIControlStateNormal]; _studyBtn.titleLabel.textAlignment = NSTextAlignmentCenter; _studyBtn.titleLabel.textColor = UIColor.whiteColor; _studyBtn.backgroundColor = RQSubColor; _studyBtn.titleLabel.numberOfLines = 0; _studyBtn.titleLabel.font = [UIFont systemFontOfSize:16]; } return _studyBtn; } @end