//
//  forgetPwdViewController.m
//  隐私保护
//
//  Created by xd h on 2023/11/6.
//

#import "forgetPwdViewController.h"
#import "AuthCodeInputView.h"
#import "SetPWDFirstViewController.h"
#import "forgetSecretKeyViewController.h"

@interface forgetPwdViewController ()

@end

@implementation forgetPwdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self.toolBar setHidden:YES];
    [self.navigationBar setHidden:YES];
    [self.navBarBGView setHidden:NO];
    
    NSString *curTitle = NSLocalizedString(@"input_pwd_forget_secret_key",nil);
    UIButton *rightBut = [[UIButton alloc] init];
    //rightBut.backgroundColor = [UIColor redColor];
    [rightBut setTitle:curTitle forState:UIControlStateNormal];
    rightBut.titleLabel.font = [UIFont systemFontOfSize:16.0];
    [rightBut  setTitleColor:[UIColor hwColor:@"#13B2EB" alpha:1.0] forState:UIControlStateNormal];
    [rightBut addTarget:self action:@selector(rightBtnPressed) forControlEvents:UIControlEventTouchUpInside];
    [self.navBarBGView addSubview:rightBut];
    
    [rightBut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.backBtn.mas_centerY);
        make.width.mas_equalTo(80);
        make.right.mas_equalTo(-20);
        make.height.mas_equalTo(30);
    }];
    
    [self initBaseUIfun];
}

#pragma mark 点击返回
- (void)backBtnPressed{
    if(_isCheckPwdType){
        [self.navigationController popViewControllerAnimated:YES];
        return;
    }
    
    //发个通知 记录进入了设置密码
    [[NSNotificationCenter defaultCenter] postNotificationName:forgetPwdBackNotification object:nil];
}

#pragma mark 点击右导航线
- (void)rightBtnPressed{
    forgetSecretKeyViewController *vc = [forgetSecretKeyViewController new];
    [self.navigationController pushViewController:vc animated:YES];
}
    
#pragma mark UI
- (void)initBaseUIfun
{
    self.view.backgroundColor = HWF5F7FAColor;
    
    AuthCodeInputView *view =  [[AuthCodeInputView alloc] init];
    [self.view addSubview:view];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(self.navBarBGView.mas_bottom).offset(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    
    KWeakSelf
    view.authSuccess = ^(BOOL success) {
        if(success){
            [weakSelf gotoSetPwdVCFun];
        }
    };
}

#pragma mark 跳转设置密码界面
- (void)gotoSetPwdVCFun
{
    /*设置密码*/
    SetPWDFirstViewController *nextVC = [[SetPWDFirstViewController alloc] init];
    nextVC.isForgetPwdType = YES;
    [self.navigationController pushViewController:nextVC animated:YES];
}
@end
