






#import "BlackRateFarCell.h"
#import "YahooKeyTip.h"
#import "Masonry.h"
#import "UIImage+DidImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+Incorrect.h"

@interface BlackRateFarCell()


@property (nonatomic,strong) NSString * maxEggFullOut;


@property (nonatomic,strong) UIImageView * faxTenSameView;


@property (nonatomic,strong) UILabel * chainClampLabel;


@property (nonatomic,strong) UILabel * rainAlarmLabel;

@property (nonatomic, strong) UIButton * whoAreButton;

@end

@implementation BlackRateFarCell

- (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.faxTenSameView = [UIImageView new];
        self.faxTenSameView.tintColor = [YahooKeyTip expireCanColor];
        self.faxTenSameView.layer.cornerRadius = YahooKeyTip.tatarMaximum.airLayerWait;
        [self.contentView addSubview:self.faxTenSameView];
        [self.faxTenSameView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(YahooKeyTip.tatarMaximum.looperGreat);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(YahooKeyTip.tatarMaximum.activityBeat);
        }];
        
        self.chainClampLabel = [UILabel new];
        self.chainClampLabel.font = [UIFont boldSystemFontOfSize:YahooKeyTip.tatarMaximum.insertedHave];
        self.chainClampLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.chainClampLabel];
        
        self.rainAlarmLabel = [UILabel new];
        self.rainAlarmLabel.font = [UIFont boldSystemFontOfSize:YahooKeyTip.tatarMaximum.bridgePanBit];
        self.rainAlarmLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.rainAlarmLabel];
        
        [self.chainClampLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.faxTenSameView.mas_right).offset(YahooKeyTip.tatarMaximum.themeNapHard);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.rainAlarmLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.chainClampLabel);
            make.top.equalTo(self.chainClampLabel.mas_bottom).offset(YahooKeyTip.tatarMaximum.orderingSee);
        }];
        
        self.whoAreButton = [[UIButton alloc] init];
        _whoAreButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage badmintonScanLogWorkflowShadowName:YahooKeyTip.tatarMaximum.handoffClampingCollapsedEmailCharacter] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_whoAreButton setBackgroundImage:[UIImage badmintonScanLogWorkflowShadowName:YahooKeyTip.tatarMaximum.countUnsignedStatementExternTranslate] forState: UIControlStateNormal];
        [_whoAreButton setBackgroundImage:image forState: UIControlStateSelected];
        _whoAreButton.tintColor = [YahooKeyTip expireCanColor];
        [self.contentView addSubview:_whoAreButton];
        [_whoAreButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-YahooKeyTip.tatarMaximum.themeNapHard);
            make.size.mas_equalTo(CGSizeMake(YahooKeyTip.tatarMaximum.maxBusNative, YahooKeyTip.tatarMaximum.maxBusNative));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _whoAreButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [YahooKeyTip expireCanColor].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 = YahooKeyTip.tatarMaximum.looperGreat;
    frame.size.width -= YahooKeyTip.tatarMaximum.insertedHave;
    frame.origin.y += YahooKeyTip.tatarMaximum.looperGreat;
    frame.size.height -= YahooKeyTip.tatarMaximum.looperGreat;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setMaxEggFullOut:(NSString *)maxEggFullOut {
    _maxEggFullOut = maxEggFullOut;
    [self.faxTenSameView sd_setImageWithURL:[NSURL URLWithString:maxEggFullOut] placeholderImage:nil];
}

- (void)setWillNative:(MaySlowRelayOfferShuffleClick *)willNative {
    _willNative= willNative;
    self.maxEggFullOut = willNative.catStatic;
    self.chainClampLabel.text = willNative.handshake;
    NSString *note = willNative.hisLooper?:@"";
    if (note.chatBedPlace) {
        self.rainAlarmLabel.hidden = YES;
        [self.chainClampLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.faxTenSameView.mas_right).offset(YahooKeyTip.tatarMaximum.themeNapHard);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.rainAlarmLabel.hidden = NO;
        NSRange runYou = [note rangeOfString:YahooKeyTip.tatarMaximum.rotateHandleAutomaticAmbiguousSodiumPanel];
        NSRange sheGet = [note rangeOfString:YahooKeyTip.tatarMaximum.spanWayPopRefusedWrestlingGraceful];
        
        if (runYou.length == 0 && sheGet.length == 0) {
            self.rainAlarmLabel.text = note;
            self.rainAlarmLabel.font = [UIFont systemFontOfSize:YahooKeyTip.tatarMaximum.bridgePanBit];
            self.rainAlarmLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange treeWire = NSMakeRange(runYou.location+runYou.length, sheGet.location-(runYou.location+runYou.length));
            NSString *seeSee = [note substringWithRange:treeWire];
            NSString *stepOut = [note stringByReplacingOccurrencesOfString:YahooKeyTip.tatarMaximum.rotateHandleAutomaticAmbiguousSodiumPanel withString:@""];
            stepOut = [stepOut stringByReplacingOccurrencesOfString:YahooKeyTip.tatarMaximum.spanWayPopRefusedWrestlingGraceful withString:@""];
            
            treeWire = [stepOut rangeOfString:seeSee];
            NSMutableAttributedString *pinDanceLong = [[NSMutableAttributedString alloc] initWithString:stepOut];
            [pinDanceLong addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, stepOut.length)];
            [pinDanceLong addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, stepOut.length)];
            [pinDanceLong addAttribute:NSForegroundColorAttributeName value:[YahooKeyTip expireCanColor] range:treeWire];
            [pinDanceLong addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:treeWire];
            
            self.rainAlarmLabel.attributedText = pinDanceLong;
        }
        
        [self.chainClampLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.faxTenSameView.mas_right).offset(YahooKeyTip.tatarMaximum.themeNapHard);
            make.top.equalTo(self.faxTenSameView).offset(YahooKeyTip.tatarMaximum.tabTrapShot);
        }];
    }
}

@end
