Skip to content

Commit

Permalink
Update version release.
Browse files Browse the repository at this point in the history
  • Loading branch information
k-o-d-e-n committed Feb 12, 2017
1 parent bc6c082 commit 61f6b52
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
2 changes: 1 addition & 1 deletion PinCodeControl.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'PinCodeControl'
s.version = '0.1.0'
s.version = '0.2.0'
s.summary = 'QUIckControl subclass for enter pin code.'

# This description is used to generate tags and improve search results.
Expand Down
2 changes: 1 addition & 1 deletion PinCodeControl/PinCodeControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fileprivate class ValueApplier: NSObject {

// TODO: Remove limit on input only numbers. Create enum with types of control for enter secure code. Create base class SecureCodeControl with private class PinCodeControl.
@IBDesignable open class PinCodeControl: QUIckControl, UIKeyInput, UITextInputTraits {
/// preset states
public enum States {
public static let plain = QUICStateDescriptor(inverted: .filled)
public static let valid = QUICStateDescriptor(intersected: .valid)
Expand All @@ -59,7 +60,6 @@ fileprivate class ValueApplier: NSObject {

/// structure for initialize
public struct Parameters {
static let def = Parameters(length: 4, spaceSize: 15, sideSize: 20)
let length: Int
let spaceSize: CGFloat
let sideSize: CGFloat
Expand Down
46 changes: 31 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ it, simply add the following line to your Podfile:
```ruby
pod "QUIckControl"
```
```ruby
pod "PinCodeControl"
```

<h2>Manage states:</h2>

Expand Down Expand Up @@ -50,7 +47,7 @@ register(.valid, with: NSPredicate { control, _ in
Immediately, after registration you may setup values for this state using:
```swift
func setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, forInvertedState: UIControlState) {
func setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, forAllStatesContained: UIControlState)
func setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, forAllStatesContained: UIControlState)
func setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, for: UIControlState)
func setValue(_ value: Any?, forTarget: NSObject = default, forKeyPath: String, for: QUICStateDescriptor)
```
Expand Down Expand Up @@ -97,6 +94,10 @@ control.subscribe(on: QUICStateDescriptor(intersected: .valid), { button.enabled

QUIckControl subclass, which is used for input PIN code. It uses programming states for change visual view.

```ruby
pod "PinCodeControl"
```

Custom event and states:
```swift
extension UIControlEvents {
Expand All @@ -107,26 +108,41 @@ extension UIControlState {
public static var invalid = UIControlState(rawValue: 1 << 17)
public static var valid = UIControlState(rawValue: (1 << 18) | filled.rawValue)
}
// preset state descriptors
enum States {
static public let plain: QUICStateDescriptor
static public let valid: QUICStateDescriptor
static public let invalid: QUICStateDescriptor
static public let highlighted: QUICStateDescriptor
static public let disabled: QUICStateDescriptor
}
```

Main API
```swift
var code: String { get } // entered code
var filled: Bool { get set } // enabled, when all code entered
var valid: Bool { get set } // disabled, when entered code invalid
var validationBlock: ((_ code: String) -> Bool)? // custom validation
var shouldUseDefaultValidation: Bool // when enabled, for validate used default implementation with implementation in validationBlock, if defined
var filled: Bool { get } // enabled, when all code entered
var valid: Bool { get } // disabled, when entered code invalid
var validator: BlockPredicate<String>? // object for user validation pin code value
var shouldUseDefaultValidation: Bool // if true, then code equal strings, such as '1111', '1234', '9876' will be defined as invalid values
var filledItemColor: UIColor? // color for entered code element
var itemPath: UIBezierPath? // bezier path for code element
required init(codeLength: Int, sideSize: CGFloat, spaceSize: CGFloat) // main initializer

init(parameters: Parameters, frame: CGRect? = default) // main initializer
func clear() // clear all entered code

// methods for set parameters for each state
func setForValidState(_ fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat?)
func setForInvalidState(_ fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat?)
func setForPlainState(_ fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat?)
func setForHighlightedState(_ fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat?)
func setForDisabledState(_ fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat?)
func validate(_ pin: String) -> Bool // invoke validation process entered code
func setFillColor(fillColor: UIColor?, for state: QUICStateDescriptor)
func setBorderColor(borderColor: UIColor?, for state: QUICStateDescriptor)
func setBorderWidth(borderWidth: CGFloat, for state: QUICStateDescriptor)
func setForValidState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)
func setForInvalidState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)
func setForPlainState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)
func setForHighlightedState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)
func setForDisabledState(fillColor: UIColor?, borderColor: UIColor?, borderWidth: CGFloat)
// validation
func validate() -> Bool // perform validation current code value
func validate(_ pin: String) -> Bool // method for validation entered pin code. Declared for subclasses override.
```

<h2>Support information:</h2>
Expand Down

0 comments on commit 61f6b52

Please sign in to comment.