TrainSummaryHoursCell.m 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. //
  2. // TrainSummaryHoursCell.m
  3. // LN_School
  4. //
  5. // Created by 张嵘 on 2019/7/28.
  6. // Copyright © 2019 Danson. All rights reserved.
  7. //
  8. #import "TrainSummaryHoursCell.h"
  9. #import "ShowPhotoesViewController.h"
  10. @interface TrainSummaryHoursCell ()
  11. @property (nonatomic, readwrite, strong) UILabel *stageLabel;
  12. @property (nonatomic, readwrite, strong) UIImageView *centerLineView;
  13. @property (nonatomic, readwrite, strong) UILabel *theoryHoursLabel;
  14. @property (nonatomic, readwrite, strong) UILabel *practicalOperationHoursLabel;
  15. @property (nonatomic, readwrite, strong) UILabel *mileageHoursLabel;
  16. @property (nonatomic, readwrite, strong) UILabel *simulateHoursLabel;
  17. @property (nonatomic, readwrite, strong) UILabel *assessmentHoursLabel;
  18. @property (nonatomic, readwrite, strong) UILabel *classTrainingHoursLabel;
  19. @property (nonatomic, readwrite, strong) UIImageView *bottomLineView;
  20. @property (nonatomic, readwrite, strong) UIButton *showPhotoesBtn;
  21. @property (nonatomic, readwrite, strong) UILabel *totalHoursLabel;
  22. @end
  23. @implementation TrainSummaryHoursCell
  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.stageLabel];
  30. [self.contentView addSubview:self.centerLineView];
  31. [self.contentView addSubview:self.theoryHoursLabel];
  32. [self.contentView addSubview:self.practicalOperationHoursLabel];
  33. [self.contentView addSubview:self.mileageHoursLabel];
  34. [self.contentView addSubview:self.simulateHoursLabel];
  35. [self.contentView addSubview:self.assessmentHoursLabel];
  36. [self.contentView addSubview:self.classTrainingHoursLabel];
  37. [self.contentView addSubview:self.bottomLineView];
  38. [self.contentView addSubview:self.showPhotoesBtn];
  39. [self.contentView addSubview:self.totalHoursLabel];
  40. }
  41. return self;
  42. }
  43. - (void)layoutSubviews {
  44. [super layoutSubviews];
  45. [_stageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.top.left.mas_offset(16);
  47. make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - 16 * 5) * (1.f / 3.f), (self.bounds.size.height - 7 * 16) / 4.f));
  48. }];
  49. [_centerLineView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.mas_equalTo(_stageLabel.mas_bottom).mas_offset(16);
  51. make.left.mas_equalTo(_stageLabel);
  52. make.right.mas_offset(0);
  53. make.height.mas_equalTo(1);
  54. }];
  55. [_theoryHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.top.mas_equalTo(_centerLineView.mas_bottom).mas_offset(16);
  57. make.left.mas_equalTo(_stageLabel);
  58. make.size.mas_equalTo(_stageLabel);
  59. }];
  60. [_practicalOperationHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.top.mas_equalTo(_theoryHoursLabel);
  62. make.centerX.mas_equalTo(self.contentView);
  63. make.size.mas_equalTo(_stageLabel);
  64. }];
  65. [_mileageHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.top.mas_equalTo(_theoryHoursLabel);
  67. make.right.mas_offset(-16);
  68. make.size.mas_equalTo(_stageLabel);
  69. }];
  70. [_simulateHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.top.mas_equalTo(_theoryHoursLabel.mas_bottom).mas_offset(16);
  72. make.left.mas_equalTo(_stageLabel);
  73. make.size.mas_equalTo(_stageLabel);
  74. }];
  75. [_assessmentHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.top.mas_equalTo(_simulateHoursLabel);
  77. make.centerX.mas_equalTo(self.contentView);
  78. make.size.mas_equalTo(_stageLabel);
  79. }];
  80. [_classTrainingHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.top.mas_equalTo(_simulateHoursLabel);
  82. make.right.mas_offset(-16);
  83. make.size.mas_equalTo(_stageLabel);
  84. }];
  85. [_bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.mas_equalTo(_simulateHoursLabel.mas_bottom).mas_offset(16);
  87. make.left.mas_equalTo(_stageLabel);
  88. make.right.mas_offset(0);
  89. make.height.mas_equalTo(1);
  90. }];
  91. [_showPhotoesBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.top.mas_equalTo(_bottomLineView.mas_bottom).mas_offset(12);
  93. make.left.mas_equalTo(_stageLabel);
  94. make.size.mas_equalTo(CGSizeMake(90, (self.bounds.size.height - 5 * 16) / 4.f));
  95. }];
  96. [_totalHoursLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  97. make.top.mas_equalTo(_bottomLineView.mas_bottom).mas_offset(16);
  98. make.right.mas_offset(-16);
  99. make.size.mas_equalTo(_stageLabel);
  100. }];
  101. }
  102. #pragma mark - HDUpdateUIProtocol
  103. - (void)updateCellUI:(__kindof HDCellModel *)model {
  104. // TrainRecordModel *trainRecordModel = model.orgData;
  105. // [self.headImageView sd_setImageWithURL:[NSURL URLWithString:trainRecordModel.url? : @""] placeholderImage:[UIImage imageNamed:@"HeaderPlacehold"]];
  106. // self.timeLabel.text = [NSString stringWithFormat:@"时间:%@",trainRecordModel.time];
  107. // self.stageLabel.text = [NSString stringWithFormat:@"阶段:%@",trainRecordModel.stage];
  108. // self.driverObjectLabel.text = [NSString stringWithFormat:@"类型:%@",trainRecordModel.object];
  109. // self.driverHoursLabel.text = [NSString stringWithFormat:@"学时:%@",trainRecordModel.hour];
  110. }
  111. #pragma mark - Private Functions
  112. - (void)showPhotoesBtnAction {
  113. ShowPhotoesViewController *vc = [[ShowPhotoesViewController alloc] init];
  114. [[RQ_SHARE_FUNCTION getCurrentVC] navPushHideTabbarToVC:vc];
  115. }
  116. #pragma mark - Lazy Load
  117. - (UILabel *)stageLabel {
  118. if (!_stageLabel) {
  119. _stageLabel = [[UILabel alloc] init];
  120. _stageLabel.text = @"阶段三";
  121. _stageLabel.textAlignment = NSTextAlignmentLeft;
  122. _stageLabel.textColor = RQSubColor;
  123. _stageLabel.numberOfLines = 0;
  124. _stageLabel.font = [UIFont systemFontOfSize:16];
  125. }
  126. return _stageLabel;
  127. }
  128. - (UIImageView *)centerLineView {
  129. if (!_centerLineView) {
  130. _centerLineView = [[UIImageView alloc] init];
  131. _centerLineView.backgroundColor = RQBackGroundColor;
  132. }
  133. return _centerLineView;
  134. }
  135. - (UILabel *)theoryHoursLabel {
  136. if (!_theoryHoursLabel) {
  137. _theoryHoursLabel = [[UILabel alloc] init];
  138. _theoryHoursLabel.text = @"理论:25";
  139. _theoryHoursLabel.textAlignment = NSTextAlignmentLeft;
  140. _theoryHoursLabel.textColor = RQTitleTextColor;
  141. _theoryHoursLabel.numberOfLines = 0;
  142. _theoryHoursLabel.font = [UIFont systemFontOfSize:16];
  143. }
  144. return _theoryHoursLabel;
  145. }
  146. - (UILabel *)practicalOperationHoursLabel {
  147. if (!_practicalOperationHoursLabel) {
  148. _practicalOperationHoursLabel = [[UILabel alloc] init];
  149. _practicalOperationHoursLabel.text = @"实操:25";
  150. _practicalOperationHoursLabel.textAlignment = NSTextAlignmentCenter;
  151. _practicalOperationHoursLabel.textColor = RQTitleTextColor;
  152. _practicalOperationHoursLabel.numberOfLines = 0;
  153. _practicalOperationHoursLabel.font = [UIFont systemFontOfSize:16];
  154. }
  155. return _practicalOperationHoursLabel;
  156. }
  157. - (UILabel *)mileageHoursLabel {
  158. if (!_mileageHoursLabel) {
  159. _mileageHoursLabel = [[UILabel alloc] init];
  160. _mileageHoursLabel.text = @"里程:25";
  161. _mileageHoursLabel.textAlignment = NSTextAlignmentRight;
  162. _mileageHoursLabel.textColor = RQTitleTextColor;
  163. _mileageHoursLabel.numberOfLines = 0;
  164. _mileageHoursLabel.font = [UIFont systemFontOfSize:16];
  165. }
  166. return _mileageHoursLabel;
  167. }
  168. - (UILabel *)simulateHoursLabel {
  169. if (!_simulateHoursLabel) {
  170. _simulateHoursLabel = [[UILabel alloc] init];
  171. _simulateHoursLabel.text = @"模拟:25";
  172. _simulateHoursLabel.textAlignment = NSTextAlignmentLeft;
  173. _simulateHoursLabel.textColor = RQTitleTextColor;
  174. _simulateHoursLabel.numberOfLines = 0;
  175. _simulateHoursLabel.font = [UIFont systemFontOfSize:16];
  176. }
  177. return _simulateHoursLabel;
  178. }
  179. - (UILabel *)assessmentHoursLabel {
  180. if (!_assessmentHoursLabel) {
  181. _assessmentHoursLabel = [[UILabel alloc] init];
  182. _assessmentHoursLabel.text = @"考核:25";
  183. _assessmentHoursLabel.textAlignment = NSTextAlignmentCenter;
  184. _assessmentHoursLabel.textColor = RQTitleTextColor;
  185. _assessmentHoursLabel.numberOfLines = 0;
  186. _assessmentHoursLabel.font = [UIFont systemFontOfSize:16];
  187. }
  188. return _assessmentHoursLabel;
  189. }
  190. - (UILabel *)classTrainingHoursLabel {
  191. if (!_classTrainingHoursLabel) {
  192. _classTrainingHoursLabel = [[UILabel alloc] init];
  193. _classTrainingHoursLabel.text = @"堂训:25";
  194. _classTrainingHoursLabel.textAlignment = NSTextAlignmentRight;
  195. _classTrainingHoursLabel.textColor = RQTitleTextColor;
  196. _classTrainingHoursLabel.numberOfLines = 0;
  197. _classTrainingHoursLabel.font = [UIFont systemFontOfSize:16];
  198. }
  199. return _classTrainingHoursLabel;
  200. }
  201. - (UIImageView *)bottomLineView {
  202. if (!_bottomLineView) {
  203. _bottomLineView = [[UIImageView alloc] init];
  204. _bottomLineView.backgroundColor = RQBackGroundColor;
  205. }
  206. return _bottomLineView;
  207. }
  208. - (UIButton *)showPhotoesBtn {
  209. if (!_showPhotoesBtn) {
  210. _showPhotoesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  211. _showPhotoesBtn.layer.borderWidth = 1;
  212. _showPhotoesBtn.layer.borderColor = RQGreenColor.CGColor;
  213. _showPhotoesBtn.layer.cornerRadius = 5;
  214. _showPhotoesBtn.layer.masksToBounds = YES;
  215. _showPhotoesBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  216. _showPhotoesBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
  217. [_showPhotoesBtn setTitle:@"查看照片" forState:UIControlStateNormal];
  218. [_showPhotoesBtn setTitleColor:RQGreenColor forState:UIControlStateNormal];
  219. [_showPhotoesBtn addTarget:self action:@selector(showPhotoesBtnAction) forControlEvents:UIControlEventTouchUpInside];
  220. }
  221. return _showPhotoesBtn;
  222. }
  223. - (UILabel *)totalHoursLabel {
  224. if (!_totalHoursLabel) {
  225. _totalHoursLabel = [[UILabel alloc] init];
  226. _totalHoursLabel.text = @"合计:150";
  227. _totalHoursLabel.textAlignment = NSTextAlignmentRight;
  228. _totalHoursLabel.textColor = RQGreenColor;
  229. _totalHoursLabel.numberOfLines = 0;
  230. _totalHoursLabel.font = [UIFont systemFontOfSize:16];
  231. }
  232. return _totalHoursLabel;
  233. }
  234. @end