Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting PasscodeLock windowLevel #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions PasscodeLock/PasscodeLockPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import UIKit
public class PasscodeLockPresenter {

private var mainWindow: UIWindow?
private var passcodeWindowLevel: UIWindowLevel

private lazy var passcodeLockWindow: UIWindow = {

Expand All @@ -27,19 +28,24 @@ public class PasscodeLockPresenter {

public let passcodeLockVC: PasscodeLockViewController

public init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType, viewController: PasscodeLockViewController) {

public init(mainWindow window: UIWindow?, passcodeWindowLevel: UIWindowLevel = 2,
configuration: PasscodeLockConfigurationType, viewController: PasscodeLockViewController)
{
mainWindow = window
mainWindow?.windowLevel = 1
passcodeConfiguration = configuration
self.passcodeWindowLevel = passcodeWindowLevel

passcodeLockVC = viewController
}

public convenience init(mainWindow window: UIWindow?, configuration: PasscodeLockConfigurationType) {
public convenience init(mainWindow window: UIWindow?, passcodeWindowLevel: UIWindowLevel = 2,
configuration: PasscodeLockConfigurationType)
{
let passcodeLockVC = PasscodeLockViewController(state: .EnterPasscode, configuration: configuration)

self.init(mainWindow: window, configuration: configuration, viewController: passcodeLockVC)
self.init(mainWindow: window, passcodeWindowLevel: passcodeWindowLevel,
configuration: configuration, viewController: passcodeLockVC)
}

// HACK: below function that handles not presenting the keyboard in case Passcode is presented
Expand All @@ -64,7 +70,7 @@ public class PasscodeLockPresenter {
guard !isPasscodePresented else { return }

isPasscodePresented = true
passcodeLockWindow.windowLevel = 2
passcodeLockWindow.windowLevel = passcodeWindowLevel

toggleKeyboardVisibility(hide: true)

Expand Down