@@ -42,6 +42,22 @@ public class PasscodeLockPresenter {
4242 self . init ( mainWindow: window, configuration: configuration, viewController: passcodeLockVC)
4343 }
4444
45+ // HACK: below function that handles not presenting the keyboard in case Passcode is presented
46+ // is a smell in the code that had to be introduced for iOS9 where Apple decided to move the keyboard
47+ // in a UIRemoteKeyboardWindow.
48+ // This doesn't allow our Passcode Lock window to move on top of keyboard.
49+ // Setting a higher windowLevel to our window or even trying to change keyboards'
50+ // windowLevel has been tried without luck.
51+ //
52+ // Revise in a later version and remove the hack if not needed
53+ func toggleKeyboardVisibility( hide hide: Bool ) {
54+ if let keyboardWindow = UIApplication . sharedApplication ( ) . windows. last
55+ where keyboardWindow. description. hasPrefix ( " <UIRemoteKeyboardWindow " )
56+ {
57+ keyboardWindow. alpha = hide ? 0.0 : 1.0
58+ }
59+ }
60+
4561 public func presentPasscodeLock( ) {
4662
4763 guard passcodeConfiguration. repository. hasPasscode else { return }
@@ -50,6 +66,8 @@ public class PasscodeLockPresenter {
5066 isPasscodePresented = true
5167 passcodeLockWindow. windowLevel = 2
5268
69+ toggleKeyboardVisibility ( hide: true )
70+
5371 let userDismissCompletionCallback = passcodeLockVC. dismissCompletionCallback
5472
5573 passcodeLockVC. dismissCompletionCallback = { [ weak self] in
@@ -84,11 +102,13 @@ public class PasscodeLockPresenter {
84102 self ? . passcodeLockWindow. windowLevel = 0
85103 self ? . passcodeLockWindow. rootViewController = nil
86104 self ? . passcodeLockWindow. alpha = 1
105+ self ? . toggleKeyboardVisibility ( hide: false )
87106 }
88107 )
89108 } else {
90109 passcodeLockWindow. windowLevel = 0
91110 passcodeLockWindow. rootViewController = nil
111+ toggleKeyboardVisibility ( hide: false )
92112 }
93113 }
94114}
0 commit comments