Skip to content

Pin View for swift, with easy to configure keyboard and display view

Notifications You must be signed in to change notification settings

0xPr0xy/SwiftPin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SwiftPin

Features

This project aims at providing a PinView usable for capturing and displaying input of digits

Configuration Options:

  • pin length can be configured
  • keyboard button can be configured
  • pin digit view can be configured
  • pin digit view's dot view can be configured
  • keyboard layout can be configured

Classes

SwiftPin consists of 4 classes:

  • PinView
  • PinViewInput
  • PinViewOutput
  • Key

PinView

This view is receiving input from the PinViewInput and forwarding that input to PinViewOutput. it also sends PinEvents to the delegate

PinViewInput

This view is responsible for displaying a keyboard for input of the digits.

PinViewOutput

This view is responsible for displaying the amount of digits entered and the amount of digits still to enter.

Key

Definition of the keys we support for input. Currently this is numbers from 0 - 9, option and backspace

Installation

Cococapods

add pod:

pod 'SwiftPin', :git => 'https://github.com/0xPr0xy/SwiftPin.git'

and install with pod install

Usage

In your UIViewController xib or storyboard, Add a UIView and add constraints for size and positioning in it's super view. Then set the UIView class to PinView and it's module to SwiftPin and connect it to your ViewController:

@IBOutlet weak var pinView: PinView!

Import the library:

import PinView

Then set the UIViewController as delegate of PinView:

pinView.delegate = self

Implement the PinViewDelegate protocol:

extension UnlockViewController: PinViewDelegate {

    var clearInputOnCompleted: Bool { return false }

    func handle(_ event: PinEvent) {

    }
}

Implement the PinViewConfigurationProvider protocol:

extension UnlockViewController: PinViewConfigurationProvider {

    var pinInputViewConfiguration: PinInputViewConfiguration {
        return PinInputViewConfiguration.standard
    }
    var pinOutputViewConfiguration: PinOutputViewConfiguration {
        return PinOutputViewConfiguration.standard
    }
}

Screenshots

Standard

standard

Custom

custom

About

Pin View for swift, with easy to configure keyboard and display view

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published