






#import "LooseAndPoolCell.h"
#import "PrintFarFor.h"
#import "Masonry.h"
#import "UIImage+MinImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+Aggregate.h"

@interface LooseAndPoolCell()


@property (nonatomic,strong) NSString * broadcastCaps;


@property (nonatomic,strong) UIImageView * updateFreeView;


@property (nonatomic,strong) UILabel * bordersMapLabel;


@property (nonatomic,strong) UILabel * twoPrefixLabel;

@property (nonatomic, strong) UIButton * keySunButton;

@end

@implementation LooseAndPoolCell

- (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.updateFreeView = [UIImageView new];
        self.updateFreeView.tintColor = [PrintFarFor expansionColor];
        self.updateFreeView.layer.cornerRadius = PrintFarFor.guideMaySelf.expandingIts;
        [self.contentView addSubview:self.updateFreeView];
        [self.updateFreeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(PrintFarFor.guideMaySelf.splatButPen);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(PrintFarFor.guideMaySelf.secondWithin);
        }];
        
        self.bordersMapLabel = [UILabel new];
        self.bordersMapLabel.font = [UIFont boldSystemFontOfSize:PrintFarFor.guideMaySelf.numbersLight];
        self.bordersMapLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.bordersMapLabel];
        
        self.twoPrefixLabel = [UILabel new];
        self.twoPrefixLabel.font = [UIFont boldSystemFontOfSize:PrintFarFor.guideMaySelf.purpleBoxFix];
        self.twoPrefixLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.twoPrefixLabel];
        
        [self.bordersMapLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.updateFreeView.mas_right).offset(PrintFarFor.guideMaySelf.chatQuantize);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.twoPrefixLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.bordersMapLabel);
            make.top.equalTo(self.bordersMapLabel.mas_bottom).offset(PrintFarFor.guideMaySelf.areAirSplit);
        }];
        
        self.keySunButton = [[UIButton alloc] init];
        _keySunButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage lossyCurlRadialUnderlinePromotionName:PrintFarFor.guideMaySelf.wonAudiogramHyphensBuildManganese] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_keySunButton setBackgroundImage:[UIImage lossyCurlRadialUnderlinePromotionName:PrintFarFor.guideMaySelf.denseOriginalMouthPinchHidden] forState: UIControlStateNormal];
        [_keySunButton setBackgroundImage:image forState: UIControlStateSelected];
        _keySunButton.tintColor = [PrintFarFor expansionColor];
        [self.contentView addSubview:_keySunButton];
        [_keySunButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-PrintFarFor.guideMaySelf.chatQuantize);
            make.size.mas_equalTo(CGSizeMake(PrintFarFor.guideMaySelf.canSeparator, PrintFarFor.guideMaySelf.canSeparator));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _keySunButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [PrintFarFor expansionColor].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 = PrintFarFor.guideMaySelf.splatButPen;
    frame.size.width -= PrintFarFor.guideMaySelf.numbersLight;
    frame.origin.y += PrintFarFor.guideMaySelf.splatButPen;
    frame.size.height -= PrintFarFor.guideMaySelf.splatButPen;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setBroadcastCaps:(NSString *)broadcastCaps {
    _broadcastCaps = broadcastCaps;
    [self.updateFreeView sd_setImageWithURL:[NSURL URLWithString:broadcastCaps] placeholderImage:nil];
}

- (void)setRefusedSix:(SuperiorsNowAngularPullLighterOccur *)refusedSix {
    _refusedSix= refusedSix;
    self.broadcastCaps = refusedSix.magicNode;
    self.bordersMapLabel.text = refusedSix.trapBrown;
    NSString *note = refusedSix.catCosmic?:@"";
    if (note.bodyAfterBox) {
        self.twoPrefixLabel.hidden = YES;
        [self.bordersMapLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.updateFreeView.mas_right).offset(PrintFarFor.guideMaySelf.chatQuantize);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.twoPrefixLabel.hidden = NO;
        NSRange icyAnd = [note rangeOfString:PrintFarFor.guideMaySelf.speakOutAfterCarOriginPack];
        NSRange bedSob = [note rangeOfString:PrintFarFor.guideMaySelf.glyphHalftoneSuitableObsoleteChildSon];
        
        if (icyAnd.length == 0 && bedSob.length == 0) {
            self.twoPrefixLabel.text = note;
            self.twoPrefixLabel.font = [UIFont systemFontOfSize:PrintFarFor.guideMaySelf.purpleBoxFix];
            self.twoPrefixLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange inuitOff = NSMakeRange(icyAnd.location+icyAnd.length, bedSob.location-(icyAnd.location+icyAnd.length));
            NSString *catArt = [note substringWithRange:inuitOff];
            NSString *spaDown = [note stringByReplacingOccurrencesOfString:PrintFarFor.guideMaySelf.speakOutAfterCarOriginPack withString:@""];
            spaDown = [spaDown stringByReplacingOccurrencesOfString:PrintFarFor.guideMaySelf.glyphHalftoneSuitableObsoleteChildSon withString:@""];
            
            inuitOff = [spaDown rangeOfString:catArt];
            NSMutableAttributedString *lostShareWho = [[NSMutableAttributedString alloc] initWithString:spaDown];
            [lostShareWho addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, spaDown.length)];
            [lostShareWho addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, spaDown.length)];
            [lostShareWho addAttribute:NSForegroundColorAttributeName value:[PrintFarFor expansionColor] range:inuitOff];
            [lostShareWho addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:inuitOff];
            
            self.twoPrefixLabel.attributedText = lostShareWho;
        }
        
        [self.bordersMapLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.updateFreeView.mas_right).offset(PrintFarFor.guideMaySelf.chatQuantize);
            make.top.equalTo(self.updateFreeView).offset(PrintFarFor.guideMaySelf.touchSignal);
        }];
    }
}

@end
