//
//  FindTopCell.m
//  Open
//
//  Created by 雷俊博 on 2020/6/1.
//  Copyright © 2020 黄江涛 . All rights reserved.
//

#import "FindTopCell.h"

@interface FindTopCell ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgWidthLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgHeightLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *imgTopLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topLeadingLayout;


@end

@implementation FindTopCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.imgWidthLayout.constant = 35 * WIDTHRADIU;
    self.imgHeightLayout.constant = 35 * WIDTHRADIU;
    self.imgTopLayout.constant = 9 * WIDTHRADIU;
    self.topLeadingLayout.constant = 5 * WIDTHRADIU;
    
}


#pragma mark - public

- (void)setupCellWithModel:(DHCWNativeAdDataObject *)model
                  delegate:(id<DHCWNativeAdViewDelegate>)delegate loca:(id<DHCWNativeLocaVideoAdDelegate>)localDelegate
        rootViewController:(UIViewController *)rootViewController
{
    self.adView = [[NativeAdCustomView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)];
    [self.contentView addSubview:self.adView];
    
    [self.adView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.offset(0);
    } ];
    
    // 以下代码实现 请严谨按该顺序执行
    self.adView.delegate = delegate;

    [self.adView registerDataObject:model container:self.adView clickableViews:@[self.adView.clickButton]];
    self.adView.rootViewController = rootViewController;
    [self.adView setupWithModel:model];
    
    /**
            可选操作
     */
    self.localVideoAd = [[DHCWNativeLocalVideoAd alloc]init];
    self.localVideoAd.delegate = localDelegate;
    [self.adView configNativeLocalVideoAd:self.localVideoAd];
    
}

+ (CGFloat)cellHeightForModel:(DHCWNativeAdDataObject *)model
{
    return 100;
}

@end
