//
//  GovNewsHeaderView.m
//  Open
//
//  Created by 雷俊博 on 2021/7/20.
//  Copyright © 2021 黄江涛 . All rights reserved.
//

#import "GovNewsHeaderView.h"
#import "GovLineView.h"
#import <KSAdSDK/KSCUFeedPage.h>
#import "UIViewController+KSCUFeedPageExtend.h"
@implementation GovNewsHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    
    UIView *blueView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), 45 * WIDTHRADIU)];
    blueView.backgroundColor = K_MainColor;
    [self addSubview:blueView];
    UIBezierPath *maskPath;
    maskPath = [UIBezierPath bezierPathWithRoundedRect:blueView.bounds

                                        byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)

                                              cornerRadii:CGSizeMake(8.0, 8.0)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = blueView.bounds;
    maskLayer.path = maskPath.CGPath;
    blueView.layer.mask = maskLayer;
    
    
    //阴历
    UILabel *lb_date = [UILabel new];
    lb_date.text = @"今日签到";
    lb_date.textColor = [UIColor whiteColor];
    lb_date.font = [UIFont boldSystemFontOfSize:14 * WIDTHRADIU];
    [blueView addSubview:lb_date];
    [lb_date mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15 * WIDTHRADIU);
        make.centerY.equalTo(blueView);
    }];
    
    self.lb_lunDate = lb_date;
    
    //温度
    UILabel *lb_weather = [UILabel new];
    lb_weather.text = @"连续签到拿更多金币奖励";
    lb_weather.textColor = [UIColor whiteColor];
    lb_weather.font = [UIFont systemFontOfSize:13 * WIDTHRADIU];
    [blueView addSubview:lb_weather];
    [lb_weather mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lb_date.mas_right).offset(20 * WIDTHRADIU);
        make.centerY.equalTo(blueView);
    }];
    
    self.lb_dateAndWeather = lb_weather;
    
    
    //日期按钮
    UIButton *dateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    dateBtn.tag = 200;
    [dateBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [blueView addSubview:dateBtn];
    [dateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.offset(0);
        make.right.equalTo(lb_weather);
    }];
    
    
    //按钮
    UIButton *targetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    targetBtn.frame = CGRectMake(CGRectGetWidth(self.bounds) - 95 * WIDTHRADIU, 8.5 * WIDTHRADIU, 80 * WIDTHRADIU, 28 * WIDTHRADIU);
    [targetBtn setTitle:@"领取金币" forState:UIControlStateNormal];
    [targetBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    targetBtn.titleLabel.font = [UIFont systemFontOfSize:12 * WIDTHRADIU];
    targetBtn.layer.cornerRadius = 14 * WIDTHRADIU;
    targetBtn.layer.borderWidth = 0.5;
    targetBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    targetBtn.tag = 201;
    [targetBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [blueView addSubview:targetBtn];
    
    self.signBtn = targetBtn;
    
    //新闻header
    //UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(blueView.frame), CGRectGetWidth(self.bounds), 46 * WIDTHRADIU)];
    //headerView.backgroundColor = [UIColor whiteColor];
    //[self addSubview:headerView];
    
    
    //line
//    GovLineView *lineView = [[GovLineView alloc]initWithFrame:CGRectMake(15 * WIDTHRADIU, 15 * WIDTHRADIU, 4, 16 * WIDTHRADIU)];
//    [headerView addSubview:lineView];
//
//    UILabel *lb_title = [UILabel new];
//    lb_title.text = @"视频";
//    lb_title.textColor = [UIColor colorWithHex:0x4d4d4d];
//    lb_title.font = [UIFont systemFontOfSize:17 * WIDTHRADIU weight:UIFontWeightMedium];
//    [headerView addSubview:lb_title];
//    [lb_title mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(lineView.mas_right).offset(10 * WIDTHRADIU);
//        make.centerY.equalTo(lineView);
//    }];
    
//    KSCUFeedPage *feedPage = [[KSCUFeedPage alloc] initWithPosId:@"6030000009"];
//    feedPage.videoStateDelegate = self;
//    feedPage.stateDelegate = self;
//    feedPage.callBackDelegate = self;
//    feedPage.hidesBottomBarWhenPushed = YES;
//    UIViewController *vc1 = feedPage.feedViewController;
//    [vc1 setKscu_feedPageDelegate:self.Gov];
//    [self.Gov addChildViewController:vc1];
//    UIView *ksview=vc1.view;
//    ksview.frame=CGRectMake(0, 200, ScreenWidth, ScreenHeight + 52);
//    [headerView addSubview:ksview];
//    [vc1.view mas_makeConstraints:^(MASConstraintMaker *make) {
//        //make.top.equalTo(self.newsHeaderView.mas_bottom).offset(20);
//        make.top.right.bottom.left.offset(0);
//    }];
//    
    
//    //查看全部
//    UILabel *checkLabel = [UILabel new];
//    checkLabel.text = @"查看全部>>";
//    checkLabel.textColor = [UIColor colorWithHex:0x808080];
//    checkLabel.font = [UIFont systemFontOfSize:14 * WIDTHRADIU];
//    checkLabel.textAlignment = NSTextAlignmentRight;
//    [headerView addSubview:checkLabel];
//
//    [checkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.offset(-15 * WIDTHRADIU);
//        make.centerY.equalTo(headerView);
//        make.height.offset(46 * WIDTHRADIU);
//    }];
//
//    UIButton *checkAllBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    checkAllBtn.tag = 202;
//    [checkAllBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
//    [headerView addSubview:checkAllBtn];
//    [checkAllBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.right.top.bottom.equalTo(checkLabel);
//    }];
    
    
    
   
}

#pragma mark - event response
- (void)btnClick:(UIButton *)sender
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(GovNewsHeaderViewClickBtnWithIndex:)]) {
        [self.delegate GovNewsHeaderViewClickBtnWithIndex:sender.tag];
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
