Skip to content

Commit

Permalink
Add delegate for entry completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Fawxy committed Jun 18, 2019
1 parent e828b30 commit 8cf5cc1
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CBPinEntryView.podspec
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'CBPinEntryView'
s.version = '1.6.1'
s.version = '1.6.2'
s.summary = 'A view for entering arbitrary length pins, codes or passwords written in Swift 4.2. Supports one time codes.'

# This description is used to generate tags and improve search results.
4 changes: 4 additions & 0 deletions CBPinEntryView/Classes/CBPinEntryView.swift
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import UIKit

public protocol CBPinEntryViewDelegate: class {
func entryChanged(_ completed: Bool)
func entryCompleted(with entry: String?)
}

@IBDesignable open class CBPinEntryView: UIView {
@@ -293,6 +294,9 @@ extension CBPinEntryView: UITextFieldDelegate {
@objc func textfieldChanged(_ textField: UITextField) {
let complete: Bool = textField.text!.count == length
delegate?.entryChanged(complete)
if complete {
delegate?.entryCompleted(with: textField.text)
}
}

public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
Binary file modified Example/.DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion Example/CBPinEntryView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
1EF36EE374CAFC7442A03421 /* Pods-CBPinEntryView_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CBPinEntryView_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-CBPinEntryView_Example/Pods-CBPinEntryView_Example.release.xcconfig"; sourceTree = "<group>"; };
2164B9A14BA79EDDC9BA3A44 /* Pods-CBPinEntryView_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CBPinEntryView_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CBPinEntryView_Example/Pods-CBPinEntryView_Example.debug.xcconfig"; sourceTree = "<group>"; };
2EAA631FAD3805D87B03B812 /* Pods-CBPinEntryView_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CBPinEntryView_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CBPinEntryView_Tests/Pods-CBPinEntryView_Tests.debug.xcconfig"; sourceTree = "<group>"; };
5608D787ADD458FF492581EE /* CBPinEntryView.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CBPinEntryView.podspec; path = ../CBPinEntryView.podspec; sourceTree = "<group>"; };
5608D787ADD458FF492581EE /* CBPinEntryView.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CBPinEntryView.podspec; path = ../CBPinEntryView.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
607FACD01AFB9204008FA782 /* CBPinEntryView_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CBPinEntryView_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -228,6 +228,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);

0 comments on commit 8cf5cc1

Please sign in to comment.