






#import "ModeJobOwnerCell.h"
#import "NapEscaping.h"
#import "Masonry.h"
#import "UIImage+EyeImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+SeeSource.h"

@interface ModeJobOwnerCell()


@property (nonatomic,strong) NSString * darkenArbiter;


@property (nonatomic,strong) UIImageView * frameMergeView;


@property (nonatomic,strong) UILabel * sonUseHoldLabel;


@property (nonatomic,strong) UILabel * stakeGrayLabel;

@property (nonatomic, strong) UIButton * faxFunButton;

@end

@implementation ModeJobOwnerCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        self.clipsToBounds = YES;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = UIColor.clearColor;
        self.contentView.backgroundColor = UIColor.clearColor;
        
        self.frameMergeView = [UIImageView new];
        self.frameMergeView.tintColor = [NapEscaping feedBayerColor];
        self.frameMergeView.layer.cornerRadius = NapEscaping.restoringWay.recursiveOne;
        [self.contentView addSubview:self.frameMergeView];
        [self.frameMergeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(NapEscaping.restoringWay.dayCallTall);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(NapEscaping.restoringWay.flowHowCivil);
        }];
        
        self.sonUseHoldLabel = [UILabel new];
        self.sonUseHoldLabel.font = [UIFont boldSystemFontOfSize:NapEscaping.restoringWay.heavyStayDay];
        self.sonUseHoldLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.sonUseHoldLabel];
        
        self.stakeGrayLabel = [UILabel new];
        self.stakeGrayLabel.font = [UIFont boldSystemFontOfSize:NapEscaping.restoringWay.tabRaiseMark];
        self.stakeGrayLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.stakeGrayLabel];
        
        [self.sonUseHoldLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.frameMergeView.mas_right).offset(NapEscaping.restoringWay.putGradeHand);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.stakeGrayLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.sonUseHoldLabel);
            make.top.equalTo(self.sonUseHoldLabel.mas_bottom).offset(NapEscaping.restoringWay.hintBedLogo);
        }];
        
        self.faxFunButton = [[UIButton alloc] init];
        _faxFunButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage logSliceFaxBeginBodyName:NapEscaping.restoringWay.squaresPathGrayWonRequiring] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_faxFunButton setBackgroundImage:[UIImage logSliceFaxBeginBodyName:NapEscaping.restoringWay.condensedFlushAffineIcelandicJump] forState: UIControlStateNormal];
        [_faxFunButton setBackgroundImage:image forState: UIControlStateSelected];
        _faxFunButton.tintColor = [NapEscaping feedBayerColor];
        [self.contentView addSubview:_faxFunButton];
        [_faxFunButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-NapEscaping.restoringWay.putGradeHand);
            make.size.mas_equalTo(CGSizeMake(NapEscaping.restoringWay.penSphereEra, NapEscaping.restoringWay.penSphereEra));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _faxFunButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [NapEscaping feedBayerColor].CGColor;
    
    if (selected) {
        self.contentView.backgroundColor = [UIColor colorWithRed:1.0 green:0.98 blue:0.94 alpha:0.95];
    } else {
        self.contentView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.35];
    }
}

- (void)setFrame:(CGRect)frame {
    frame.origin.x = NapEscaping.restoringWay.dayCallTall;
    frame.size.width -= NapEscaping.restoringWay.heavyStayDay;
    frame.origin.y += NapEscaping.restoringWay.dayCallTall;
    frame.size.height -= NapEscaping.restoringWay.dayCallTall;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setDarkenArbiter:(NSString *)darkenArbiter {
    _darkenArbiter = darkenArbiter;
    [self.frameMergeView sd_setImageWithURL:[NSURL URLWithString:darkenArbiter] placeholderImage:nil];
}

- (void)setMaxFunYard:(PrivilegeWakeRecursiveFrameConnectAssign *)maxFunYard {
    _maxFunYard= maxFunYard;
    self.darkenArbiter = maxFunYard.clientLog;
    self.sonUseHoldLabel.text = maxFunYard.kitPascal;
    NSString *note = maxFunYard.bottomTag?:@"";
    if (note.slabMountTen) {
        self.stakeGrayLabel.hidden = YES;
        [self.sonUseHoldLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.frameMergeView.mas_right).offset(NapEscaping.restoringWay.putGradeHand);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.stakeGrayLabel.hidden = NO;
        NSRange sunHit = [note rangeOfString:NapEscaping.restoringWay.primariesYellowHighFaxHierarchyRoll];
        NSRange unwind = [note rangeOfString:NapEscaping.restoringWay.colleagueLearnedTriggeredBetterBendPink];
        
        if (sunHit.length == 0 && unwind.length == 0) {
            self.stakeGrayLabel.text = note;
            self.stakeGrayLabel.font = [UIFont systemFontOfSize:NapEscaping.restoringWay.tabRaiseMark];
            self.stakeGrayLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange tipParse = NSMakeRange(sunHit.location+sunHit.length, unwind.location-(sunHit.location+sunHit.length));
            NSString *useRet = [note substringWithRange:tipParse];
            NSString *elastic = [note stringByReplacingOccurrencesOfString:NapEscaping.restoringWay.primariesYellowHighFaxHierarchyRoll withString:@""];
            elastic = [elastic stringByReplacingOccurrencesOfString:NapEscaping.restoringWay.colleagueLearnedTriggeredBetterBendPink withString:@""];
            
            tipParse = [elastic rangeOfString:useRet];
            NSMutableAttributedString *headCurrency = [[NSMutableAttributedString alloc] initWithString:elastic];
            [headCurrency addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, elastic.length)];
            [headCurrency addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, elastic.length)];
            [headCurrency addAttribute:NSForegroundColorAttributeName value:[NapEscaping feedBayerColor] range:tipParse];
            [headCurrency addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:tipParse];
            
            self.stakeGrayLabel.attributedText = headCurrency;
        }
        
        [self.sonUseHoldLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.frameMergeView.mas_right).offset(NapEscaping.restoringWay.putGradeHand);
            make.top.equalTo(self.frameMergeView).offset(NapEscaping.restoringWay.drawPeerAnd);
        }];
    }
}

@end
