






#import "MenWasStrongCell.h"
#import "SafeTradEar.h"
#import "Masonry.h"
#import "UIImage+OffImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+MayRename.h"

@interface MenWasStrongCell()


@property (nonatomic,strong) NSString * writeInnerTip;


@property (nonatomic,strong) UIImageView * workNotDryView;


@property (nonatomic,strong) UILabel * tipDidMoodLabel;


@property (nonatomic,strong) UILabel * directionLabel;

@property (nonatomic, strong) UIButton * recordButton;

@end

@implementation MenWasStrongCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        self.clipsToBounds = YES;
        self.layer.cornerRadius = SafeTradEar.smallestMany.pongPongNap;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.workNotDryView = [UIImageView new];
        self.workNotDryView.tintColor = [SafeTradEar dueScreenColor];
        self.workNotDryView.layer.cornerRadius = SafeTradEar.smallestMany.tenSonStream;
        [self.contentView addSubview:self.workNotDryView];
        [self.workNotDryView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(SafeTradEar.smallestMany.tensionBody);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(SafeTradEar.smallestMany.eraCleanDeep);
        }];
        
        self.tipDidMoodLabel = [UILabel new];
        self.tipDidMoodLabel.font = [UIFont boldSystemFontOfSize:SafeTradEar.smallestMany.icyFormatHas];
        self.tipDidMoodLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.tipDidMoodLabel];
        
        self.directionLabel = [UILabel new];
        self.directionLabel.font = [UIFont boldSystemFontOfSize:SafeTradEar.smallestMany.chainEarlier];
        self.directionLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.directionLabel];
        
        [self.tipDidMoodLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.workNotDryView.mas_right).offset(SafeTradEar.smallestMany.gigabytesYet);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.directionLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.tipDidMoodLabel);
            make.top.equalTo(self.tipDidMoodLabel.mas_bottom).offset(SafeTradEar.smallestMany.eggDissolve);
        }];
        
        self.recordButton = [[UIButton alloc] init];
        _recordButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage acrossPlugMoleDetachCelticName:SafeTradEar.smallestMany.cellphoneDeleteLetterProximityCut] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_recordButton setBackgroundImage:[UIImage acrossPlugMoleDetachCelticName:SafeTradEar.smallestMany.swashesHeartEncodingZoneBin] forState: UIControlStateNormal];
        [_recordButton setBackgroundImage:image forState: UIControlStateSelected];
        _recordButton.tintColor = [SafeTradEar dueScreenColor];
        [self.contentView addSubview:_recordButton];
        [_recordButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-SafeTradEar.smallestMany.gigabytesYet);
            make.size.mas_equalTo(CGSizeMake(SafeTradEar.smallestMany.willBoundOdd, SafeTradEar.smallestMany.willBoundOdd));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _recordButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [SafeTradEar dueScreenColor].CGColor;
}

- (void)setFrame:(CGRect)frame {
    frame.origin.x = SafeTradEar.smallestMany.tensionBody;
    frame.size.width -= SafeTradEar.smallestMany.icyFormatHas;
    frame.origin.y += SafeTradEar.smallestMany.tensionBody;
    frame.size.height -= SafeTradEar.smallestMany.tensionBody;
    [super setFrame:frame];
}

-(void)setWriteInnerTip:(NSString *)writeInnerTip {
    _writeInnerTip = writeInnerTip;
    [self.workNotDryView sd_setImageWithURL:[NSURL URLWithString:writeInnerTip] placeholderImage:nil];
}

- (void)setProcessBus:(BelowUsabilityDatumNoteBuiltNet *)processBus {
    _processBus= processBus;
    self.writeInnerTip = processBus.accepting;
    self.tipDidMoodLabel.text = processBus.tapsPlace;
    NSString *note = processBus.exactness?:@"";
    if (note.followHelper) {
        self.directionLabel.hidden = YES;
        [self.tipDidMoodLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.workNotDryView.mas_right).offset(SafeTradEar.smallestMany.gigabytesYet);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.directionLabel.hidden = NO;
        NSRange ensure = [note rangeOfString:SafeTradEar.smallestMany.adapterMasterActualStickyChromaDiagnose];
        NSRange shrink = [note rangeOfString:SafeTradEar.smallestMany.backwardInventoryWateryBleedBoldfaceIgnore];
        
        if (ensure.length == 0 && shrink.length == 0) {
            self.directionLabel.text = note;
            self.directionLabel.font = [UIFont systemFontOfSize:SafeTradEar.smallestMany.chainEarlier];
            self.directionLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange lockHash = NSMakeRange(ensure.location+ensure.length, shrink.location-(ensure.location+ensure.length));
            NSString *oldUse = [note substringWithRange:lockHash];
            NSString *menLike = [note stringByReplacingOccurrencesOfString:SafeTradEar.smallestMany.adapterMasterActualStickyChromaDiagnose withString:@""];
            menLike = [menLike stringByReplacingOccurrencesOfString:SafeTradEar.smallestMany.backwardInventoryWateryBleedBoldfaceIgnore withString:@""];
            
            lockHash = [menLike rangeOfString:oldUse];
            NSMutableAttributedString *conflictGrow = [[NSMutableAttributedString alloc] initWithString:menLike];
            [conflictGrow addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, menLike.length)];
            [conflictGrow addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, menLike.length)];
            [conflictGrow addAttribute:NSForegroundColorAttributeName value:[SafeTradEar dueScreenColor] range:lockHash];
            [conflictGrow addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:lockHash];
            
            self.directionLabel.attributedText = conflictGrow;
        }
        
        [self.tipDidMoodLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.workNotDryView.mas_right).offset(SafeTradEar.smallestMany.gigabytesYet);
            make.top.equalTo(self.workNotDryView).offset(SafeTradEar.smallestMany.wakeManChar);
        }];
    }
}

@end
