123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- //
- // SetPWDFirstViewController.m
- // 隐私保护
- //
- // Created by APPLE on 2023/9/19.
- //
- #import "SetPWDFirstViewController.h"
- #import <Masonry.h>
- #import "SetPWDSecondViewController.h"
- @interface SetPWDFirstViewController (){
- NSString *pwd;
- UILabel *pointView0;
- UILabel *pointView1;
- UILabel *pointView2;
- UILabel *pointView3;
-
- UIButton *keyBoardBtn0;
- }
- @end
- @implementation SetPWDFirstViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- pwd = @"";
- [self drawAnyView];
-
- //发个通知 记录进入了设置密码
- if(!_isForgetPwdType){
- //[[NSNotificationCenter defaultCenter] postNotificationName:setPwdNotification object:nil];
- [HWDataManager setBoolWithKey:Const_need_show_Secret_key value:YES];
- }
-
- }
- - (void)drawAnyView{
- [self.navigationBar setHidden:YES];
- [self.toolBar setHidden:YES];
-
- [self.view setBackgroundColor:HWF5F7FAColor];
-
- /*设置密码标题*/
- UILabel *topLabel = [[UILabel alloc] init];
- [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
- [topLabel setTextColor:HW333333Color];
- [topLabel setTextAlignment:(NSTextAlignmentCenter)];
- [topLabel setText:NSLocalizedString(@"guide_set_pwd_title",nil)];
- [self.view addSubview:topLabel];
- [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- make.top.mas_equalTo(99.f + H_STATE_BAR);
- }];
-
- CGFloat w_pwd = 24.f;
- CGFloat h_pwd = 24.f;
-
- CGFloat pointFont = 20.f;
- /*密码视图*/
- pointView0 = [[UILabel alloc] init];
- [pointView0 setTextColor:HW0A132BColor];
- [pointView0 setBackgroundColor:HWE3E8F1Color];
- [pointView0 setClipsToBounds:YES];
- [pointView0 setTextAlignment:(NSTextAlignmentCenter)];
- [pointView0 setFont:[UIFont systemFontOfSize:pointFont]];
- [pointView0.layer setCornerRadius:w_pwd/2.f];
- [self.view addSubview:pointView0];
- [pointView0 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view.mas_centerX).offset((0-2)*(w_pwd+w_pwd) + w_pwd/2.f);
- make.height.mas_equalTo(h_pwd);
- make.width.mas_equalTo(w_pwd);
- make.top.mas_equalTo(151.f + H_STATE_BAR);
- }];
-
- pointView1 = [[UILabel alloc] init];
- [pointView1 setTextColor:HW0A132BColor];
- [pointView1 setBackgroundColor:HWE3E8F1Color];
- [pointView1 setClipsToBounds:YES];
- [pointView1 setTextAlignment:(NSTextAlignmentCenter)];
- [pointView1 setFont:[UIFont systemFontOfSize:pointFont]];
- [pointView1.layer setCornerRadius:w_pwd/2.f];
- [self.view addSubview:pointView1];
- [pointView1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view.mas_centerX).offset((1-2)*(w_pwd+w_pwd) + w_pwd/2.f);
- make.height.mas_equalTo(h_pwd);
- make.width.mas_equalTo(w_pwd);
- make.top.mas_equalTo(151.f + H_STATE_BAR);
- }];
-
- pointView2 = [[UILabel alloc] init];
- [pointView2 setTextColor:HW0A132BColor];
- [pointView2 setBackgroundColor:HWE3E8F1Color];
- [pointView2 setClipsToBounds:YES];
- [pointView2 setTextAlignment:(NSTextAlignmentCenter)];
- [pointView2 setFont:[UIFont systemFontOfSize:pointFont]];
- [pointView2.layer setCornerRadius:w_pwd/2.f];
- [self.view addSubview:pointView2];
- [pointView2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view.mas_centerX).offset((2-2)*(w_pwd+w_pwd) + w_pwd/2.f);
- make.height.mas_equalTo(h_pwd);
- make.width.mas_equalTo(w_pwd);
- make.top.mas_equalTo(151.f + H_STATE_BAR);
- }];
-
- pointView3 = [[UILabel alloc] init];
- [pointView3 setTextColor:HW0A132BColor];
- [pointView3 setBackgroundColor:HWE3E8F1Color];
- [pointView3 setClipsToBounds:YES];
- [pointView3 setTextAlignment:(NSTextAlignmentCenter)];
- [pointView3 setFont:[UIFont systemFontOfSize:pointFont]];
- [pointView3.layer setCornerRadius:w_pwd/2.f];
- [self.view addSubview:pointView3];
- [pointView3 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view.mas_centerX).offset((3-2)*(w_pwd+w_pwd) + w_pwd/2.f);
- make.height.mas_equalTo(h_pwd);
- make.width.mas_equalTo(w_pwd);
- make.top.mas_equalTo(151.f + H_STATE_BAR);
- }];
-
- /*下方绘制键盘按钮*/
- UIView *bgViewForNumberBoard = [[UIView alloc] init];
- [bgViewForNumberBoard setBackgroundColor:[UIColor clearColor]];
- CGFloat w_bgViewForNumberBoard = SCREEN_W - 2*22.f*AUTOSCALE;
- CGFloat h_bgViewForNumberBoard = 330.f;
- [self.view addSubview:bgViewForNumberBoard];
- [bgViewForNumberBoard mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(22.f*AUTOSCALE);
- make.height.mas_equalTo(h_bgViewForNumberBoard);
- make.width.mas_equalTo(w_bgViewForNumberBoard);
- make.bottom.mas_equalTo(-70.f);
- }];
-
- CGFloat w_key_btn = w_bgViewForNumberBoard/3.f;
- CGFloat h_key_btn = h_bgViewForNumberBoard/4.f;
-
- /*绘制键盘 1~9*/
- for (NSInteger nFori = 0; nFori < 9; nFori++) {
- CGFloat x_key_btn = (nFori%3)*w_key_btn;
- CGFloat y_key_btn = (nFori/3)*h_key_btn;
-
- UIButton *keyBoardBtn = [[UIButton alloc] init];
- [keyBoardBtn setBackgroundColor:[UIColor clearColor]];
- [keyBoardBtn setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
- [keyBoardBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
- [keyBoardBtn setTitle:[NSString stringWithFormat:@"%ld",nFori+1] forState:(UIControlStateNormal)];
- [keyBoardBtn addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
- [bgViewForNumberBoard addSubview:keyBoardBtn];
- [keyBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(x_key_btn);
- make.top.mas_equalTo(y_key_btn);
- make.width.mas_equalTo(w_key_btn);
- make.height.mas_equalTo(h_key_btn);
- }];
- }
-
- /*删除按钮*/
- UIButton *deleteBoardBtn = [[UIButton alloc] init];
- [deleteBoardBtn setBackgroundColor:[UIColor clearColor]];
- [deleteBoardBtn addTarget:self action:@selector(deleteBoardBtnPressed) forControlEvents:(UIControlEventTouchUpInside)];
- [deleteBoardBtn setImage:[UIImage imageNamed:@"key_board_delete"] forState:(UIControlStateNormal)];
- [bgViewForNumberBoard addSubview:deleteBoardBtn];
- [deleteBoardBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.width.mas_equalTo(w_key_btn);
- make.height.mas_equalTo(h_key_btn);
- }];
-
- /*0*/
- keyBoardBtn0 = [[UIButton alloc] init];
- [keyBoardBtn0 setBackgroundColor:[UIColor clearColor]];
- [keyBoardBtn0 setTitleColor:HW0A132BColor forState:(UIControlStateNormal)];
- [keyBoardBtn0 setTitleColor:COLOR_PACEHOLDER forState:(UIControlStateDisabled)];
- [keyBoardBtn0.titleLabel setFont:[UIFont boldSystemFontOfSize:40.f]];
- [keyBoardBtn0 setTitle:@"0" forState:(UIControlStateNormal)];
- [keyBoardBtn0 addTarget:self action:@selector(keyBoardBtnPressed:) forControlEvents:(UIControlEventTouchUpInside)];
- [bgViewForNumberBoard addSubview:keyBoardBtn0];
- keyBoardBtn0.enabled = NO;
- [keyBoardBtn0 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(w_key_btn);
- make.bottom.mas_equalTo(0);
- make.width.mas_equalTo(w_key_btn);
- make.height.mas_equalTo(h_key_btn);
- }];
-
- /*OK*/
- UIButton *keyBoardBtnOK = [[UIButton alloc] init];
- [keyBoardBtnOK setBackgroundColor:[UIColor clearColor]];
- [keyBoardBtnOK setTitleColor:HW13B2EBColor forState:(UIControlStateNormal)];
- [keyBoardBtnOK.titleLabel setFont:[UIFont boldSystemFontOfSize:30.f]];
- [keyBoardBtnOK setTitle:@"OK" forState:(UIControlStateNormal)];
- [keyBoardBtnOK addTarget:self action:@selector(keyBoardBtnOKPressed) forControlEvents:(UIControlEventTouchUpInside)];
- [bgViewForNumberBoard addSubview:keyBoardBtnOK];
- [keyBoardBtnOK mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(2*w_key_btn);
- make.bottom.mas_equalTo(0);
- make.width.mas_equalTo(w_key_btn);
- make.height.mas_equalTo(h_key_btn);
- }];
-
- /*绘制引导视图*/
- [self addGuideView];
- }
- - (void)addGuideView{
- UIView *bgView = [[UIView alloc] init];
- [bgView setBackgroundColor:HW000000Color60];
- [self.view addSubview:bgView];
- [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- }];
-
- /*密码背景*/
- UIView *pwdBgView = [[UIView alloc] init];
- [pwdBgView setBackgroundColor:HWF5F7FAColor];
- pwdBgView.layer.cornerRadius = 26.f;
- [bgView addSubview:pwdBgView];
- [pwdBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(bgView.mas_centerX);
- make.top.mas_equalTo(68.f + H_STATE_BAR);
- make.width.mas_equalTo(248);
- make.height.mas_equalTo(138);
- }];
-
- /*密码*/
- UILabel *topLabel = [[UILabel alloc] init];
- [topLabel setFont:[UIFont boldSystemFontOfSize:16.f]];
- [topLabel setTextColor:HW333333Color];
- [topLabel setTextAlignment:(NSTextAlignmentCenter)];
- [topLabel setText:NSLocalizedString(@"guide_set_pwd_title",nil)];
- [pwdBgView addSubview:topLabel];
- [topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- make.top.mas_equalTo(31.f);
- }];
-
- for (NSInteger nfori = 0; nfori < 4; nfori++) {
- CGFloat w_pwd = 24.f;
- CGFloat h_pwd = 24.f;
- /*密码视图*/
- UILabel *pointView = [[UILabel alloc] init];
- [pointView setBackgroundColor:HWE3E8F1Color];
- [pointView setClipsToBounds:YES];
- [pointView.layer setCornerRadius:w_pwd/2.f];
- [pwdBgView addSubview:pointView];
- [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(40.f + (w_pwd + w_pwd)*nfori);
- make.height.mas_equalTo(h_pwd);
- make.width.mas_equalTo(w_pwd);
- make.top.mas_equalTo(83.f);
- }];
- }
-
- /*箭头视图*/
- UIImageView *flagImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_set_pwd_flag"]];
- [bgView addSubview:flagImageView];
- [flagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(pwdBgView.mas_left).offset(49);
- make.height.mas_equalTo(56);
- make.width.mas_equalTo(14);
- make.top.equalTo(pwdBgView.mas_bottom);
- }];
-
- /*不可点击btn*/
- UIButton *unableBtn = [[UIButton alloc] init];
- unableBtn.frame = CGRectMake(0, 0, 250, 40.f);
- // gradient
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0,0,250,40.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)];
-
- [unableBtn.layer addSublayer:gl];
- [unableBtn setUserInteractionEnabled:NO];
- [unableBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide",nil) forState:(UIControlStateNormal)];
- [unableBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [unableBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- [unableBtn.layer setCornerRadius:8.f];
- unableBtn.clipsToBounds = YES;
- [bgView addSubview:unableBtn];
- [unableBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(pwdBgView.mas_left).offset(16);
- make.width.mas_equalTo(250);
- make.top.equalTo(flagImageView.mas_bottom);
- make.height.mas_equalTo(40.f);
- }];
-
- UIButton *knowBtn = [[UIButton alloc] init];
- [knowBtn setBackgroundColor:[UIColor clearColor]];
- [knowBtn.layer setCornerRadius:18.f];
- [knowBtn.layer setBorderColor:HWFFFFFFColor.CGColor];
- [knowBtn.layer setBorderWidth:1];
- [knowBtn setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:(UIControlStateNormal)];
- [knowBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [knowBtn.titleLabel setFont:[UIFont systemFontOfSize:16]];
- [bgView addSubview:knowBtn];
- [knowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(pwdBgView.mas_right).offset(-10);
- make.width.mas_equalTo(120);
- make.top.equalTo(unableBtn.mas_bottom).offset(25);
- make.height.mas_equalTo(36.f);
- }];
- [knowBtn addTarget:bgView
- action:@selector(removeFromSuperview)
- forControlEvents:(UIControlEventTouchUpInside)];
- }
- - (void)deleteBoardBtnPressed{
- if (pwd.length > 0){
- NSInteger numberLength = pwd.length;
- if (numberLength == 1){
- [pointView0 setText:@""];
- [pointView0 setBackgroundColor:HWE3E8F1Color];
- self->keyBoardBtn0.enabled = NO;
- }else if (numberLength == 2){
- [pointView1 setText:@""];
- [pointView1 setBackgroundColor:HWE3E8F1Color];
- }else if (numberLength == 3){
- [pointView2 setText:@""];
- [pointView2 setBackgroundColor:HWE3E8F1Color];
- }else if (numberLength == 4){
- [pointView3 setText:@""];
- [pointView3 setBackgroundColor:HWE3E8F1Color];
- }
-
- pwd = [pwd substringToIndex:numberLength-1];
- }
- }
- - (void)keyBoardBtnOKPressed{
- if (pwd.length == 4){
- /*进入下一级确认密码*/
- SetPWDSecondViewController *nextVC = [[SetPWDSecondViewController alloc] init];
- nextVC.oldPWD = pwd;
- nextVC.isForgetPwdType = _isForgetPwdType;
- [self.navigationController pushViewController:nextVC animated:YES];
-
- if(!_isForgetPwdType){
- [HWDataManager setBoolWithKey:Const_need_random_Change_Params value:YES];
- }
- }
- }
- - (void)keyBoardBtnPressed:(id)sender{
- UIButton *btn = (UIButton *)sender;
- NSString *selectNumberStr = btn.titleLabel.text;
- if (pwd.length < 4){
- NSInteger numberLength = pwd.length;
- if (numberLength == 0){
- [pointView0 setText:selectNumberStr];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self->pointView0 setBackgroundColor:HW0A132BColor];
- self->keyBoardBtn0.enabled = YES;
- });
- }else if (numberLength == 1){
- [pointView1 setText:selectNumberStr];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self->pointView1 setBackgroundColor:HW0A132BColor];
- });
- }else if (numberLength == 2){
- [pointView2 setText:selectNumberStr];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self->pointView2 setBackgroundColor:HW0A132BColor];
- });
- }else if (numberLength == 3){
- [pointView3 setText:selectNumberStr];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self->pointView3 setBackgroundColor:HW0A132BColor];
- });
- }
-
- pwd = [pwd stringByAppendingString:selectNumberStr];
- }
- }
- /*
- #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
|