






#import "BasqueIllFarCell.h"
#import "RuleListCut.h"
#import "Masonry.h"
#import "UIImage+HasImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+Anonymous.h"

@interface BasqueIllFarCell()


@property (nonatomic,strong) NSString * ironSpaceBike;


@property (nonatomic,strong) UIImageView * lowerDutchView;


@property (nonatomic,strong) UILabel * alcoholKeyLabel;


@property (nonatomic,strong) UILabel * thousandsLabel;

@property (nonatomic, strong) UIButton * pencilButton;

@end

@implementation BasqueIllFarCell

- (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.lowerDutchView = [UIImageView new];
        self.lowerDutchView.tintColor = [RuleListCut slopeLockColor];
        self.lowerDutchView.layer.cornerRadius = RuleListCut.coloredDraft.youSideScene;
        [self.contentView addSubview:self.lowerDutchView];
        [self.lowerDutchView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(RuleListCut.coloredDraft.asleepScene);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(RuleListCut.coloredDraft.workDispatch);
        }];
        
        self.alcoholKeyLabel = [UILabel new];
        self.alcoholKeyLabel.font = [UIFont boldSystemFontOfSize:RuleListCut.coloredDraft.hardAddExist];
        self.alcoholKeyLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.alcoholKeyLabel];
        
        self.thousandsLabel = [UILabel new];
        self.thousandsLabel.font = [UIFont boldSystemFontOfSize:RuleListCut.coloredDraft.yardJobShift];
        self.thousandsLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.thousandsLabel];
        
        [self.alcoholKeyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lowerDutchView.mas_right).offset(RuleListCut.coloredDraft.redPeriodIll);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.thousandsLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.alcoholKeyLabel);
            make.top.equalTo(self.alcoholKeyLabel.mas_bottom).offset(RuleListCut.coloredDraft.curveRunWax);
        }];
        
        self.pencilButton = [[UIButton alloc] init];
        _pencilButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage infoBusFilterVariationTurnName:RuleListCut.coloredDraft.pagerRecentlyEncipherTicketsMax] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_pencilButton setBackgroundImage:[UIImage infoBusFilterVariationTurnName:RuleListCut.coloredDraft.interVersionReplaceInstantNotation] forState: UIControlStateNormal];
        [_pencilButton setBackgroundImage:image forState: UIControlStateSelected];
        _pencilButton.tintColor = [RuleListCut slopeLockColor];
        [self.contentView addSubview:_pencilButton];
        [_pencilButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-RuleListCut.coloredDraft.redPeriodIll);
            make.size.mas_equalTo(CGSizeMake(RuleListCut.coloredDraft.mustInuitBut, RuleListCut.coloredDraft.mustInuitBut));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _pencilButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [RuleListCut slopeLockColor].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 = RuleListCut.coloredDraft.asleepScene;
    frame.size.width -= RuleListCut.coloredDraft.hardAddExist;
    frame.origin.y += RuleListCut.coloredDraft.asleepScene;
    frame.size.height -= RuleListCut.coloredDraft.asleepScene;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setIronSpaceBike:(NSString *)ironSpaceBike {
    _ironSpaceBike = ironSpaceBike;
    [self.lowerDutchView sd_setImageWithURL:[NSURL URLWithString:ironSpaceBike] placeholderImage:nil];
}

- (void)setBaseSlovak:(TargetWriteHitNativeOwnershipMacintosh *)baseSlovak {
    _baseSlovak= baseSlovak;
    self.ironSpaceBike = baseSlovak.thumbFlow;
    self.alcoholKeyLabel.text = baseSlovak.gaspYahoo;
    NSString *note = baseSlovak.slideSign?:@"";
    if (note.faceBitChina) {
        self.thousandsLabel.hidden = YES;
        [self.alcoholKeyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lowerDutchView.mas_right).offset(RuleListCut.coloredDraft.redPeriodIll);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.thousandsLabel.hidden = NO;
        NSRange online = [note rangeOfString:RuleListCut.coloredDraft.bundleTranslateCinematicToolProposalEvery];
        NSRange dayOne = [note rangeOfString:RuleListCut.coloredDraft.yearsThreadedFriendZoomHasPhotos];
        
        if (online.length == 0 && dayOne.length == 0) {
            self.thousandsLabel.text = note;
            self.thousandsLabel.font = [UIFont systemFontOfSize:RuleListCut.coloredDraft.yardJobShift];
            self.thousandsLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange pieceGet = NSMakeRange(online.location+online.length, dayOne.location-(online.location+online.length));
            NSString *subCup = [note substringWithRange:pieceGet];
            NSString *showing = [note stringByReplacingOccurrencesOfString:RuleListCut.coloredDraft.bundleTranslateCinematicToolProposalEvery withString:@""];
            showing = [showing stringByReplacingOccurrencesOfString:RuleListCut.coloredDraft.yearsThreadedFriendZoomHasPhotos withString:@""];
            
            pieceGet = [showing rangeOfString:subCup];
            NSMutableAttributedString *undefinedRun = [[NSMutableAttributedString alloc] initWithString:showing];
            [undefinedRun addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, showing.length)];
            [undefinedRun addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, showing.length)];
            [undefinedRun addAttribute:NSForegroundColorAttributeName value:[RuleListCut slopeLockColor] range:pieceGet];
            [undefinedRun addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:pieceGet];
            
            self.thousandsLabel.attributedText = undefinedRun;
        }
        
        [self.alcoholKeyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lowerDutchView.mas_right).offset(RuleListCut.coloredDraft.redPeriodIll);
            make.top.equalTo(self.lowerDutchView).offset(RuleListCut.coloredDraft.runStoodIll);
        }];
    }
}

@end
