PreExamMarkCell.m 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. //
  2. // PreExamMarkCell.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/31.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "PreExamMarkCell.h"
  9. #import "PreExamMarkModel.h"
  10. @interface PreExamMarkCell ()
  11. @property (nonatomic, readwrite, strong) UILabel *studentNameLabel;
  12. @property (nonatomic, readwrite, strong) YYLabel *passStatusLabel;
  13. @property (nonatomic, readwrite, strong) UIImageView *centerLineView;
  14. @property (nonatomic, readwrite, strong) UIImageView *coachIconImageView;
  15. @property (nonatomic, readwrite, strong) UILabel *coachLabel;
  16. @property (nonatomic, readwrite, strong) UIImageView *objectIconImageView;
  17. @property (nonatomic, readwrite, strong) UILabel *objectLabel;
  18. @property (nonatomic, readwrite, strong) UILabel *objectScoreLabel;
  19. @property (nonatomic, readwrite, strong) UIImageView *dateIconImageView;
  20. @property (nonatomic, readwrite, strong) UILabel *dateLabel;
  21. @end
  22. @implementation PreExamMarkCell
  23. #pragma mark - Life Cycle
  24. - (instancetype)initWithFrame:(CGRect)frame {
  25. self = [super initWithFrame:frame];
  26. if (self) {
  27. self.contentView.backgroundColor = UIColor.whiteColor;
  28. [self.contentView addSubview:self.studentNameLabel];
  29. [self.contentView addSubview:self.passStatusLabel];
  30. [self.contentView addSubview:self.centerLineView];
  31. [self.contentView addSubview:self.coachIconImageView];
  32. [self.contentView addSubview:self.coachLabel];
  33. [self.contentView addSubview:self.objectIconImageView];
  34. [self.contentView addSubview:self.objectLabel];
  35. [self.contentView addSubview:self.objectScoreLabel];
  36. [self.contentView addSubview:self.dateIconImageView];
  37. [self.contentView addSubview:self.dateLabel];
  38. }
  39. return self;
  40. }
  41. - (void)layoutSubviews {
  42. [super layoutSubviews];
  43. [_studentNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.top.left.mas_offset(16);
  45. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 3) * (2.f / 3.f), (self.bounds.size.height - 6 * 16) / 3.f));
  46. }];
  47. [_passStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.top.mas_offset(16);
  49. make.right.mas_equalTo(-16);
  50. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 3) * (1.f / 3.f), (self.bounds.size.height - 6 * 16) / 3.f));
  51. }];
  52. [_centerLineView mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.mas_equalTo(_studentNameLabel.mas_bottom).mas_offset(16);
  54. make.left.mas_equalTo(_studentNameLabel);
  55. make.right.mas_offset(0);
  56. make.height.mas_equalTo(1);
  57. }];
  58. [_coachIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.mas_equalTo(_centerLineView.mas_bottom).mas_offset(16);
  60. make.left.mas_equalTo(_studentNameLabel);
  61. make.size.mas_equalTo(CGSizeMake((self.bounds.size.height - 6 * 16) / 5.f , (self.bounds.size.height - 6 * 16) / 5.f));
  62. }];
  63. [_coachLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  64. make.centerY.mas_equalTo(_coachIconImageView);
  65. make.left.mas_equalTo(_coachIconImageView.mas_right).mas_offset(8);
  66. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 2 - 8 - _coachIconImageView.frame.size.width), (self.bounds.size.height - 6 * 16) / 4.f));
  67. }];
  68. [_objectIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.mas_equalTo(_coachIconImageView.mas_bottom).mas_offset(16);
  70. make.left.mas_equalTo(_coachIconImageView);
  71. make.size.mas_equalTo(CGSizeMake((self.bounds.size.height - 6 * 16) / 5.f , (self.bounds.size.height - 6 * 16) / 5.f));
  72. }];
  73. [_objectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.centerY.mas_equalTo(_objectIconImageView);
  75. make.left.mas_equalTo(_coachIconImageView.mas_right).mas_offset(8);
  76. make.size.mas_equalTo(CGSizeMake([@"科目一: " widthForFont:[UIFont systemFontOfSize:15]], (self.bounds.size.height - 6 * 16) / 4.f));
  77. }];
  78. [_objectScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.centerY.mas_equalTo(_objectIconImageView);
  80. make.left.mas_equalTo(_objectLabel.mas_right).mas_offset(0);
  81. 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));
  82. }];
  83. [_dateIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  84. make.top.mas_equalTo(_objectIconImageView.mas_bottom).mas_offset(16);
  85. make.left.mas_equalTo(_objectIconImageView);
  86. make.size.mas_equalTo(CGSizeMake((self.bounds.size.height - 6 * 16) / 5.f , (self.bounds.size.height - 6 * 16) / 5.f));
  87. }];
  88. [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.centerY.mas_equalTo(_dateIconImageView);
  90. make.left.mas_equalTo(_dateIconImageView.mas_right).mas_offset(8);
  91. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 2 - 8 - _coachIconImageView.frame.size.width), (self.bounds.size.height - 6 * 16) / 4.f));
  92. }];
  93. }
  94. #pragma mark - HDUpdateUIProtocol
  95. - (void)updateCellUI:(__kindof HDCellModel *)model {
  96. PreExamMarkModel *preExamMarkModel = model.orgData;
  97. _studentNameLabel.text = [NSString stringWithFormat:@"学员:%@", preExamMarkModel.studentName];
  98. _passStatusLabel.text = [NSString stringWithFormat:@"%@", preExamMarkModel.passStatus];
  99. _passStatusLabel.textColor = [preExamMarkModel.passStatus isEqualToString:@"未通过"]? RQRedColor : RQGreenColor;
  100. _coachLabel.text = [NSString stringWithFormat:@"教练:%@", preExamMarkModel.coachName];
  101. _objectLabel.text = [NSString stringWithFormat:@"%@:", preExamMarkModel.object];
  102. _objectScoreLabel.text = [NSString stringWithFormat:@"%@", preExamMarkModel.objectScore];
  103. _dateLabel.text = [NSString stringWithFormat:@"预考时间:%@", preExamMarkModel.date];
  104. }
  105. #pragma mark - Lazy Load
  106. - (UILabel *)studentNameLabel {
  107. if (!_studentNameLabel) {
  108. _studentNameLabel = [[UILabel alloc] init];
  109. _studentNameLabel.text = @"学员:张小凡";
  110. _studentNameLabel.textAlignment = NSTextAlignmentLeft;
  111. _studentNameLabel.textColor = RQContentTextColor;
  112. _studentNameLabel.numberOfLines = 0;
  113. _studentNameLabel.font = [UIFont systemFontOfSize:16];
  114. }
  115. return _studentNameLabel;
  116. }
  117. - (YYLabel *)passStatusLabel {
  118. if (!_passStatusLabel) {
  119. _passStatusLabel = [[YYLabel alloc] init];
  120. _passStatusLabel.text = @"通过";
  121. _passStatusLabel.textAlignment = NSTextAlignmentRight;
  122. _passStatusLabel.textColor = RQTitleTextColor;
  123. _passStatusLabel.numberOfLines = 0;
  124. _passStatusLabel.font = [UIFont systemFontOfSize:16];
  125. }
  126. return _passStatusLabel;
  127. }
  128. - (UIImageView *)centerLineView {
  129. if (!_centerLineView) {
  130. _centerLineView = [[UIImageView alloc] init];
  131. _centerLineView.backgroundColor = RQBackGroundColor;
  132. }
  133. return _centerLineView;
  134. }
  135. - (UIImageView *)coachIconImageView {
  136. if (!_coachIconImageView) {
  137. _coachIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"coachIcon"]];
  138. }
  139. return _coachIconImageView;
  140. }
  141. - (UILabel *)coachLabel {
  142. if (!_coachLabel) {
  143. _coachLabel = [[UILabel alloc] init];
  144. _coachLabel.text = @"教练:张小丽";
  145. _coachLabel.textAlignment = NSTextAlignmentLeft;
  146. _coachLabel.textColor = RQTitleTextColor;
  147. _coachLabel.numberOfLines = 0;
  148. _coachLabel.font = [UIFont systemFontOfSize:15];
  149. }
  150. return _coachLabel;
  151. }
  152. - (UIImageView *)objectIconImageView {
  153. if (!_objectIconImageView) {
  154. _objectIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"objectIcon"]];
  155. }
  156. return _objectIconImageView;
  157. }
  158. - (UILabel *)objectLabel {
  159. if (!_objectLabel) {
  160. _objectLabel = [[UILabel alloc] init];
  161. _objectLabel.text = @"科目一:";
  162. _objectLabel.textAlignment = NSTextAlignmentLeft;
  163. _objectLabel.textColor = RQTitleTextColor;
  164. _objectLabel.numberOfLines = 0;
  165. _objectLabel.font = [UIFont systemFontOfSize:15];
  166. }
  167. return _objectLabel;
  168. }
  169. - (UILabel *)objectScoreLabel {
  170. if (!_objectScoreLabel) {
  171. _objectScoreLabel = [[UILabel alloc] init];
  172. _objectScoreLabel.text = @"90";
  173. _objectScoreLabel.textAlignment = NSTextAlignmentLeft;
  174. _objectScoreLabel.textColor = RQTitleTextColor;
  175. _objectScoreLabel.numberOfLines = 0;
  176. _objectScoreLabel.font = [UIFont systemFontOfSize:15];
  177. }
  178. return _objectScoreLabel;
  179. }
  180. - (UIImageView *)dateIconImageView {
  181. if (!_dateIconImageView) {
  182. _dateIconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dateIcon"]];
  183. }
  184. return _dateIconImageView;
  185. }
  186. - (UILabel *)dateLabel {
  187. if (!_dateLabel) {
  188. _dateLabel = [[UILabel alloc] init];
  189. _dateLabel.text = @"预考时间:2019-09-09";
  190. _dateLabel.textAlignment = NSTextAlignmentLeft;
  191. _dateLabel.textColor = RQTitleTextColor;
  192. _dateLabel.numberOfLines = 0;
  193. _dateLabel.font = [UIFont systemFontOfSize:15];
  194. }
  195. return _dateLabel;
  196. }
  197. @end