Skip to content

Commit 0edf6be

Browse files
author
Athul Sai
committed
Changed KWTextFieldDelegate method name from didEndEditing() to didChangeCharacters(), removed self keyword form many places and added Screenshots folder.
1 parent 2ab238b commit 0edf6be

7 files changed

Lines changed: 12 additions & 13 deletions

File tree

Example/KWVerificationCodeView/VerificationCodeViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class VerificationCodeViewController: UIViewController {
1818
// MARK: - Lifecycle
1919
override func viewDidLoad() {
2020
super.viewDidLoad()
21+
2122
submitButton.isEnabled = false
2223
verificationCodeView.delegate = self
2324
}
@@ -36,6 +37,6 @@ class VerificationCodeViewController: UIViewController {
3637
// MARK: - KWVerificationCodeViewDelegate
3738
extension VerificationCodeViewController: KWVerificationCodeViewDelegate {
3839
func didChangeVerificationCode() {
39-
self.submitButton.isEnabled = verificationCodeView.hasValidCode()
40+
submitButton.isEnabled = verificationCodeView.hasValidCode()
4041
}
4142
}

KWVerificationCodeView/Classes/KWTextFieldView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import UIKit
1111
protocol KWTextFieldDelegate: class {
1212
func moveToNext(_ textFieldView: KWTextFieldView)
1313
func moveToPrevious(_ textFieldView: KWTextFieldView, oldCode: String)
14-
func didEndEditing()
14+
func didChangeCharacters()
1515
}
1616

1717
@IBDesignable class KWTextFieldView: UIView {
@@ -22,7 +22,7 @@ protocol KWTextFieldDelegate: class {
2222
// MARK: - IBInspectables
2323
@IBInspectable var underlineColor: UIColor = UIColor.darkGray {
2424
didSet {
25-
underlineView.backgroundColor = self.underlineColor
25+
underlineView.backgroundColor = underlineColor
2626
}
2727
}
2828
@IBInspectable var underlineSelectedColor: UIColor = UIColor.blue
@@ -78,7 +78,7 @@ protocol KWTextFieldDelegate: class {
7878
}
7979

8080
fileprivate func updateUnderline() {
81-
underlineView.backgroundColor = numberTextField.text?.trim() != "" ? self.underlineSelectedColor : self.underlineColor
81+
underlineView.backgroundColor = numberTextField.text?.trim() != "" ? underlineSelectedColor : underlineColor
8282
}
8383
}
8484

@@ -96,7 +96,7 @@ extension KWTextFieldView: UITextFieldDelegate {
9696
numberTextField.text = " "
9797
}
9898

99-
delegate?.didEndEditing()
99+
delegate?.didChangeCharacters()
100100
updateUnderline()
101101

102102
return newString.characters.count <= type(of: self).maxCharactersLength

KWVerificationCodeView/Classes/KWVerificationCodeView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ public protocol KWVerificationCodeViewDelegate: class {
2121
@IBInspectable open var underlineColor: UIColor = UIColor.darkGray {
2222
didSet {
2323
for textFieldView in textFieldViews {
24-
textFieldView.underlineColor = self.underlineColor
24+
textFieldView.underlineColor = underlineColor
2525
}
2626
}
2727
}
2828
@IBInspectable var underlineSelectedColor: UIColor = UIColor.blue {
2929
didSet {
3030
for textFieldView in textFieldViews {
31-
textFieldView.underlineSelectedColor = self.underlineSelectedColor
31+
textFieldView.underlineSelectedColor = underlineSelectedColor
3232
}
3333
}
3434
}
@@ -109,7 +109,7 @@ extension KWVerificationCodeView: KWTextFieldDelegate {
109109
textFieldViews[validIndex].reset()
110110
}
111111

112-
func didEndEditing() {
112+
func didChangeCharacters() {
113113
delegate?.didChangeVerificationCode()
114114
}
115115
}

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
KWVerificationCodeView
2-
==================
1+
# KWVerificationCodeView
32

4-
[![CI Status](http://img.shields.io/travis/Athul Sai/KWVerificationCodeView.svg?style=flat)](https://travis-ci.org/Athul Sai/KWVerificationCodeView)
53
[![Version](https://img.shields.io/cocoapods/v/KWVerificationCodeView.svg?style=flat)](http://cocoapods.org/pods/KWVerificationCodeView)
64
[![License](https://img.shields.io/cocoapods/l/KWVerificationCodeView.svg?style=flat)](http://cocoapods.org/pods/KWVerificationCodeView)
75
[![Platform](https://img.shields.io/cocoapods/p/KWVerificationCodeView.svg?style=flat)](http://cocoapods.org/pods/KWVerificationCodeView)
86

97
A customisable verification code view with built in validation. Can be used for one time passwords (OTPs), email verification codes etc.
108

11-
![Screenshot](Example/KWVerificationCodeView.gif)
9+
![Screenshot](Screenshots/KWVerificationCodeView.gif)
1210

1311
## Example
1412

@@ -30,7 +28,7 @@ pod "KWVerificationCodeView"
3028

3129
Add a `UIView` in your *Storyboard* and change the class to `KWVerificationCodeView`. You can set the properties in the *Attributes Inspector* and see a live preview:
3230

33-
![Interface Builder Screenshot](Example/interfacebuilder.png)
31+
![Interface Builder Screenshot](Screenshots/interfacebuilder.png)
3432

3533
It is possile to set the default and selected colors of the underline in the *Storyboard*.
3634

0 commit comments

Comments
 (0)