Skip to content

PasscodeLockLight is a lightweight version of SwiftPasscodeLock. It is suitable for the apps that need to send user input back to remote databases for password validation and then handle the returned results.

License

Notifications You must be signed in to change notification settings

phuanggh/PasscodeLockLight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to PasscodeLockLight

PasscodeLockLight is a lightweight version of SwiftPasscodeLock. It is suitable for the apps that need to send user input back to remote databases for password validation and then handle the returned results.

It removes the local persistent password repository and password validation of SwiftPasscodeLock, enabling developers to handle user input and returned results easily.

Features

iOS passcode lock view. Animates on wrong password.

demo image 1 demo image 2

Customisable passcode length, display title, description and image

demo image 3

CocoaPods Install

Add pod 'PasscodeLockLight' to your Podfile. "PasscodeLockLight" is the name of this library.

How to Use

Create a default passcode lock view

let passcodeVC = PasscodeLockViewController(state: .enter)
passcodeVC.delegate = self
present(passcodeVC, animated: true, completion: nil)

Create a custom passcode lock view

Create a class that conform to protocol PasscodeLockStateType Example:

struct  SIMLockState: PasscodeLockStateType {
    var title: String
    var description: String
    var passcodeLength: Int
    var cancelButtonTitle: String = "Cancel"
    var deleteButtonTitle: String = "Delete"
    var isCancellableAction: Bool = true
    var isTouchIDAllowed: Bool = false
    var shouldRequestTouchIDImmediately: Bool = false
    var image: UIImage? = nil
}

And inject it’s object to a PasscodeLockViewController instance Example:

let state =  SIMLockState(title: "Unlock PIN",
                          description: "1 attempt remaining",
                          passcodeLength: 4)
let passcodeVC = PasscodeLockViewController(state: state )
passcodeVC.delegate = self
present(passcodeVC, animated: true, completion: nil)

Handle user input

Let your view controller conform to PasscodeLockViewControllerDelegate And implement the following functions

func passcodeDidReceive(_ passcode: String, passcodeLockViewController: PasscodeLockViewController) {
// pass the passcode to your database for validation
// use passcodeLockViewController to dismiss the passcode view or animate passcode holder
}

func  passcodeLockDidDismiss(success: Bool) {
// handle the successful and failed cases of passcode unlock or Touch ID authentication
}

About

PasscodeLockLight is a lightweight version of SwiftPasscodeLock. It is suitable for the apps that need to send user input back to remote databases for password validation and then handle the returned results.

Resources

License

Stars

Watchers

Forks

Packages

No packages published