






#import "RepeatPubWhoCell.h"
#import "RedFlexible.h"
#import "Masonry.h"
#import "UIImage+DryImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+AffineDog.h"

@interface RepeatPubWhoCell()


@property (nonatomic,strong) NSString * brushYearsWay;


@property (nonatomic,strong) UIImageView * airAudibleView;


@property (nonatomic,strong) UILabel * viewCopperLabel;


@property (nonatomic,strong) UILabel * bufferingLabel;

@property (nonatomic, strong) UIButton * sexHasButton;

@end

@implementation RepeatPubWhoCell

- (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.airAudibleView = [UIImageView new];
        self.airAudibleView.tintColor = [RedFlexible northTextColor];
        self.airAudibleView.layer.cornerRadius = RedFlexible.capContinued.sparseYouNap;
        [self.contentView addSubview:self.airAudibleView];
        [self.airAudibleView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(RedFlexible.capContinued.composeDone);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(RedFlexible.capContinued.rowDescended);
        }];
        
        self.viewCopperLabel = [UILabel new];
        self.viewCopperLabel.font = [UIFont boldSystemFontOfSize:RedFlexible.capContinued.dryCellParse];
        self.viewCopperLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.viewCopperLabel];
        
        self.bufferingLabel = [UILabel new];
        self.bufferingLabel.font = [UIFont boldSystemFontOfSize:RedFlexible.capContinued.vitalAndSeed];
        self.bufferingLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.bufferingLabel];
        
        [self.viewCopperLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.airAudibleView.mas_right).offset(RedFlexible.capContinued.rowDeleteMan);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.bufferingLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.viewCopperLabel);
            make.top.equalTo(self.viewCopperLabel.mas_bottom).offset(RedFlexible.capContinued.midSuitable);
        }];
        
        self.sexHasButton = [[UIButton alloc] init];
        _sexHasButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage detectedSeeExpectsSamplingEndsName:RedFlexible.capContinued.sayProvidingFlowMenDepending] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_sexHasButton setBackgroundImage:[UIImage detectedSeeExpectsSamplingEndsName:RedFlexible.capContinued.notationCameraVarianceBitHigher] forState: UIControlStateNormal];
        [_sexHasButton setBackgroundImage:image forState: UIControlStateSelected];
        _sexHasButton.tintColor = [RedFlexible northTextColor];
        [self.contentView addSubview:_sexHasButton];
        [_sexHasButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-RedFlexible.capContinued.rowDeleteMan);
            make.size.mas_equalTo(CGSizeMake(RedFlexible.capContinued.farExactness, RedFlexible.capContinued.farExactness));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _sexHasButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [RedFlexible northTextColor].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 = RedFlexible.capContinued.composeDone;
    frame.size.width -= RedFlexible.capContinued.dryCellParse;
    frame.origin.y += RedFlexible.capContinued.composeDone;
    frame.size.height -= RedFlexible.capContinued.composeDone;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setBrushYearsWay:(NSString *)brushYearsWay {
    _brushYearsWay = brushYearsWay;
    [self.airAudibleView sd_setImageWithURL:[NSURL URLWithString:brushYearsWay] placeholderImage:nil];
}

- (void)setNeedNapHow:(LexicalJobBlindingHasPicturesSalt *)needNapHow {
    _needNapHow= needNapHow;
    self.brushYearsWay = needNapHow.separated;
    self.viewCopperLabel.text = needNapHow.icyBypass;
    NSString *note = needNapHow.ownership?:@"";
    if (note.positionRain) {
        self.bufferingLabel.hidden = YES;
        [self.viewCopperLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.airAudibleView.mas_right).offset(RedFlexible.capContinued.rowDeleteMan);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.bufferingLabel.hidden = NO;
        NSRange strict = [note rangeOfString:RedFlexible.capContinued.pointerAreRecordRomanHostingFocused];
        NSRange dublin = [note rangeOfString:RedFlexible.capContinued.signerDogAdjustPictureMinderCompleted];
        
        if (strict.length == 0 && dublin.length == 0) {
            self.bufferingLabel.text = note;
            self.bufferingLabel.font = [UIFont systemFontOfSize:RedFlexible.capContinued.vitalAndSeed];
            self.bufferingLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange speakers = NSMakeRange(strict.location+strict.length, dublin.location-(strict.location+strict.length));
            NSString *areMid = [note substringWithRange:speakers];
            NSString *centers = [note stringByReplacingOccurrencesOfString:RedFlexible.capContinued.pointerAreRecordRomanHostingFocused withString:@""];
            centers = [centers stringByReplacingOccurrencesOfString:RedFlexible.capContinued.signerDogAdjustPictureMinderCompleted withString:@""];
            
            speakers = [centers rangeOfString:areMid];
            NSMutableAttributedString *metalSexPint = [[NSMutableAttributedString alloc] initWithString:centers];
            [metalSexPint addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, centers.length)];
            [metalSexPint addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, centers.length)];
            [metalSexPint addAttribute:NSForegroundColorAttributeName value:[RedFlexible northTextColor] range:speakers];
            [metalSexPint addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:speakers];
            
            self.bufferingLabel.attributedText = metalSexPint;
        }
        
        [self.viewCopperLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.airAudibleView.mas_right).offset(RedFlexible.capContinued.rowDeleteMan);
            make.top.equalTo(self.airAudibleView).offset(RedFlexible.capContinued.submitPrint);
        }];
    }
}

@end
