//
//  Package2CoinsView.m
//  Open
//
//  Created by 雷俊博 on 2019/10/23.
//  Copyright © 2019 黄江涛 . All rights reserved.
//

#import "Package2CoinsView.h"
#import "UIButton+CQBlockSupport.h"

@implementation Package2CoinsView

/** 带block回调的弹窗 */
+ (void)alertWithButtonClickedBlock:(void (^)(void))buttonClickedBlock
{
    
    // 大背景
    UIView *bgView = [[UIView alloc] init];
    [[[[UIApplication sharedApplication] delegate] window] addSubview:bgView];
    bgView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
    }];
    
    
    // 背景图片
    
       UIButton  *bgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
       [bgBtn setBackgroundImage:[UIImage imageNamed:@"签到成功"] forState:UIControlStateNormal];
       [bgView addSubview:bgBtn];
       [bgBtn cq_addAction:^(UIButton *button) {
         buttonClickedBlock();
         [bgView removeFromSuperview];
     } forControlEvents:UIControlEventTouchUpInside];
       [bgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
           make.center.mas_equalTo(bgView);
           make.size.mas_equalTo(CGSizeMake(138, 145));
       }];
    
    
    // 取消按钮
       UIButton *cancelButton = [[UIButton alloc] init];
       [bgView addSubview:cancelButton];
       [cancelButton setBackgroundImage:[UIImage imageNamed:@"btn_lottery_close"] forState:UIControlStateNormal];
       // 取消按钮点击
       [cancelButton cq_addAction:^(UIButton *button) {
           [bgView removeFromSuperview];
       } forControlEvents:UIControlEventTouchUpInside];
       [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
           make.left.mas_equalTo(bgBtn.mas_right).mas_offset(-8);
           make.bottom.mas_equalTo(bgBtn.mas_top).mas_offset(15);
           make.size.mas_equalTo(CGSizeMake(34, 34));
       }];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
