






#import "YardInternalCell.h"
#import "WinNeedHang.h"
#import "Masonry.h"
#import "UIImage+EggImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+TalkBound.h"

@interface YardInternalCell()


@property (nonatomic,strong) NSString * deciliterLink;


@property (nonatomic,strong) UIImageView * eraTwitterView;


@property (nonatomic,strong) UILabel * cursorRingLabel;


@property (nonatomic,strong) UILabel * spaCancelLabel;

@property (nonatomic, strong) UIButton * intentButton;

@end

@implementation YardInternalCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        self.clipsToBounds = YES;
        self.layer.cornerRadius = WinNeedHang.chargePenSin.butCropFoot;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.eraTwitterView = [UIImageView new];
        self.eraTwitterView.tintColor = [WinNeedHang suspendedColor];
        self.eraTwitterView.layer.cornerRadius = WinNeedHang.chargePenSin.tooCousinPin;
        [self.contentView addSubview:self.eraTwitterView];
        [self.eraTwitterView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(WinNeedHang.chargePenSin.useMayPrime);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(WinNeedHang.chargePenSin.occlusionYou);
        }];
        
        self.cursorRingLabel = [UILabel new];
        self.cursorRingLabel.font = [UIFont boldSystemFontOfSize:WinNeedHang.chargePenSin.youHeightSub];
        self.cursorRingLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.cursorRingLabel];
        
        self.spaCancelLabel = [UILabel new];
        self.spaCancelLabel.font = [UIFont boldSystemFontOfSize:WinNeedHang.chargePenSin.iconNetThick];
        self.spaCancelLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.spaCancelLabel];
        
        [self.cursorRingLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.eraTwitterView.mas_right).offset(WinNeedHang.chargePenSin.littleTabAre);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.spaCancelLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.cursorRingLabel);
            make.top.equalTo(self.cursorRingLabel.mas_bottom).offset(WinNeedHang.chargePenSin.ageAttitude);
        }];
        
        self.intentButton = [[UIButton alloc] init];
        _intentButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage rearrangeKeepCutterAbsentBalancedName:WinNeedHang.chargePenSin.popTheDateKeyboardMile] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_intentButton setBackgroundImage:[UIImage rearrangeKeepCutterAbsentBalancedName:WinNeedHang.chargePenSin.blobSongAddBouncingHertz] forState: UIControlStateNormal];
        [_intentButton setBackgroundImage:image forState: UIControlStateSelected];
        _intentButton.tintColor = [WinNeedHang suspendedColor];
        [self.contentView addSubview:_intentButton];
        [_intentButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-WinNeedHang.chargePenSin.littleTabAre);
            make.size.mas_equalTo(CGSizeMake(WinNeedHang.chargePenSin.visitRestBit, WinNeedHang.chargePenSin.visitRestBit));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _intentButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [WinNeedHang suspendedColor].CGColor;
}

- (void)setFrame:(CGRect)frame {
    frame.origin.x = WinNeedHang.chargePenSin.useMayPrime;
    frame.size.width -= WinNeedHang.chargePenSin.youHeightSub;
    frame.origin.y += WinNeedHang.chargePenSin.useMayPrime;
    frame.size.height -= WinNeedHang.chargePenSin.useMayPrime;
    [super setFrame:frame];
}

-(void)setDeciliterLink:(NSString *)deciliterLink {
    _deciliterLink = deciliterLink;
    [self.eraTwitterView sd_setImageWithURL:[NSURL URLWithString:deciliterLink] placeholderImage:nil];
}

- (void)setMaxKeyDeep:(RectifiedDeletionDetectedDecodingAnimatedCubic *)maxKeyDeep {
    _maxKeyDeep= maxKeyDeep;
    self.deciliterLink = maxKeyDeep.twistRead;
    self.cursorRingLabel.text = maxKeyDeep.andPortal;
    NSString *note = maxKeyDeep.unwinding?:@"";
    if (note.consumesCase) {
        self.spaCancelLabel.hidden = YES;
        [self.cursorRingLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.eraTwitterView.mas_right).offset(WinNeedHang.chargePenSin.littleTabAre);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.spaCancelLabel.hidden = NO;
        NSRange rawRaw = [note rangeOfString:WinNeedHang.chargePenSin.syntaxSevenPopAtomCyclingMax];
        NSRange napPub = [note rangeOfString:WinNeedHang.chargePenSin.contactsExpandedKernelsHasExportingCamera];
        
        if (rawRaw.length == 0 && napPub.length == 0) {
            self.spaCancelLabel.text = note;
            self.spaCancelLabel.font = [UIFont systemFontOfSize:WinNeedHang.chargePenSin.iconNetThick];
            self.spaCancelLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange sleetNap = NSMakeRange(rawRaw.location+rawRaw.length, napPub.location-(rawRaw.location+rawRaw.length));
            NSString *faxWon = [note substringWithRange:sleetNap];
            NSString *mixFair = [note stringByReplacingOccurrencesOfString:WinNeedHang.chargePenSin.syntaxSevenPopAtomCyclingMax withString:@""];
            mixFair = [mixFair stringByReplacingOccurrencesOfString:WinNeedHang.chargePenSin.contactsExpandedKernelsHasExportingCamera withString:@""];
            
            sleetNap = [mixFair rangeOfString:faxWon];
            NSMutableAttributedString *netHeartDeny = [[NSMutableAttributedString alloc] initWithString:mixFair];
            [netHeartDeny addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, mixFair.length)];
            [netHeartDeny addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, mixFair.length)];
            [netHeartDeny addAttribute:NSForegroundColorAttributeName value:[WinNeedHang suspendedColor] range:sleetNap];
            [netHeartDeny addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:sleetNap];
            
            self.spaCancelLabel.attributedText = netHeartDeny;
        }
        
        [self.cursorRingLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.eraTwitterView.mas_right).offset(WinNeedHang.chargePenSin.littleTabAre);
            make.top.equalTo(self.eraTwitterView).offset(WinNeedHang.chargePenSin.dashGetSwap);
        }];
    }
}

@end
