//
//  NvMoreReloadView.m
//  SDKDemo
//
//  Created by shizhouhu on 2018/7/18.
 //
//

#import "NvMoreReloadView.h"
#import "NvUtils.h"
#import "UIColor+NvColor.h"
#import "Masonry.h"

@implementation NvMoreReloadView

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    
    UILabel *label = UILabel.new;
    label.text = @"加载失败！";
    label.font = [UIFont systemFontOfSize:19*SCREANSCALE];
    label.textColor = [UIColor nv_colorWithHexRGB:@"#D0021B"];
    [self addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self).offset(-100);
        make.width.equalTo(@(95*SCREANSCALE));
        make.height.equalTo(@(27*SCREANSCALE));
    }];
    
    UIButton *button = UIButton.new;
    [button setTitle:@"重试" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    button.backgroundColor = [UIColor nv_colorWithHexRGB:@"#4A90E2"];
    button.layer.cornerRadius = 4*SCREANSCALE;
    [self addSubview:button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.centerY.equalTo(self);
        make.width.equalTo(@(60*SCREANSCALE));
        make.height.equalTo(@(27*SCREANSCALE));
    }];
    
    [button addTarget:self action:@selector(onReloadClicked) forControlEvents:UIControlEventTouchUpInside];
    self.backgroundColor = [UIColor whiteColor];
    return self;
}

- (void)onReloadClicked {
    if ([self.delegate respondsToSelector:@selector(onReloadClicked)]) {
        [self.delegate onReloadClicked];
    }
}

@end
