| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- //
- // HJExperienceView.m
- // HappyJob
- //
- // Created by Bob on 2019/4/17.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJExperienceView.h"
- #import "HJResumeKeys.h"
- #import "HJLoginInfoLookResumeExperienceListView.h"
- @interface HJExperienceView ()
- @property (nonatomic, strong) UIButton *titleBtn;
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) UIButton *changeBtn;//修改btn
- @property (nonatomic, strong) UIImageView *noWriteImageV;
- @property (nonatomic, strong) UILabel *noWriteLanel;
- @property (nonatomic, strong) HJLoginInfoLookResumeExperienceListView *lastListView;
- @end
- @implementation HJExperienceView
- - (instancetype)init {
-
- if (self = [super init])
- {
-
- }
- return self;
- }
- - (void)configWithData:(NSDictionary *)data {
-
- for (UIView *subView in self.bgView.subviews)
- {
- [subView removeFromSuperview];
- }
- [self.bgView removeFromSuperview];
-
- if (data == nil || [data isEqual:[NSNull null]])
- {
- return;
- }
-
- [self addSubview:self.bgView];
- [self.bgView addSubview:self.titleBtn];
- [self.bgView addSubview:self.changeBtn];
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(self.mas_leading).offset(15);
- make.trailing.equalTo(self.mas_trailing).offset(-15);
- make.top.equalTo(self.mas_top).offset(0);
- make.bottom.equalTo(self.mas_bottom).offset(0);
- }];
- [_titleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(self.bgView.mas_leading).offset(32);
- make.top.equalTo(self.bgView.mas_top).offset(34);
- }];
- [_changeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.right.equalTo(self.bgView.mas_right).offset(-30);
- make.centerY.equalTo(self.titleBtn);
- }];
- NSArray *listArray = data[kHJResumeKeyWorkExperience];
- if (listArray.count > 0)
- {
- _noWriteImageV.hidden = YES;
- _noWriteLanel.hidden = YES;
- _changeBtn.tag = 101;
- [_changeBtn setTitle:@"点击修改 >" forState:UIControlStateNormal];
- for (int i = 0; i < listArray.count; i ++ )
- {
- NSDictionary *dict = listArray[i];
-
- HJLoginInfoLookResumeExperienceListView *listView = [[HJLoginInfoLookResumeExperienceListView alloc]init];
-
- listView.addressLabel.text = dict[kHJResumeKeyWorkCompany];
- listView.positionLabel.text = dict[kHJResumeKeyWorkPosition];
- listView.timeLabel.text = [NSString stringWithFormat:@"%@至%@",dict[kHJResumeKeyWorkStartDate],dict[kHJResumeKeyWorkEndDate]];
- [self.bgView addSubview:listView];
- [listView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- if (i == 0)
- {
- make.top.equalTo(self.titleBtn.mas_bottom).offset(18);
- listView.topView.hidden = YES;
- }
- else
- {
- make.top.equalTo(self.lastListView.mas_bottom).offset(0);
- }
- make.leading.equalTo(self.bgView.mas_leading).offset(15);
- make.trailing.equalTo(self.bgView.mas_trailing).offset(-15);
- if (i == listArray.count - 1)
- {
- make.bottom.equalTo(self.bgView.mas_bottom).offset(0);
- listView.downView.hidden = YES;
- listView.dottedlLineIcon.hidden = YES;
- }
- }];
- if (listArray.count == 1)
- {
- listView.downView.hidden = NO;
- }
- self.lastListView = listView;
- }
- }
- else
- {
- [self.bgView addSubview:self.noWriteLanel];
- [self.bgView addSubview:self.noWriteImageV];
- _changeBtn.tag = 100;
- [_changeBtn setTitle:@"点击添加 >" forState:UIControlStateNormal];
- [_noWriteLanel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.centerX.equalTo(self.bgView);
- make.top.equalTo(self.titleBtn.mas_bottom).offset(40);
- make.bottom.equalTo(self.bgView.mas_bottom).offset(-67);
- }];
- [_noWriteImageV mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.titleBtn.mas_bottom).offset(40);
- make.right.equalTo(self.noWriteLanel.mas_left).offset(-20);
- make.size.mas_offset(CGSizeMake(7, 40));
- }];
- }
- }
- #pragma mark - event response
- - (void)changeButtonClick:(UIButton *)btn {
-
- if (btn.tag == 100)
- {
- if ([self.delegate respondsToSelector:@selector(experienceShouldAdd:)])
- {
- [self.delegate experienceShouldAdd:self];
- }
- }
- else
- {
- if ([self.delegate respondsToSelector:@selector(experienceList:)])
- {
- [self.delegate experienceList:self ];
- }
- }
-
- }
- #pragma mark - getters and setters
- - (UIView *)bgView {
-
- if (_bgView == nil)
- {
- _bgView = [[UIView alloc]init];
- _bgView.backgroundColor = [UIColor whiteColor];
- _bgView.layer.cornerRadius = 10;
- _bgView.layer.masksToBounds = YES;
- }
- return _bgView;
- }
- - (UIButton *)titleBtn {
-
- if (_titleBtn == nil)
- {
- _titleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_titleBtn setImage:[UIImage imageNamed:@"look_work_experience"] forState:UIControlStateNormal];
- [_titleBtn setTitle:@"工作经验" forState:UIControlStateNormal];
- _titleBtn.titleLabel.font = [UIFont systemFontOfSize:19];
- [_titleBtn setTitleColor:COLOR_BACK3 forState:UIControlStateNormal];
- [_titleBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:10];
- }
- return _titleBtn;
- }
- - (UIButton *)changeBtn {
-
- if (_changeBtn == nil)
- {
- _changeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_changeBtn setTitle:@"点击修改 >" forState:UIControlStateNormal];
- [_changeBtn setTitleColor:COLOR_BLUE_4183E1 forState:UIControlStateNormal];
- _changeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- [_changeBtn addTarget:self action:@selector(changeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _changeBtn;
- }
- - (UIImageView *)noWriteImageV {
-
- if (_noWriteImageV == nil)
- {
- _noWriteImageV = [[UIImageView alloc]init];
- _noWriteImageV.image = [UIImage imageNamed:@"resume_empty_experience"];
- }
- return _noWriteImageV;
- }
- - (UILabel *)noWriteLanel {
-
- if (_noWriteLanel == nil)
- {
- _noWriteLanel = [[UILabel alloc]init];
- _noWriteLanel.text = @"用户暂未填写工作经验";
- _noWriteLanel.font = [UIFont systemFontOfSize:15];
- _noWriteLanel.textColor = COLOR_GRAY9;
- }
- return _noWriteLanel;
- }
- @end
|