//
//  NvStrokeCollectionViewCell.m
//  SDKDemo
//
//  Created by Meicam on 2018/6/6.
//  Copyright © 2018年 刘东旭. All rights reserved.
//

#import "NvStrokeCollectionViewCell.h"
#import "NVHeader.h"

@interface NvStrokeCollectionViewCell()

@property (nonatomic, strong) UIImageView *view;

@end

@implementation NvStrokeCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.contentView.backgroundColor = [UIColor nv_colorWithHexRGB:@"#242728"];
        self.view = [UIImageView new];
        [self.contentView addSubview:self.view];
        [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(@0);
        }];
    }
    return self;
}

- (void)renderCellWithItem:(NvCaptionStrokeItem *)item {
    if (item.color.r == 0 && item.color.g == 0 && item.color.b == 0 && item.color.a == 0) {
        self.view.image = [NvUtils imageWithName:@"NvsFilterNone"];
        self.view.backgroundColor = [UIColor clearColor];
    } else {
        self.view.image = nil;
        self.view.backgroundColor = [UIColor colorWithRed:item.color.r green:item.color.g blue:item.color.b alpha:item.color.a];
    }
    if (item.isSelect) {
        self.view.layer.borderWidth = 2;
        self.view.layer.borderColor = [UIColor nv_colorWithHexRGB:@"#4A90E2"].CGColor;
        self.view.layer.cornerRadius = 12.5*SCREANSCALE;
        self.view.layer.masksToBounds = YES;
    } else {
        self.view.layer.borderWidth = 0;
        self.view.layer.borderColor = [UIColor clearColor].CGColor;
        self.view.layer.cornerRadius = 12.5*SCREANSCALE;
        self.view.layer.masksToBounds = YES;
    }
}


@end
