//
//  KWMTBVSectionHeardView.m
//  iCemarose
//
//  Created by 陈荣科 on 16/9/1.
//  Copyright © 2016年 kollway. All rights reserved.
//

#import "KWMTBVSectionHeardView.h"
#import "KWMStringUtil.h"

@implementation KWMTBVSectionHeardView

- (instancetype)init{
    if (self = [super init]) {
        [self initContentView];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder{

    if (self = [super initWithCoder:aDecoder]) {
        [self initContentView];
    }
    return self;
}

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

- (void)awakeFromNib{
    [super awakeFromNib];
    [self initContentView];
}

- (void)initContentView{
    [[NSBundle mainBundle] loadNibNamed:@"KWMTBVSectionHeardView" owner:self options:nil];
    [self addSubview:self.vContent];
    self.vContent.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
    self.vLine.backgroundColor = [UIColor colorWithRed:241.0/255 green:242.0/255 blue:243.0/255 alpha:1];
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickWacthMore:)];
    self.ivMore.userInteractionEnabled = YES;
    [self.ivMore addGestureRecognizer:tapGesture];
}

- (void)setGoodsModel:(KWMNewGoodsModel *)goodsModel{
    _goodsModel = goodsModel;
    if (goodsModel) {
        if (goodsModel.chineseName != nil && ![goodsModel.chineseName isEqualToString:@""]) {
            _lbSectionTitel.text = _goodsModel.chineseName;
        }else{
            _lbSectionTitel.text = _goodsModel.title;
        }
    }
}

- (void)onClickWacthMore:(UITapGestureRecognizer *)tapGesture{
    if ([self.delegate respondsToSelector:@selector(kwm_watchMoreProductsByBrand:AndTitle:)]) {
        [self.delegate kwm_watchMoreProductsByBrand:_goodsModel AndTitle:_lbSectionTitel.text];
    }
}

@end