






#import "SixGetActualCell.h"
#import "LearnWeekly.h"
#import "Masonry.h"
#import "UIImage+EarImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+YearSetup.h"

@interface SixGetActualCell()


@property (nonatomic,strong) NSString * stoodThatFind;


@property (nonatomic,strong) UIImageView * mealGallonView;


@property (nonatomic,strong) UILabel * outSchemesLabel;


@property (nonatomic,strong) UILabel * recordingLabel;

@property (nonatomic, strong) UIButton * winSayButton;

@end

@implementation SixGetActualCell

- (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.mealGallonView = [UIImageView new];
        self.mealGallonView.tintColor = [LearnWeekly youBorderColor];
        self.mealGallonView.layer.cornerRadius = LearnWeekly.reuseRenewal.performerTwo;
        [self.contentView addSubview:self.mealGallonView];
        [self.mealGallonView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(LearnWeekly.reuseRenewal.burstVolume);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(LearnWeekly.reuseRenewal.areShortcuts);
        }];
        
        self.outSchemesLabel = [UILabel new];
        self.outSchemesLabel.font = [UIFont boldSystemFontOfSize:LearnWeekly.reuseRenewal.workBriefThe];
        self.outSchemesLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.outSchemesLabel];
        
        self.recordingLabel = [UILabel new];
        self.recordingLabel.font = [UIFont boldSystemFontOfSize:LearnWeekly.reuseRenewal.lastYouShare];
        self.recordingLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.recordingLabel];
        
        [self.outSchemesLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mealGallonView.mas_right).offset(LearnWeekly.reuseRenewal.withinWayUse);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.recordingLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.outSchemesLabel);
            make.top.equalTo(self.outSchemesLabel.mas_bottom).offset(LearnWeekly.reuseRenewal.cyclingZone);
        }];
        
        self.winSayButton = [[UIButton alloc] init];
        _winSayButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage resourcesFunAskHandoffSaltName:LearnWeekly.reuseRenewal.putConnectedSquashSoundArts] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_winSayButton setBackgroundImage:[UIImage resourcesFunAskHandoffSaltName:LearnWeekly.reuseRenewal.hasHerDownhillExpensiveType] forState: UIControlStateNormal];
        [_winSayButton setBackgroundImage:image forState: UIControlStateSelected];
        _winSayButton.tintColor = [LearnWeekly youBorderColor];
        [self.contentView addSubview:_winSayButton];
        [_winSayButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-LearnWeekly.reuseRenewal.withinWayUse);
            make.size.mas_equalTo(CGSizeMake(LearnWeekly.reuseRenewal.glyphHasTalk, LearnWeekly.reuseRenewal.glyphHasTalk));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _winSayButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [LearnWeekly youBorderColor].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 = LearnWeekly.reuseRenewal.burstVolume;
    frame.size.width -= LearnWeekly.reuseRenewal.workBriefThe;
    frame.origin.y += LearnWeekly.reuseRenewal.burstVolume;
    frame.size.height -= LearnWeekly.reuseRenewal.burstVolume;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setStoodThatFind:(NSString *)stoodThatFind {
    _stoodThatFind = stoodThatFind;
    [self.mealGallonView sd_setImageWithURL:[NSURL URLWithString:stoodThatFind] placeholderImage:nil];
}

- (void)setHisTagStep:(AssistiveMediumBarTornadoPositiveAirline *)hisTagStep {
    _hisTagStep= hisTagStep;
    self.stoodThatFind = hisTagStep.gradeBase;
    self.outSchemesLabel.text = hisTagStep.searchTab;
    NSString *note = hisTagStep.cupParent?:@"";
    if (note.mustDefaults) {
        self.recordingLabel.hidden = YES;
        [self.outSchemesLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mealGallonView.mas_right).offset(LearnWeekly.reuseRenewal.withinWayUse);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.recordingLabel.hidden = NO;
        NSRange fixKey = [note rangeOfString:LearnWeekly.reuseRenewal.unlockCommitSecurityAgeStableBlue];
        NSRange andTag = [note rangeOfString:LearnWeekly.reuseRenewal.producerFemaleTeamFoldStoneContents];
        
        if (fixKey.length == 0 && andTag.length == 0) {
            self.recordingLabel.text = note;
            self.recordingLabel.font = [UIFont systemFontOfSize:LearnWeekly.reuseRenewal.lastYouShare];
            self.recordingLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange earDelta = NSMakeRange(fixKey.location+fixKey.length, andTag.location-(fixKey.location+fixKey.length));
            NSString *ourPan = [note substringWithRange:earDelta];
            NSString *weekMen = [note stringByReplacingOccurrencesOfString:LearnWeekly.reuseRenewal.unlockCommitSecurityAgeStableBlue withString:@""];
            weekMen = [weekMen stringByReplacingOccurrencesOfString:LearnWeekly.reuseRenewal.producerFemaleTeamFoldStoneContents withString:@""];
            
            earDelta = [weekMen rangeOfString:ourPan];
            NSMutableAttributedString *subContinued = [[NSMutableAttributedString alloc] initWithString:weekMen];
            [subContinued addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, weekMen.length)];
            [subContinued addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, weekMen.length)];
            [subContinued addAttribute:NSForegroundColorAttributeName value:[LearnWeekly youBorderColor] range:earDelta];
            [subContinued addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:earDelta];
            
            self.recordingLabel.attributedText = subContinued;
        }
        
        [self.outSchemesLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mealGallonView.mas_right).offset(LearnWeekly.reuseRenewal.withinWayUse);
            make.top.equalTo(self.mealGallonView).offset(LearnWeekly.reuseRenewal.hostPrivacy);
        }];
    }
}

@end
