HJExperienceView.m 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. //
  2. // HJExperienceView.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/4/17.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJExperienceView.h"
  9. #import "HJResumeKeys.h"
  10. #import "HJLoginInfoLookResumeExperienceListView.h"
  11. @interface HJExperienceView ()
  12. @property (nonatomic, strong) UIButton *titleBtn;
  13. @property (nonatomic, strong) UIView *bgView;
  14. @property (nonatomic, strong) UIButton *changeBtn;//修改btn
  15. @property (nonatomic, strong) UIImageView *noWriteImageV;
  16. @property (nonatomic, strong) UILabel *noWriteLanel;
  17. @property (nonatomic, strong) HJLoginInfoLookResumeExperienceListView *lastListView;
  18. @end
  19. @implementation HJExperienceView
  20. - (instancetype)init {
  21. if (self = [super init])
  22. {
  23. }
  24. return self;
  25. }
  26. - (void)configWithData:(NSDictionary *)data {
  27. for (UIView *subView in self.bgView.subviews)
  28. {
  29. [subView removeFromSuperview];
  30. }
  31. [self.bgView removeFromSuperview];
  32. if (data == nil || [data isEqual:[NSNull null]])
  33. {
  34. return;
  35. }
  36. [self addSubview:self.bgView];
  37. [self.bgView addSubview:self.titleBtn];
  38. [self.bgView addSubview:self.changeBtn];
  39. [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.leading.equalTo(self.mas_leading).offset(15);
  41. make.trailing.equalTo(self.mas_trailing).offset(-15);
  42. make.top.equalTo(self.mas_top).offset(0);
  43. make.bottom.equalTo(self.mas_bottom).offset(0);
  44. }];
  45. [_titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.leading.equalTo(self.bgView.mas_leading).offset(32);
  47. make.top.equalTo(self.bgView.mas_top).offset(34);
  48. }];
  49. [_changeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.right.equalTo(self.bgView.mas_right).offset(-30);
  51. make.centerY.equalTo(self.titleBtn);
  52. }];
  53. NSArray *listArray = data[kHJResumeKeyWorkExperience];
  54. if (listArray.count > 0)
  55. {
  56. _noWriteImageV.hidden = YES;
  57. _noWriteLanel.hidden = YES;
  58. _changeBtn.tag = 101;
  59. [_changeBtn setTitle:@"点击修改 >" forState:UIControlStateNormal];
  60. for (int i = 0; i < listArray.count; i ++ )
  61. {
  62. NSDictionary *dict = listArray[i];
  63. HJLoginInfoLookResumeExperienceListView *listView = [[HJLoginInfoLookResumeExperienceListView alloc]init];
  64. listView.addressLabel.text = dict[kHJResumeKeyWorkCompany];
  65. listView.positionLabel.text = dict[kHJResumeKeyWorkPosition];
  66. listView.timeLabel.text = [NSString stringWithFormat:@"%@至%@",dict[kHJResumeKeyWorkStartDate],dict[kHJResumeKeyWorkEndDate]];
  67. [self.bgView addSubview:listView];
  68. [listView mas_makeConstraints:^(MASConstraintMaker *make) {
  69. if (i == 0)
  70. {
  71. make.top.equalTo(self.titleBtn.mas_bottom).offset(18);
  72. listView.topView.hidden = YES;
  73. }
  74. else
  75. {
  76. make.top.equalTo(self.lastListView.mas_bottom).offset(0);
  77. }
  78. make.leading.equalTo(self.bgView.mas_leading).offset(15);
  79. make.trailing.equalTo(self.bgView.mas_trailing).offset(-15);
  80. if (i == listArray.count - 1)
  81. {
  82. make.bottom.equalTo(self.bgView.mas_bottom).offset(0);
  83. listView.downView.hidden = YES;
  84. listView.dottedlLineIcon.hidden = YES;
  85. }
  86. }];
  87. if (listArray.count == 1)
  88. {
  89. listView.downView.hidden = NO;
  90. }
  91. self.lastListView = listView;
  92. }
  93. }
  94. else
  95. {
  96. [self.bgView addSubview:self.noWriteLanel];
  97. [self.bgView addSubview:self.noWriteImageV];
  98. _changeBtn.tag = 100;
  99. [_changeBtn setTitle:@"点击添加 >" forState:UIControlStateNormal];
  100. [_noWriteLanel mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.centerX.equalTo(self.bgView);
  102. make.top.equalTo(self.titleBtn.mas_bottom).offset(40);
  103. make.bottom.equalTo(self.bgView.mas_bottom).offset(-67);
  104. }];
  105. [_noWriteImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.top.equalTo(self.titleBtn.mas_bottom).offset(40);
  107. make.right.equalTo(self.noWriteLanel.mas_left).offset(-20);
  108. make.size.mas_offset(CGSizeMake(7, 40));
  109. }];
  110. }
  111. }
  112. #pragma mark - event response
  113. - (void)changeButtonClick:(UIButton *)btn {
  114. if (btn.tag == 100)
  115. {
  116. if ([self.delegate respondsToSelector:@selector(experienceShouldAdd:)])
  117. {
  118. [self.delegate experienceShouldAdd:self];
  119. }
  120. }
  121. else
  122. {
  123. if ([self.delegate respondsToSelector:@selector(experienceList:)])
  124. {
  125. [self.delegate experienceList:self ];
  126. }
  127. }
  128. }
  129. #pragma mark - getters and setters
  130. - (UIView *)bgView {
  131. if (_bgView == nil)
  132. {
  133. _bgView = [[UIView alloc]init];
  134. _bgView.backgroundColor = [UIColor whiteColor];
  135. _bgView.layer.cornerRadius = 10;
  136. _bgView.layer.masksToBounds = YES;
  137. }
  138. return _bgView;
  139. }
  140. - (UIButton *)titleBtn {
  141. if (_titleBtn == nil)
  142. {
  143. _titleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  144. [_titleBtn setImage:[UIImage imageNamed:@"look_work_experience"] forState:UIControlStateNormal];
  145. [_titleBtn setTitle:@"工作经验" forState:UIControlStateNormal];
  146. _titleBtn.titleLabel.font = [UIFont systemFontOfSize:19];
  147. [_titleBtn setTitleColor:COLOR_BACK3 forState:UIControlStateNormal];
  148. [_titleBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:10];
  149. }
  150. return _titleBtn;
  151. }
  152. - (UIButton *)changeBtn {
  153. if (_changeBtn == nil)
  154. {
  155. _changeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  156. [_changeBtn setTitle:@"点击修改 >" forState:UIControlStateNormal];
  157. [_changeBtn setTitleColor:COLOR_BLUE_4183E1 forState:UIControlStateNormal];
  158. _changeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
  159. [_changeBtn addTarget:self action:@selector(changeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  160. }
  161. return _changeBtn;
  162. }
  163. - (UIImageView *)noWriteImageV {
  164. if (_noWriteImageV == nil)
  165. {
  166. _noWriteImageV = [[UIImageView alloc]init];
  167. _noWriteImageV.image = [UIImage imageNamed:@"resume_empty_experience"];
  168. }
  169. return _noWriteImageV;
  170. }
  171. - (UILabel *)noWriteLanel {
  172. if (_noWriteLanel == nil)
  173. {
  174. _noWriteLanel = [[UILabel alloc]init];
  175. _noWriteLanel.text = @"用户暂未填写工作经验";
  176. _noWriteLanel.font = [UIFont systemFontOfSize:15];
  177. _noWriteLanel.textColor = COLOR_GRAY9;
  178. }
  179. return _noWriteLanel;
  180. }
  181. @end