| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- //
- // HJClockInStateView.m
- // HappyJob
- //
- // Created by 张晓光 on 2020/8/24.
- // Copyright © 2020 Bob. All rights reserved.
- //
- #import "HJClockInStateView.h"
- @implementation HJClockInStateView
- - (instancetype)initWithFrame:(CGRect)frame {
-
- if (self = [super initWithFrame:frame])
- {
- [self initSubViews];
- }
- return self;
- }
- - (void)initSubViews {
-
- [self addSubview:self.bgView];
- [self.bgView addSubview:self.goWorkView];
- [self.goWorkView addSubview:self.goWorkLabel];
- [self.goWorkView addSubview:self.goWorkStateView];
-
- [self.bgView addSubview:self.afterWorkView];
- [self.afterWorkView addSubview:self.afterWorkLabel];
- [self.afterWorkView addSubview:self.afterWorkStateView];
-
- [self.bgView addSubview:self.ruleLabel];
- [self.bgView addSubview:self.clockInButton];
-
- [self.bgView addSubview:self.promptView];
-
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.mas_left).offset(15);
- make.top.equalTo(self.mas_top).offset(10);
- make.right.equalTo(self.mas_right).offset(-15);
- make.bottom.equalTo(self.mas_bottom).offset(-10);
- }];
-
- //上班打卡
- [self.goWorkView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.bgView.mas_left).offset(13);
- make.top.equalTo(self.bgView.mas_top).offset(15);
- make.width.mas_equalTo((SCREEN_WIDTH - 15*2 - 13*2 - 6)/2);
- }];
- [self.goWorkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.goWorkView.mas_left).offset(15);
- make.top.equalTo(self.goWorkView.mas_top).offset(5);
- }];
- [self.goWorkStateView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.goWorkView.mas_left).offset(15);
- make.top.equalTo(self.goWorkLabel.mas_bottom).offset(2);
- make.bottom.equalTo(self.goWorkView.mas_bottom).offset(-5);
- }];
-
-
- //下班打卡
- [self.afterWorkView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.right.equalTo(self.bgView.mas_right).offset(-13);
- make.top.equalTo(self.bgView.mas_top).offset(15);
- make.width.mas_equalTo((SCREEN_WIDTH - 15*2 - 13*2 - 6)/2);
- }];
- [self.afterWorkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.afterWorkView.mas_left).offset(15);
- make.top.equalTo(self.afterWorkView.mas_top).offset(5);
- }];
- [self.afterWorkStateView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.afterWorkView.mas_left).offset(15);
- make.top.equalTo(self.afterWorkLabel.mas_bottom).offset(2);
- make.bottom.equalTo(self.afterWorkView.mas_bottom).offset(-5);
- }];
-
- //规则
- [self.ruleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.bgView.mas_left).offset(28);
- make.top.equalTo(self.goWorkView.mas_bottom).offset(10);
- }];
-
- //打卡
- [self.clockInButton mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.center.equalTo(self.bgView);
- make.size.mas_equalTo(CGSizeMake(140, 140));
- }];
-
-
- }
- - (void)setStateType:(HJClockInStateType)stateType {
-
- _stateType = stateType;
-
- switch (stateType) {
-
- case HJClockInStateTypeAuthing:
- {//审核中
- [self.clockInButton setImage:[UIImage imageNamed:@"clockin_audit"] forState:UIControlStateNormal];
- self.promptView.icon.image = [UIImage imageNamed:@"clockIn_state_warning"];
- self.promptView.textLabel.text = @"我们会尽快完成实名认证审核";
- [self goWork];
- }
- break;
-
- case HJClockInStateTypeGoWork:
- {//上班
- [self.clockInButton setImage:[UIImage imageNamed:@"clockIn_can"] forState:UIControlStateNormal];
- self.promptView.icon.image = [UIImage imageNamed:@"clockIn_state_can"];
- self.promptView.textLabel.text = @"已进入考勤打卡范围";
- [self goWork];
- }
- break;
-
- case HJClockInStateTypeGoWorkComplete:
- {//上班打卡完成,下班打卡还没开始
- [self.clockInButton setImage:[UIImage imageNamed:@"clockOut_disable"] forState:UIControlStateNormal];
- self.promptView.icon.image = [UIImage imageNamed:@"clockIn_state_warning"];
- [self afterWork];
- }
- break;
-
- case HJClockInStateTypeAfterWork:
- {//下班
- [self.clockInButton setImage:[UIImage imageNamed:@"clockOut_can"] forState:UIControlStateNormal];
- self.promptView.icon.image = [UIImage imageNamed:@"clockIn_state_can"];
- self.promptView.textLabel.text = @"已进入考勤打卡范围";
- [self afterWork];
- }
- break;
-
- case HJClockInStateTypeComplete:
- {//打卡完成
- [self.clockInButton setImage:[UIImage imageNamed:@"clockIn_done"] forState:UIControlStateNormal];
- self.promptView.icon.image = [UIImage imageNamed:@"clockIn_state_can"];
- self.promptView.textLabel.text = @"今日打卡已完成";
- [self complete];
- }
- break;
-
- case HJClockInStateTypeGoWorkOutOfRange:
- {//上班超出范围
- [self.clockInButton setImage:[UIImage imageNamed:@"clockin_beyond"] forState:UIControlStateNormal];
- self.promptView.icon.image = [UIImage imageNamed:@"clockIn_state_warning"];
- self.promptView.textLabel.text = @"请进入企业后再进行打卡";
-
- //从当前的下班打卡到下一个上班打卡
- self.goWorkStateView.icon.image = nil;
- [self.goWorkStateView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.goWorkStateView.icon.mas_right).offset(0);
- }];
-
- [self outOfRange];
- }
- break;
-
- case HJClockInStateTypeAfterWorkOutOfRange:
- {//下班超出范围
- [self.clockInButton setImage:[UIImage imageNamed:@"clockin_beyond"] forState:UIControlStateNormal];
- self.promptView.icon.image = [UIImage imageNamed:@"clockIn_state_warning"];
- self.promptView.textLabel.text = @"请进入企业后再进行打卡";
- //上班已经完成了
- self.goWorkStateView.icon.image = [UIImage imageNamed:@"clockIn_icon"];
- [self.goWorkStateView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.goWorkStateView.icon.mas_right).offset(3);
- }];
- [self outOfRange];
- }
- break;
-
- default:
- break;
- }
- }
- /* 上班 */
- - (void)goWork{
-
- [self.retryButton removeFromSuperview];
- [self.lineView removeFromSuperview];
- [self.wageView removeFromSuperview];
-
- //从当前的下班打卡到下一个上班打卡
- self.goWorkStateView.icon.image = nil;
- [self.goWorkStateView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.goWorkStateView.icon.mas_right).offset(0);
- }];
-
- //下班打卡完成
- self.afterWorkStateView.icon.image = nil;
- [self.afterWorkStateView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.afterWorkStateView.icon.mas_right).offset(0);
- }];
-
- [self.promptView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.clockInButton.mas_bottom).offset(25);
- make.centerX.equalTo(self.bgView);
- // make.bottom.equalTo(self.bgView.mas_bottom).offset(-HJXVerticalScale(50));
- }];
- [self.promptView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.promptView.icon.mas_right).offset(6);
- }];
-
- }
- /* 下班 */
- - (void)afterWork {
-
- [self.retryButton removeFromSuperview];
- [self.lineView removeFromSuperview];
- [self.wageView removeFromSuperview];
- //上班打卡完成了
- self.goWorkStateView.icon.image = [UIImage imageNamed:@"clockIn_icon"];
- [self.goWorkStateView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.goWorkStateView.icon.mas_right).offset(3);
- }];
-
-
- [self.promptView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.clockInButton.mas_bottom).offset(25);
- make.centerX.equalTo(self.bgView);
- // make.bottom.equalTo(self.bgView.mas_bottom).offset(-HJXVerticalScale(50));
- }];
- [self.promptView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.promptView.icon.mas_right).offset(6);
- }];
- }
- /* 打卡完成 */
- - (void)complete {
-
- [self.retryButton removeFromSuperview];
- [self.bgView addSubview:self.lineView];
- [self.bgView addSubview:self.wageView];
-
- //上班打卡完成
- self.goWorkStateView.icon.image = [UIImage imageNamed:@"clockIn_icon"];
- [self.goWorkStateView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.goWorkStateView.icon.mas_right).offset(3);
- }];
-
- //下班打卡完成
- self.afterWorkStateView.icon.image = [UIImage imageNamed:@"clockIn_icon"];
- [self.afterWorkStateView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.afterWorkStateView.icon.mas_right).offset(3);
- }];
-
-
- [self.promptView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.clockInButton.mas_bottom).offset(25);
- make.centerX.equalTo(self.bgView);
- // make.bottom.equalTo(self.bgView.mas_bottom).offset(-HJXVerticalScale(50));
- }];
- [self.promptView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.promptView.icon.mas_right).offset(6);
- }];
- // [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
- //
- // make.left.right.equalTo(self.bgView).offset(0);
- // make.top.equalTo(self.promptView.mas_bottom).offset(HJXVerticalScale(50));
- // make.height.mas_equalTo(1);
- // }];
- // [self.wageView mas_remakeConstraints:^(MASConstraintMaker *make) {
- //
- // make.left.equalTo(self.bgView.mas_left).offset(15);
- // make.right.equalTo(self.bgView.mas_right).offset(-15);
- // make.top.equalTo(self.lineView.mas_bottom).offset(HJXVerticalScale(30));
- // make.bottom.equalTo(self.bgView.mas_bottom).offset(-HJXVerticalScale(25));
- // }];
- }
- /* 超出范围 */
- - (void)outOfRange {
-
- [self.bgView addSubview:self.retryButton];
- [self.lineView removeFromSuperview];
- [self.wageView removeFromSuperview];
-
- [self.promptView mas_remakeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.clockInButton.mas_bottom).offset(25);
- make.centerX.equalTo(self.bgView);
- }];
-
- [self.promptView.textLabel mas_updateConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.promptView.icon.mas_right).offset(6);
- }];
-
- [self.retryButton mas_remakeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.promptView.mas_bottom).offset(40);
- make.centerX.equalTo(self.bgView);
- // make.bottom.equalTo(self.bgView.mas_bottom).offset(-HJVerticalScale(50));
- }];
- }
- #pragma mark - lazy
- - (UIView *)bgView {
-
- if (_bgView == nil)
- {
- _bgView = [[UIView alloc] init];
- _bgView.backgroundColor = [UIColor whiteColor];
- _bgView.layer.cornerRadius = 8;
- }
- return _bgView;
- }
- - (UIView *)goWorkView {
-
- if (_goWorkView == nil)
- {
- _goWorkView = [[UIView alloc] init];
- _goWorkView.backgroundColor = COLOR_F5F5F5;
- _goWorkView.layer.cornerRadius = 4;
- }
- return _goWorkView;
- }
- - (UILabel *)goWorkLabel {
-
- if (_goWorkLabel == nil)
- {
- _goWorkLabel = [[UILabel alloc] init];
- _goWorkLabel.textColor = COLOR_000000;
- _goWorkLabel.text = @"上班打卡";
- _goWorkLabel.font = [UIFont systemFontOfSize:14];
- }
- return _goWorkLabel;
- }
- - (HJClockInLabelImageView *)goWorkStateView {
-
- if (_goWorkStateView == nil)
- {
- _goWorkStateView = [[HJClockInLabelImageView alloc] init];
- _goWorkStateView.textLabel.text = @"未完成";
- _goWorkStateView.textLabel.textColor = COLOR_999999;
- _goWorkStateView.textLabel.font = [UIFont systemFontOfSize:13];
- }
- return _goWorkStateView;
- }
- - (UIView *)afterWorkView {
-
- if (_afterWorkView == nil)
- {
- _afterWorkView = [[UIView alloc] init];
- _afterWorkView.backgroundColor = COLOR_F5F5F5;
- _afterWorkView.layer.cornerRadius = 4;
- }
- return _afterWorkView;
- }
- - (UILabel *)afterWorkLabel {
-
- if (_afterWorkLabel == nil)
- {
- _afterWorkLabel = [[UILabel alloc] init];
- _afterWorkLabel.textColor = COLOR_000000;
- _afterWorkLabel.text = @"下班打卡";
- _afterWorkLabel.font = [UIFont systemFontOfSize:14];
- }
- return _afterWorkLabel;
- }
- - (HJClockInLabelImageView *)afterWorkStateView {
-
- if (_afterWorkStateView == nil)
- {
- _afterWorkStateView = [[HJClockInLabelImageView alloc] init];
- _afterWorkStateView.textLabel.text = @"未完成";
- _afterWorkStateView.textLabel.textColor = COLOR_999999;
- _afterWorkStateView.textLabel.font = [UIFont systemFontOfSize:13];
- }
- return _afterWorkStateView;
- }
- - (UILabel *)ruleLabel {
-
- if (_ruleLabel == nil)
- {
- _ruleLabel = [[UILabel alloc] init];
- _ruleLabel.text = @"请根据企业实际上下班时间打卡";
- _ruleLabel.font = [UIFont systemFontOfSize:12];
- _ruleLabel.textColor = COLOR_999999;
- }
- return _ruleLabel;
- }
- - (UIButton *)clockInButton {
-
- if (_clockInButton == nil)
- {
- _clockInButton = [UIButton buttonWithType:UIButtonTypeCustom];
- }
- return _clockInButton;
- }
- - (HJClockInLabelImageView *)promptView {
-
- if (_promptView == nil)
- {
- _promptView = [[HJClockInLabelImageView alloc] init];
- _promptView.textLabel.text = @"已进入考勤打卡范围";
- _promptView.textLabel.font = [UIFont systemFontOfSize:13];
- _promptView.icon.image = [UIImage imageNamed:@"clockIn_state_complete"];//clockIn_state_complete,clockIn_state_can
- }
- return _promptView;
- }
- - (UIButton *)retryButton {
-
- if (_retryButton == nil)
- {
- _retryButton = [UIButton buttonWithType:UIButtonTypeCustom];
- [_retryButton setTitle:@"重新定位" forState:UIControlStateNormal];
- [_retryButton setTitleColor:COLOR_0177FF forState:UIControlStateNormal];
- [_retryButton setImage:[UIImage imageNamed:@"retry_location"] forState:UIControlStateNormal];
- _retryButton.titleLabel.font = [UIFont boldSystemFontOfSize:13];
- [_retryButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
- }
- return _retryButton;
- }
- - (UIView *)lineView {
-
- if (_lineView == nil)
- {
- _lineView = [[UIView alloc] init];
- _lineView.backgroundColor = COLOR_EEEEEE;
- }
- return _lineView;
- }
- - (HJClockInStatisticWageView *)wageView {
-
- if (_wageView == nil)
- {
- _wageView = [[HJClockInStatisticWageView alloc] init];
- }
- return _wageView;
- }
- @end
|