// // JZLogginWindowManager.m // JIZHANG // // Created by kuxuan on 2017/12/25. // Copyright © 2017年 kuxuan. All rights reserved. // #import "JZLogginWindowManager.h" #import "JZGestureLogginController.h" #import "JZTouchIDTool.h" #import "JZNavigationViewController.h" @interface JZLogginWindowManager () @end @implementation JZLogginWindowManager + (instancetype)sharedManager{ static JZLogginWindowManager *manager; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ manager = [[self alloc]init]; }); return manager; } - (instancetype)init{ if (self = [super init]) { self.isShow = NO; [self setupWindow]; [self setupNotification]; } return self; } - (void)setupWindow{ self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.windowLevel = UIWindowLevelAlert; self.window.backgroundColor = [UIColor redColor]; JZGestureLogginController *loggin = [[JZGestureLogginController alloc]init]; self.window.rootViewController = [[JZNavigationViewController alloc]initWithRootViewController:loggin]; [self.window makeKeyAndVisible]; self.window.hidden = YES; loggin.windowManager = self; } - (void)show{ self.isShow = YES; [self showTouchId]; self.window.hidden = NO; } - (void)showTouchId{ if ([JZTouchIDTool isOpenTouchID]) { [JZTouchIDTool validateTouchID]; } } - (void)hide{ self.isShow = NO; self.window.hidden = YES; } - (void)setupNotification { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDSuccess) name:JZValidateTouchIDSuccess object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDFailure) name:JZValidateTouchIDFailure object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDCancel) name:JZValidateTouchIDCancel object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDUserFallback) name:JZValidateTouchIDUserFallback object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidatePasscodeNotSet) name:JZValidateTouchIDPasscodeNotSet object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDNotAvailable) name:JZValidateTouchIDNotAvailable object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDNotEnrolled) name:JZValidateTouchIDNotEnrolled object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveTouchIDLockout) name:JZValidateTouchIDLockout object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveTouchIDInvalidContext) name:JZValidateTouchIDInvalidContext object:nil]; } - (void)actionDidReceiveValidateTouchIDSuccess { NSLog(@"%s",__func__); [self hide]; } - (void)actionDidReceiveValidateTouchIDFailure { NSLog(@"%s",__func__); } - (void)actionDidReceiveValidateTouchIDCancel { NSLog(@"%s",__func__); } - (void)actionDidReceiveValidateTouchIDUserFallback { NSLog(@"%s",__func__); } - (void)actionDidReceiveValidatePasscodeNotSet { NSLog(@"%s",__func__); } - (void)actionDidReceiveValidateTouchIDNotAvailable { NSLog(@"%s",__func__); } - (void)actionDidReceiveValidateTouchIDNotEnrolled { NSLog(@"%s",__func__); } - (void)actionDidReceiveTouchIDLockout { NSLog(@"%s",__func__); } - (void)actionDidReceiveTouchIDInvalidContext { NSLog(@"%s",__func__); } @end