//
//  SaveSettingSuccessController.m
//  Open
//
//  Created by 雷俊博 on 2020/8/26.
//  Copyright © 2020 黄江涛 . All rights reserved.
//

#import "SaveSettingSuccessController.h"

@interface SaveSettingSuccessController ()

@property (nonatomic, strong)UIImageView* icon;

@property (nonatomic, strong)UILabel* lb_text;

@property (nonatomic, strong)UILabel* lb_number;

@property (nonatomic, strong)UIButton* confirmBtn;

@end

@implementation SaveSettingSuccessController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.view addSubview:self.icon];
    [self.view addSubview:self.lb_text];
    [self.view addSubview:self.lb_number];
    [self.view addSubview:self.confirmBtn];
   
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationItem.hidesBackButton = YES;
    //禁止页面左侧滑动返回，注意，如果仅仅需要禁止此单个页面返回，还需要在viewWillDisapper下开放侧滑权限
    // 禁用返回手势
    //禁止手势返回
    id traget = self.navigationController.interactivePopGestureRecognizer.delegate;
    UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:traget action:nil];
    [self.view addGestureRecognizer:pan];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(cl_kNavigationBarHeight + 20);
        make.centerX.equalTo(self.view);
        make.width.height.offset(109);
    }];
    
    [self.lb_text mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.icon.mas_bottom).offset( 10);
        make.centerX.equalTo(self.view);
    }];
    
    [self.lb_number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lb_text.mas_bottom).offset( 20);
        make.centerX.equalTo(self.view);
    }];
    
    [self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.right.offset(-15);
        make.top.equalTo(self.lb_number.mas_bottom).offset(40);
        make.height.offset(44);
    }];
}


#pragma mark - event response
- (void)confirmBtnClick:(UIButton *)sender
{
    self.navigationController.tabBarController.selectedIndex = 1;
    [self.navigationController popToRootViewControllerAnimated:YES];
}


#pragma mark - getters
- (UIImageView *)icon
{
    if (!_icon) {
        _icon = [[UIImageView alloc]init];
        _icon.image = [UIImage imageNamed:@"saveModtifySuccess"];
    }
    return _icon;
}

- (UILabel *)lb_text
{
    if (!_lb_text) {
        _lb_text = [UILabel new];
        _lb_text.text = @"修改成功";
        _lb_text.font = [UIFont boldSystemFontOfSize:17];
        _lb_text.textColor = [UIColor colorWithHex:0x4d4d4d];
        _lb_text.textAlignment = NSTextAlignmentCenter;
    }
    return _lb_text;
}

- (UILabel *)lb_number
{
    if (!_lb_number) {
        _lb_number = [UILabel new];
        _lb_number.text = @"136****0495";
        _lb_number.font = [UIFont systemFontOfSize:15];
        _lb_number.textColor = [UIColor colorWithHex:0x4d4d4d];
        _lb_number.textAlignment = NSTextAlignmentCenter;
        
        if (self.type == SMSSendTypePhoneModtify) {
            self.lb_number.text = [NSString stringWithFormat:@"%@ **** %@",[self.phone substringToIndex:3],[self.phone substringFromIndex:self.phone.length - 4]];
        }else if (self.type == SMSSendTypeTypeBindCardModify){
            self.lb_number.text = [NSString stringWithFormat:@"%@ **** **** **** %@",[self.nBindCard substringToIndex:4],[self.nBindCard substringFromIndex:self.nBindCard.length - 3]];
        }
        
    }
    return _lb_number;
}


- (UIButton *)confirmBtn
{
    if (!_confirmBtn) {
        _confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_confirmBtn setTitle:@"完成" forState:UIControlStateNormal];
        _confirmBtn.backgroundColor = [UIColor colorWithHex:0x137ef6];
        [_confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _confirmBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        _confirmBtn.layer.cornerRadius = 5;
        [_confirmBtn addTarget:self action:@selector(confirmBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _confirmBtn;
}

/*
#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
