






#import "IndentSchoolCell.h"
#import "ReloadThird.h"
#import "Masonry.h"
#import "UIImage+HasImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+ClearLift.h"

@interface IndentSchoolCell()


@property (nonatomic,strong) NSString * hisRootCatNap;


@property (nonatomic,strong) UIImageView * tooDeliverView;


@property (nonatomic,strong) UILabel * oddYouPoolLabel;


@property (nonatomic,strong) UILabel * exposuresLabel;

@property (nonatomic, strong) UIButton * barAskButton;

@end

@implementation IndentSchoolCell

- (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.tooDeliverView = [UIImageView new];
        self.tooDeliverView.tintColor = [ReloadThird fairBlockColor];
        self.tooDeliverView.layer.cornerRadius = ReloadThird.overlapQuote.veryFixPlace;
        [self.contentView addSubview:self.tooDeliverView];
        [self.tooDeliverView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(ReloadThird.overlapQuote.vortexStair);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(ReloadThird.overlapQuote.zipJoinAngle);
        }];
        
        self.oddYouPoolLabel = [UILabel new];
        self.oddYouPoolLabel.font = [UIFont boldSystemFontOfSize:ReloadThird.overlapQuote.capBarsTotal];
        self.oddYouPoolLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.oddYouPoolLabel];
        
        self.exposuresLabel = [UILabel new];
        self.exposuresLabel.font = [UIFont boldSystemFontOfSize:ReloadThird.overlapQuote.pascalPartly];
        self.exposuresLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.exposuresLabel];
        
        [self.oddYouPoolLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.tooDeliverView.mas_right).offset(ReloadThird.overlapQuote.smallestChat);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.exposuresLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.oddYouPoolLabel);
            make.top.equalTo(self.oddYouPoolLabel.mas_bottom).offset(ReloadThird.overlapQuote.ropeClicked);
        }];
        
        self.barAskButton = [[UIButton alloc] init];
        _barAskButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage removeFadeMaxEngravedDivideName:ReloadThird.overlapQuote.seeTicketsWorkspaceSheStand] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_barAskButton setBackgroundImage:[UIImage removeFadeMaxEngravedDivideName:ReloadThird.overlapQuote.scannedHailRemovableSegmentsAlive] forState: UIControlStateNormal];
        [_barAskButton setBackgroundImage:image forState: UIControlStateSelected];
        _barAskButton.tintColor = [ReloadThird fairBlockColor];
        [self.contentView addSubview:_barAskButton];
        [_barAskButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-ReloadThird.overlapQuote.smallestChat);
            make.size.mas_equalTo(CGSizeMake(ReloadThird.overlapQuote.anotherDelta, ReloadThird.overlapQuote.anotherDelta));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _barAskButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [ReloadThird fairBlockColor].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 = ReloadThird.overlapQuote.vortexStair;
    frame.size.width -= ReloadThird.overlapQuote.capBarsTotal;
    frame.origin.y += ReloadThird.overlapQuote.vortexStair;
    frame.size.height -= ReloadThird.overlapQuote.vortexStair;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setHisRootCatNap:(NSString *)hisRootCatNap {
    _hisRootCatNap = hisRootCatNap;
    [self.tooDeliverView sd_setImageWithURL:[NSURL URLWithString:hisRootCatNap] placeholderImage:nil];
}

- (void)setInhalerDay:(LayerOriginalDryCoverMegahertzFoot *)inhalerDay {
    _inhalerDay= inhalerDay;
    self.hisRootCatNap = inhalerDay.menSpeech;
    self.oddYouPoolLabel.text = inhalerDay.encodeMap;
    NSString *note = inhalerDay.forbidOut?:@"";
    if (note.inheritedHit) {
        self.exposuresLabel.hidden = YES;
        [self.oddYouPoolLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.tooDeliverView.mas_right).offset(ReloadThird.overlapQuote.smallestChat);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.exposuresLabel.hidden = NO;
        NSRange spouse = [note rangeOfString:ReloadThird.overlapQuote.backAffinityMessagingLoopCarLaunch];
        NSRange unable = [note rangeOfString:ReloadThird.overlapQuote.hexPressGenericsCommentInstallPrice];
        
        if (spouse.length == 0 && unable.length == 0) {
            self.exposuresLabel.text = note;
            self.exposuresLabel.font = [UIFont systemFontOfSize:ReloadThird.overlapQuote.pascalPartly];
            self.exposuresLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange unifySay = NSMakeRange(spouse.location+spouse.length, unable.location-(spouse.location+spouse.length));
            NSString *panTip = [note substringWithRange:unifySay];
            NSString *fileMay = [note stringByReplacingOccurrencesOfString:ReloadThird.overlapQuote.backAffinityMessagingLoopCarLaunch withString:@""];
            fileMay = [fileMay stringByReplacingOccurrencesOfString:ReloadThird.overlapQuote.hexPressGenericsCommentInstallPrice withString:@""];
            
            unifySay = [fileMay rangeOfString:panTip];
            NSMutableAttributedString *anyModifyLog = [[NSMutableAttributedString alloc] initWithString:fileMay];
            [anyModifyLog addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, fileMay.length)];
            [anyModifyLog addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, fileMay.length)];
            [anyModifyLog addAttribute:NSForegroundColorAttributeName value:[ReloadThird fairBlockColor] range:unifySay];
            [anyModifyLog addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:unifySay];
            
            self.exposuresLabel.attributedText = anyModifyLog;
        }
        
        [self.oddYouPoolLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.tooDeliverView.mas_right).offset(ReloadThird.overlapQuote.smallestChat);
            make.top.equalTo(self.tooDeliverView).offset(ReloadThird.overlapQuote.cupWinSmall);
        }];
    }
}

@end
