//
//  TipsQRCodeViewController.m
//  隐私保护
//
//  Created by APPLE on 2023/9/19.
//

#import "TipsQRCodeViewController.h"
#import <Masonry.h>
#import "UIView+View.h"
#import "QRCodeScanViewController.h"

@interface TipsQRCodeViewController ()

@end

@implementation TipsQRCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self drawAnyView];
}


- (void)drawAnyView{
    [self.navigationBar setHidden:YES];
    [self.toolBar setHidden:YES];
    
    /*背景视图*/
    UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_qrcode_bg_icon"]];
    [bgImageView setContentMode:(UIViewContentModeScaleToFill)];
    [self.view addSubview:bgImageView];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
    }];
    
    UIButton *qrcodeBtn = [[UIButton alloc] init];
    [qrcodeBtn setBackgroundColor:[UIColor clearColor]];
    [qrcodeBtn setBackgroundImage:[UIImage imageNamed:@"guide_qrcode_icon"] forState:(UIControlStateNormal)];
    [self.view addSubview:qrcodeBtn];
    [qrcodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo((363.f/812.f)*self.view.height - 80.f);
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.mas_equalTo(160);
        make.height.mas_equalTo(160);
    }];
    
    [qrcodeBtn addTarget:self
                  action:@selector(qrcodeBtnPressed)
        forControlEvents:(UIControlEventTouchUpInside)];
    
    /*提示文字*/
    UILabel *tipsLabel = [[UILabel alloc] init];
    [tipsLabel setFont:[UIFont systemFontOfSize:14]];
    [tipsLabel setTextColor:HW666666Color];
    [tipsLabel setTextAlignment:(NSTextAlignmentCenter)];
    [self.view addSubview:tipsLabel];
    [tipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(qrcodeBtn.mas_bottom).offset(8);
        make.left.mas_equalTo(60);
        make.right.mas_equalTo(-60);
    }];
    [tipsLabel setText:NSLocalizedString(@"guide_qrcoede_tips",nil)];
    
    /*扫一扫按钮*/
    UIButton *qrcodeSmallBtn = [[UIButton alloc] init];
    qrcodeSmallBtn.frame = CGRectMake(0, 0, 120.f, 36.f);

    // gradient
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,0,120.f,36.f);
    gl.startPoint = CGPointMake(0, 0.5);
    gl.endPoint = CGPointMake(1, 0.5);
    gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
    gl.locations = @[@(0), @(1.0f)];
    
    [qrcodeSmallBtn.layer addSublayer:gl];
    [qrcodeSmallBtn addTarget:self action:@selector(qrcodeBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
    [qrcodeSmallBtn setTitle:NSLocalizedString(@"guide_qrcoede_btn_title",nil) forState:(UIControlStateNormal)];
    [qrcodeSmallBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    [qrcodeSmallBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
    [qrcodeSmallBtn.layer setCornerRadius:18.f];
    qrcodeSmallBtn.clipsToBounds = YES;
    [self.view addSubview:qrcodeSmallBtn];
    [qrcodeSmallBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.width.mas_equalTo(120.f);
        make.top.equalTo(tipsLabel.mas_bottom).offset(20);
        make.height.mas_equalTo(36.f);
    }];
}

- (void)qrcodeBtnPressed{
    QRCodeScanViewController *nextVC = [[QRCodeScanViewController alloc] init];
    [self.navigationController pushViewController:nextVC animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
