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

#import "UIButton+CQBlockSupport.h"
#import "TouchRemove.h"
#import "WithDrawBindWXAlertView.h"

@implementation WithDrawBindWXAlertView

+ (void)showAlertViewWithBlock:(void (^)(void))checkButtonClickedBlock {
    //大背景
     TouchRemove *bgView = [[TouchRemove alloc] init];
     [[[[UIApplication sharedApplication] delegate] window] addSubview:bgView];
       bgView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
       [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
           make.edges.mas_equalTo(UIEdgeInsetsMake(0, 0, 0, 0));
       }];
    __block TouchRemove *backView = bgView;
    bgView.touchBlock = ^{
        [backView removeFromSuperview];
    };

    
    
    // 白色view
    UIView *whiteView = [[UIView alloc] init];
    [bgView addSubview:whiteView];
    whiteView.clipsToBounds = YES;
    whiteView.backgroundColor = [UIColor whiteColor];
    whiteView.layer.cornerRadius = 10;
    [whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(230);
        make.height.mas_equalTo(158);
        make.center.mas_equalTo(bgView);
    }];
    
    UIImageView *wxImg = [[UIImageView alloc]init];
    [whiteView addSubview:wxImg];
    wxImg.image = [UIImage imageNamed:@"bindwx_icon"];
    [wxImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(55);
        make.centerX.mas_equalTo(whiteView);
        make.top.mas_equalTo(15);
    }];
    
    // 标题
       UILabel *titleLabel = [[UILabel alloc] init];
       [whiteView addSubview:titleLabel];
       titleLabel.font = [UIFont boldSystemFontOfSize:15];
    titleLabel.textColor = [UIColor colorWithHex:0x4c4c4c];
       titleLabel.textAlignment = NSTextAlignmentCenter;
       titleLabel.text = @"绑定微信才能提现";
       [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
           make.top.equalTo(wxImg.mas_bottom).mas_offset(15);
           make.left.right.mas_offset(0);
           make.height.mas_equalTo(15);
       }];
    
    // 横线灰色线
    UIView *grayLineView1 = [[UIView alloc] init];
    [whiteView addSubview:grayLineView1];
    grayLineView1.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:1.00];
    [grayLineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_offset(0);
        make.height.mas_equalTo(1);
        make.top.mas_equalTo(titleLabel.mas_bottom).mas_offset(15);
    }];
    
    // 立即绑定按钮
    UIButton *bindButton = [[UIButton alloc] init];
    [whiteView addSubview:bindButton];
    [bindButton setTitle:@"立即绑定" forState:UIControlStateNormal];
    [bindButton.titleLabel setFont:[UIFont boldSystemFontOfSize:14]];
    [bindButton setTitleColor:K_MainColor forState:UIControlStateNormal];
    [bindButton cq_addAction:^(UIButton *button) {
        [bgView removeFromSuperview];
        checkButtonClickedBlock();
    } forControlEvents:UIControlEventTouchUpInside];
    
    [bindButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(grayLineView1.mas_bottom);
        make.left.right.bottom.mas_equalTo(whiteView);
    }];
    
    
    // 出场动画
       bgView.alpha = 0;
       whiteView.alpha = 0;
       whiteView.transform = CGAffineTransformScale(whiteView.transform, 0.1, 0.1);
       [UIView animateWithDuration:0.2 animations:^{
           whiteView.transform = CGAffineTransformIdentity;
           bgView.alpha = 1;
           whiteView.alpha = 1;
       }];
    
}




@end
