AppointDriverCell.m 9.7 KB

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