92 lines
3.2 KiB
Objective-C
92 lines
3.2 KiB
Objective-C
//
|
|
// QXChirldModeViewController.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/5/12.
|
|
//
|
|
|
|
#import "QXChirldModeViewController.h"
|
|
#import "QXPasswordView.h"
|
|
#import "QXChirldViewController.h"
|
|
#import "AppDelegate.h"
|
|
@interface QXChirldModeViewController ()<QXPasswordViewDelegate>
|
|
@property (nonatomic,strong)QXPasswordView * passwordView;
|
|
@end
|
|
|
|
@implementation QXChirldModeViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
|
}
|
|
-(void)setNavgationItems{
|
|
[super setNavgationItems];
|
|
self.navigationItem.title = QXText(@"未成年人模式");
|
|
}
|
|
-(void)initSubViews{
|
|
self.passwordView = [[QXPasswordView alloc] init];
|
|
if (self.type == 1) {
|
|
self.passwordView.type = QXPasswordViewTypeChirldModeTwice;
|
|
}else{
|
|
self.passwordView.type = QXPasswordViewTypeChirldMode;
|
|
}
|
|
|
|
self.passwordView.delegate = self;
|
|
[self.view addSubview:self.passwordView];
|
|
[self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(NavContentHeight+80);
|
|
make.height.mas_equalTo(190);
|
|
make.left.right.equalTo(self.view);
|
|
}];
|
|
}
|
|
|
|
-(void)inputFinished:(NSString *)password{
|
|
if (self.type == 0) {
|
|
QXChirldModeViewController *vc = [[QXChirldModeViewController alloc] init];
|
|
vc.type = 1;
|
|
vc.password = password;
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}else if (self.type == 1) {
|
|
if ([self.password isEqualToString:password]) {
|
|
QXChirldViewController *vc = [[QXChirldViewController alloc] init];
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
[[NSUserDefaults standardUserDefaults] setObject:password forKey:kChirldLocalPassword];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
}else{
|
|
showToast(@"两次密码输入不一致");
|
|
}
|
|
}else if (self.type == 2) {
|
|
NSString *localPassword = [[NSUserDefaults standardUserDefaults] objectForKey:kChirldLocalPassword];
|
|
if (![localPassword isEqualToString:password]) {
|
|
showToast(@"密码错误");
|
|
}else{
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey:kChirldLocalPassword];
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
if (self.isRoot) {
|
|
AppDelegate *appdelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
|
|
[appdelegate changeRootViewControllerIsTabbar];
|
|
}else{
|
|
[self.navigationController popToRootViewControllerAnimated:YES];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
|
[self.view endEditing: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
|