123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- //
- // TrainingSituationCell.m
- // LN_School
- //
- // Created by 张嵘 on 2019/7/18.
- // Copyright © 2019 Danson. All rights reserved.
- //
- #import "TrainingSituationCell.h"
- #import "TrainingSituationModel.h"
- @interface TrainingSituationCell ()
- @property (nonatomic, readwrite, strong) UIImageView *headImageView;
- @property (nonatomic, readwrite, strong) UILabel *nameLabel;
- @property (nonatomic, readwrite, strong) UILabel *carTypeLabel;
- @property (nonatomic, readwrite, strong) UILabel *totalHoursLabel;
- @property (nonatomic, readwrite, strong) UILabel *finishedHoursLabel;
- @property (nonatomic, readwrite, strong) UIImageView *arrowImageView;
- @property (nonatomic, readwrite, strong) UIImageView *bottomLineView;
- @end
- @implementation TrainingSituationCell
- #pragma mark - Life Cycle
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.contentView.backgroundColor = UIColor.whiteColor;
- [self.contentView addSubview:self.headImageView];
- [self.contentView addSubview:self.nameLabel];
- [self.contentView addSubview:self.carTypeLabel];
- [self.contentView addSubview:self.totalHoursLabel];
- [self.contentView addSubview:self.finishedHoursLabel];
- [self.contentView addSubview:self.arrowImageView];
- [self.contentView addSubview:self.bottomLineView];
- }
- __weak typeof(self) weakS = self;
- [self addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
- [weakS clickSelf];
- }];
- return self;
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
-
- CGFloat width = self.bounds.size.width - 16 - 16 - 16;
-
- [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(self.contentView);
- make.left.mas_equalTo(self.contentView).mas_offset(16);
- make.size.mas_equalTo(CGSizeMake(width * 0.15, width * 0.15));
- }];
-
- [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.contentView).mas_offset(8);
- make.left.mas_equalTo(_headImageView.mas_right).mas_offset(16);
- make.size.mas_equalTo(CGSizeMake(width * 0.425, self.bounds.size.height * 0.4));
- }];
-
- [_carTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(_nameLabel);
- make.bottom.mas_equalTo(self.contentView).mas_offset(-8);
- make.size.mas_equalTo(_nameLabel);
- }];
-
- [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(self.contentView);
- make.right.mas_equalTo(self.contentView).mas_offset(-16);
- make.size.mas_equalTo(CGSizeMake(width * 0.025, (width * 0.025) * (39.0 / 21.0)));
- }];
-
- [_totalHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(_nameLabel);
- make.right.mas_equalTo(_arrowImageView.mas_left);
- make.size.mas_equalTo(CGSizeMake(width * 0.4, self.bounds.size.height * 0.4));
- }];
-
- [_finishedHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(_carTypeLabel);
- make.right.mas_equalTo(_arrowImageView.mas_left);
- make.size.mas_equalTo(_totalHoursLabel);
- }];
-
- [_bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_offset(16);
- make.right.mas_offset(-16);
- make.bottom.mas_offset(0);
- make.height.mas_equalTo(1);
- }];
- }
- #pragma mark - HDUpdateUIProtocol
- - (void)updateCellUI:(__kindof HDCellModel *)model {
- TrainingSituationModel *trainingSituationModel = model.orgData;
- self.headImageView.image = [UIImage imageNamed:trainingSituationModel.imageName];
- self.nameLabel.text = [NSString stringWithFormat:@"姓名:%@",trainingSituationModel.name];
- self.carTypeLabel.text = [NSString stringWithFormat:@"车型:%@",trainingSituationModel.carType];
- self.totalHoursLabel.text = [NSString stringWithFormat:@"培训总学时:%@",trainingSituationModel.totalHours];
- self.finishedHoursLabel.text = [NSString stringWithFormat:@"已完成学时:%@",trainingSituationModel.finishedHours];
- }
- #pragma mark - Private Functions
- - (void)clickSelf {
- self.callback(self.hdModel);
- }
- #pragma mark - Lazy Load
- - (UIImageView *)headImageView {
- if (!_headImageView) {
- _headImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HeaderPlacehold"]];
- }
- return _headImageView;
- }
- - (UILabel *)nameLabel {
- if (!_nameLabel) {
- _nameLabel = [[UILabel alloc] init];
- _nameLabel.textAlignment = NSTextAlignmentLeft;
- _nameLabel.textColor = RQTitleTextColor;
- _nameLabel.numberOfLines = 0;
- _nameLabel.font = [UIFont systemFontOfSize:15];
- }
- return _nameLabel;
- }
- - (UILabel *)carTypeLabel {
- if (!_carTypeLabel) {
- _carTypeLabel = [[UILabel alloc] init];
- _carTypeLabel.textAlignment = NSTextAlignmentLeft;
- _carTypeLabel.textColor = RQTitleTextColor;
- _carTypeLabel.numberOfLines = 0;
- _carTypeLabel.font = [UIFont systemFontOfSize:15];
- }
- return _carTypeLabel;
- }
- - (UILabel *)totalHoursLabel {
- if (!_totalHoursLabel) {
- _totalHoursLabel = [[UILabel alloc] init];
- _totalHoursLabel.textAlignment = NSTextAlignmentLeft;
- _totalHoursLabel.textColor = RQTitleTextColor;
- _totalHoursLabel.numberOfLines = 0;
- _totalHoursLabel.font = [UIFont systemFontOfSize:15];
- }
- return _totalHoursLabel;
- }
- - (UILabel *)finishedHoursLabel {
- if (!_finishedHoursLabel) {
- _finishedHoursLabel = [[UILabel alloc] init];
- _finishedHoursLabel.textAlignment = NSTextAlignmentLeft;
- _finishedHoursLabel.textColor = RQTitleTextColor;
- _finishedHoursLabel.numberOfLines = 0;
- _finishedHoursLabel.font = [UIFont systemFontOfSize:15];
- }
- return _finishedHoursLabel;
- }
- - (UIImageView *)arrowImageView {
- if (!_arrowImageView) {
- _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Arrow"]];
- }
- return _arrowImageView;
- }
- - (UIImageView *)bottomLineView {
- if (!_bottomLineView) {
- _bottomLineView = [[UIImageView alloc] init];
- _bottomLineView.backgroundColor = RQBackGroundColor;
- }
- return _bottomLineView;
- }
- @end
|