






#import "ManualHisAgeCell.h"
#import "LambdaPatch.h"
#import "Masonry.h"
#import "UIImage+OneImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+Receiving.h"

@interface ManualHisAgeCell()


@property (nonatomic,strong) NSString * idiomAirborne;


@property (nonatomic,strong) UIImageView * sideOptPenView;


@property (nonatomic,strong) UILabel * endDueLinkLabel;


@property (nonatomic,strong) UILabel * subgroupsLabel;

@property (nonatomic, strong) UIButton * noticeButton;

@end

@implementation ManualHisAgeCell

- (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.sideOptPenView = [UIImageView new];
        self.sideOptPenView.tintColor = [LambdaPatch menstrualColor];
        self.sideOptPenView.layer.cornerRadius = LambdaPatch.faxChildBend.howStoryline;
        [self.contentView addSubview:self.sideOptPenView];
        [self.sideOptPenView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(LambdaPatch.faxChildBend.rowSawInfer);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(LambdaPatch.faxChildBend.golfDepthAsk);
        }];
        
        self.endDueLinkLabel = [UILabel new];
        self.endDueLinkLabel.font = [UIFont boldSystemFontOfSize:LambdaPatch.faxChildBend.underPopClip];
        self.endDueLinkLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.endDueLinkLabel];
        
        self.subgroupsLabel = [UILabel new];
        self.subgroupsLabel.font = [UIFont boldSystemFontOfSize:LambdaPatch.faxChildBend.weightAllMay];
        self.subgroupsLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.subgroupsLabel];
        
        [self.endDueLinkLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.sideOptPenView.mas_right).offset(LambdaPatch.faxChildBend.netDigestAre);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.subgroupsLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.endDueLinkLabel);
            make.top.equalTo(self.endDueLinkLabel.mas_bottom).offset(LambdaPatch.faxChildBend.rareCapLook);
        }];
        
        self.noticeButton = [[UIButton alloc] init];
        _noticeButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage campaignStaleItsTapProviderName:LambdaPatch.faxChildBend.discardedAppleMilesYouSafari] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_noticeButton setBackgroundImage:[UIImage campaignStaleItsTapProviderName:LambdaPatch.faxChildBend.returnWrappedStackNodeKilovolts] forState: UIControlStateNormal];
        [_noticeButton setBackgroundImage:image forState: UIControlStateSelected];
        _noticeButton.tintColor = [LambdaPatch menstrualColor];
        [self.contentView addSubview:_noticeButton];
        [_noticeButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-LambdaPatch.faxChildBend.netDigestAre);
            make.size.mas_equalTo(CGSizeMake(LambdaPatch.faxChildBend.lowWetKernel, LambdaPatch.faxChildBend.lowWetKernel));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _noticeButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [LambdaPatch menstrualColor].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 = LambdaPatch.faxChildBend.rowSawInfer;
    frame.size.width -= LambdaPatch.faxChildBend.underPopClip;
    frame.origin.y += LambdaPatch.faxChildBend.rowSawInfer;
    frame.size.height -= LambdaPatch.faxChildBend.rowSawInfer;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setIdiomAirborne:(NSString *)idiomAirborne {
    _idiomAirborne = idiomAirborne;
    [self.sideOptPenView sd_setImageWithURL:[NSURL URLWithString:idiomAirborne] placeholderImage:nil];
}

- (void)setStepsonTab:(ShowingHallMinderCombiningInvokeArrival *)stepsonTab {
    _stepsonTab= stepsonTab;
    self.idiomAirborne = stepsonTab.disabling;
    self.endDueLinkLabel.text = stepsonTab.rankFully;
    NSString *note = stepsonTab.busPreset?:@"";
    if (note.whoPopManual) {
        self.subgroupsLabel.hidden = YES;
        [self.endDueLinkLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.sideOptPenView.mas_right).offset(LambdaPatch.faxChildBend.netDigestAre);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.subgroupsLabel.hidden = NO;
        NSRange nearby = [note rangeOfString:LambdaPatch.faxChildBend.remainderQueueLogResponsesPolicyCause];
        NSRange hisTip = [note rangeOfString:LambdaPatch.faxChildBend.bitsOldContextMandarinBuildBlood];
        
        if (nearby.length == 0 && hisTip.length == 0) {
            self.subgroupsLabel.text = note;
            self.subgroupsLabel.font = [UIFont systemFontOfSize:LambdaPatch.faxChildBend.weightAllMay];
            self.subgroupsLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange angleDue = NSMakeRange(nearby.location+nearby.length, hisTip.location-(nearby.location+nearby.length));
            NSString *corner = [note substringWithRange:angleDue];
            NSString *cupIdle = [note stringByReplacingOccurrencesOfString:LambdaPatch.faxChildBend.remainderQueueLogResponsesPolicyCause withString:@""];
            cupIdle = [cupIdle stringByReplacingOccurrencesOfString:LambdaPatch.faxChildBend.bitsOldContextMandarinBuildBlood withString:@""];
            
            angleDue = [cupIdle rangeOfString:corner];
            NSMutableAttributedString *indoorListen = [[NSMutableAttributedString alloc] initWithString:cupIdle];
            [indoorListen addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, cupIdle.length)];
            [indoorListen addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, cupIdle.length)];
            [indoorListen addAttribute:NSForegroundColorAttributeName value:[LambdaPatch menstrualColor] range:angleDue];
            [indoorListen addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:angleDue];
            
            self.subgroupsLabel.attributedText = indoorListen;
        }
        
        [self.endDueLinkLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.sideOptPenView.mas_right).offset(LambdaPatch.faxChildBend.netDigestAre);
            make.top.equalTo(self.sideOptPenView).offset(LambdaPatch.faxChildBend.footUseMail);
        }];
    }
}

@end
