悟空记账

JZLogginWindowManager.m 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // JZLogginWindowManager.m
  3. // JIZHANG
  4. //
  5. // Created by kuxuan on 2017/12/25.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "JZLogginWindowManager.h"
  9. #import "JZGestureLogginController.h"
  10. #import "JZTouchIDTool.h"
  11. #import "JZNavigationViewController.h"
  12. @interface JZLogginWindowManager ()
  13. @end
  14. @implementation JZLogginWindowManager
  15. + (instancetype)sharedManager{
  16. static JZLogginWindowManager *manager;
  17. static dispatch_once_t onceToken;
  18. dispatch_once(&onceToken, ^{
  19. manager = [[self alloc]init];
  20. });
  21. return manager;
  22. }
  23. - (instancetype)init{
  24. if (self = [super init]) {
  25. self.isShow = NO;
  26. [self setupWindow];
  27. [self setupNotification];
  28. }
  29. return self;
  30. }
  31. - (void)setupWindow{
  32. self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
  33. self.window.windowLevel = UIWindowLevelAlert;
  34. self.window.backgroundColor = [UIColor redColor];
  35. JZGestureLogginController *loggin = [[JZGestureLogginController alloc]init];
  36. self.window.rootViewController = [[JZNavigationViewController alloc]initWithRootViewController:loggin];
  37. [self.window makeKeyAndVisible];
  38. self.window.hidden = YES;
  39. loggin.windowManager = self;
  40. }
  41. - (void)show{
  42. self.isShow = YES;
  43. [self showTouchId];
  44. self.window.hidden = NO;
  45. }
  46. - (void)showTouchId{
  47. if ([JZTouchIDTool isOpenTouchID]) {
  48. [JZTouchIDTool validateTouchID];
  49. }
  50. }
  51. - (void)hide{
  52. self.isShow = NO;
  53. self.window.hidden = YES;
  54. }
  55. - (void)setupNotification {
  56. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDSuccess) name:JZValidateTouchIDSuccess object:nil];
  57. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDFailure) name:JZValidateTouchIDFailure object:nil];
  58. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDCancel) name:JZValidateTouchIDCancel object:nil];
  59. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDUserFallback) name:JZValidateTouchIDUserFallback object:nil];
  60. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidatePasscodeNotSet) name:JZValidateTouchIDPasscodeNotSet object:nil];
  61. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDNotAvailable) name:JZValidateTouchIDNotAvailable object:nil];
  62. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveValidateTouchIDNotEnrolled) name:JZValidateTouchIDNotEnrolled object:nil];
  63. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveTouchIDLockout) name:JZValidateTouchIDLockout object:nil];
  64. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionDidReceiveTouchIDInvalidContext) name:JZValidateTouchIDInvalidContext object:nil];
  65. }
  66. - (void)actionDidReceiveValidateTouchIDSuccess {
  67. NSLog(@"%s",__func__);
  68. [self hide];
  69. }
  70. - (void)actionDidReceiveValidateTouchIDFailure {
  71. NSLog(@"%s",__func__);
  72. }
  73. - (void)actionDidReceiveValidateTouchIDCancel {
  74. NSLog(@"%s",__func__);
  75. }
  76. - (void)actionDidReceiveValidateTouchIDUserFallback {
  77. NSLog(@"%s",__func__);
  78. }
  79. - (void)actionDidReceiveValidatePasscodeNotSet {
  80. NSLog(@"%s",__func__);
  81. }
  82. - (void)actionDidReceiveValidateTouchIDNotAvailable {
  83. NSLog(@"%s",__func__);
  84. }
  85. - (void)actionDidReceiveValidateTouchIDNotEnrolled {
  86. NSLog(@"%s",__func__);
  87. }
  88. - (void)actionDidReceiveTouchIDLockout {
  89. NSLog(@"%s",__func__);
  90. }
  91. - (void)actionDidReceiveTouchIDInvalidContext {
  92. NSLog(@"%s",__func__);
  93. }
  94. @end