//
//  KSFeedAdCell.m
//  KSAdSDKGitDemo
//
//  Created by xuzhijun on 2019/11/24.
//  Copyright © 2019 xuzhijun. All rights reserved.
//

#import "KSFeedAdCell.h"
#import "Masonry.h"

@interface KSFeedAdCell ()

@property (nonatomic, strong)UIView *lineView;

@end

@implementation KSFeedAdCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:self.lineView];
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
  
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10 * WIDTHRADIU);
        make.right.offset(-10 * WIDTHRADIU);
        make.bottom.offset(0);
        make.height.offset(0.5);
    }];
}




- (void)refreshWithFeedAd:(KSFeedAd *)feedAd soundEnable:(BOOL)soundEnable {
    
    UIView *view = [self.contentView viewWithTag:100];
    [view removeFromSuperview];
    feedAd.feedView.tag = 100;
    [feedAd setVideoSoundEnable:soundEnable];
    [self.contentView addSubview:feedAd.feedView];
    [feedAd.feedView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.edges.left.right.top.equalTo(@0);
        make.edges.bottom.equalTo(@(6 * WIDTHRADIU + 1));
    }];
    
    [self.contentView bringSubviewToFront:self.lineView];
}

#pragma mark - getters 
- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
    }
    return _lineView;
}

@end
