//
//  WKSimilarPhotoHeadView.m
//  WuKongClearPhotoDemo
//
//  Created by ZhangJingHao2345 on 2018/3/8.
//  Copyright © 2018年 ZhangJingHao2345. All rights reserved.
//

#import "WKSimilarPhotoHeadView.h"

@interface WKSimilarPhotoHeadView()

@property (nonatomic, weak) UILabel *nameLab;


@end

@implementation WKSimilarPhotoHeadView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUIWithFrame:frame];
    }
    return self;
}

- (void)setupUIWithFrame:(CGRect)frame {
    CGFloat nameX = 15;
    CGFloat nameW = frame.size.width * 0.5;
    CGFloat nameH = frame.size.height;
    CGRect nameF = CGRectMake(nameX, 0, nameW, nameH);
    UILabel *nameLab = [[UILabel alloc] initWithFrame:nameF];
    nameLab.textColor = [UIColor colorWithHex:0x858B9C];
    nameLab.font = [UIFont systemFontOfSize:15];
    [self addSubview:nameLab];
    self.nameLab = nameLab;
    
    CGFloat btnW = 100;
    CGFloat btnX = frame.size.width - btnW;
    UIButton *selectBtn = [[UIButton alloc] initWithFrame:CGRectMake(btnX, 0, btnW, nameH)];
    selectBtn.titleLabel.font = [UIFont systemFontOfSize: 15];
    [selectBtn setTitle: ICLocalized(@"CancelAll") forState:UIControlStateSelected];
    [selectBtn setTitle: ICLocalized(@"ChooseAll") forState:UIControlStateNormal];
    [selectBtn setTitleColor:kMassColor forState:UIControlStateNormal];
    [selectBtn addTarget:self action:@selector(selectAllOrNotAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:selectBtn];
    self.selectBtn = selectBtn;
    self.selectBtn.selected = true;
}

- (void)selectAllOrNotAction: (UIButton *)button {
    button.selected = !button.isSelected;    
    if (_selectAllOrNotClosure) {
        _selectAllOrNotClosure(button.isSelected);
    }
}

- (void)bindWithCountString:(NSString *)countString {
    self.nameLab.text = countString;
}


@end
