






#import "PutCathedralCell.h"
#import "BurstPetite.h"
#import "Masonry.h"
#import "UIImage+EggImage.h"
#import "UIImageView+WebCache.h"
#import "NSString+ReloadPan.h"

@interface PutCathedralCell()


@property (nonatomic,strong) NSString * invertAmharic;


@property (nonatomic,strong) UIImageView * policyLeadView;


@property (nonatomic,strong) UILabel * sentDayKeyLabel;


@property (nonatomic,strong) UILabel * pressGrayLabel;

@property (nonatomic, strong) UIButton * tabSixButton;

@end

@implementation PutCathedralCell

- (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.policyLeadView = [UIImageView new];
        self.policyLeadView.tintColor = [BurstPetite finalTurnColor];
        self.policyLeadView.layer.cornerRadius = BurstPetite.virtualSheet.airAuthority;
        [self.contentView addSubview:self.policyLeadView];
        [self.policyLeadView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(BurstPetite.virtualSheet.partGeneral);
            make.centerY.mas_equalTo(self.contentView);
            make.width.height.mas_equalTo(BurstPetite.virtualSheet.answerCommit);
        }];
        
        self.sentDayKeyLabel = [UILabel new];
        self.sentDayKeyLabel.font = [UIFont boldSystemFontOfSize:BurstPetite.virtualSheet.decomposeRow];
        self.sentDayKeyLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.sentDayKeyLabel];
        
        self.pressGrayLabel = [UILabel new];
        self.pressGrayLabel.font = [UIFont boldSystemFontOfSize:BurstPetite.virtualSheet.balancedAtom];
        self.pressGrayLabel.textColor = UIColor.darkGrayColor;
        [self.contentView addSubview:self.pressGrayLabel];
        
        [self.sentDayKeyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.policyLeadView.mas_right).offset(BurstPetite.virtualSheet.canTerabytes);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.pressGrayLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.sentDayKeyLabel);
            make.top.equalTo(self.sentDayKeyLabel.mas_bottom).offset(BurstPetite.virtualSheet.inputDigest);
        }];
        
        self.tabSixButton = [[UIButton alloc] init];
        _tabSixButton.userInteractionEnabled = NO;
        
        UIImage *image = [[UIImage lawMoodPointArteryQueryingName:BurstPetite.virtualSheet.helloTargetDiscardedCheckCap] imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
        [_tabSixButton setBackgroundImage:[UIImage lawMoodPointArteryQueryingName:BurstPetite.virtualSheet.anyContentsRepairSixUsage] forState: UIControlStateNormal];
        [_tabSixButton setBackgroundImage:image forState: UIControlStateSelected];
        _tabSixButton.tintColor = [BurstPetite finalTurnColor];
        [self.contentView addSubview:_tabSixButton];
        [_tabSixButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.offset(0);
            make.right.offset(-BurstPetite.virtualSheet.canTerabytes);
            make.size.mas_equalTo(CGSizeMake(BurstPetite.virtualSheet.seeFrequency, BurstPetite.virtualSheet.seeFrequency));
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected {
    _tabSixButton.selected = selected;
    self.layer.borderWidth = selected ? 1:0;
    self.layer.borderColor = [BurstPetite finalTurnColor].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 = BurstPetite.virtualSheet.partGeneral;
    frame.size.width -= BurstPetite.virtualSheet.decomposeRow;
    frame.origin.y += BurstPetite.virtualSheet.partGeneral;
    frame.size.height -= BurstPetite.virtualSheet.partGeneral;
    [super setFrame:frame];
    
    self.layer.cornerRadius = frame.size.height / 2.0;
}

-(void)setInvertAmharic:(NSString *)invertAmharic {
    _invertAmharic = invertAmharic;
    [self.policyLeadView sd_setImageWithURL:[NSURL URLWithString:invertAmharic] placeholderImage:nil];
}

- (void)setWinSendPop:(SceneOneRateRopeMovieFor *)winSendPop {
    _winSendPop= winSendPop;
    self.invertAmharic = winSendPop.fastLocal;
    self.sentDayKeyLabel.text = winSendPop.heartbeat;
    NSString *note = winSendPop.sinFooter?:@"";
    if (note.napTapExpect) {
        self.pressGrayLabel.hidden = YES;
        [self.sentDayKeyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.policyLeadView.mas_right).offset(BurstPetite.virtualSheet.canTerabytes);
            make.centerY.equalTo(self.contentView);
        }];
    }else {
        self.pressGrayLabel.hidden = NO;
        NSRange chunky = [note rangeOfString:BurstPetite.virtualSheet.neverChromiumTintRefinedLegalCost];
        NSRange dryHex = [note rangeOfString:BurstPetite.virtualSheet.backwardsPanKazakhPutStateCreating];
        
        if (chunky.length == 0 && dryHex.length == 0) {
            self.pressGrayLabel.text = note;
            self.pressGrayLabel.font = [UIFont systemFontOfSize:BurstPetite.virtualSheet.balancedAtom];
            self.pressGrayLabel.textColor = UIColor.lightGrayColor;
        }else {
            NSRange globally = NSMakeRange(chunky.location+chunky.length, dryHex.location-(chunky.location+chunky.length));
            NSString *bigSin = [note substringWithRange:globally];
            NSString *flatKey = [note stringByReplacingOccurrencesOfString:BurstPetite.virtualSheet.neverChromiumTintRefinedLegalCost withString:@""];
            flatKey = [flatKey stringByReplacingOccurrencesOfString:BurstPetite.virtualSheet.backwardsPanKazakhPutStateCreating withString:@""];
            
            globally = [flatKey rangeOfString:bigSin];
            NSMutableAttributedString *tipAlignment = [[NSMutableAttributedString alloc] initWithString:flatKey];
            [tipAlignment addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, flatKey.length)];
            [tipAlignment addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, flatKey.length)];
            [tipAlignment addAttribute:NSForegroundColorAttributeName value:[BurstPetite finalTurnColor] range:globally];
            [tipAlignment addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:globally];
            
            self.pressGrayLabel.attributedText = tipAlignment;
        }
        
        [self.sentDayKeyLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.policyLeadView.mas_right).offset(BurstPetite.virtualSheet.canTerabytes);
            make.top.equalTo(self.policyLeadView).offset(BurstPetite.virtualSheet.putBloodSaw);
        }];
    }
}

@end
