Skip to content

Commit a1b92c1

Browse files
Merge pull request #2 from keepworks/develop
Feature enhancement: Toggle user interaction on KWVerificationCodeView.
2 parents 4284076 + 2c0515f commit a1b92c1

7 files changed

Lines changed: 31 additions & 9 deletions

File tree

Example/KWVerificationCodeView.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@
306306
);
307307
runOnlyForDeploymentPostprocessing = 0;
308308
shellPath = /bin/sh;
309-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
309+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
310310
showEnvVarsInLog = 0;
311311
};
312312
C416736B908F6E6989465549 /* [CP] Check Pods Manifest.lock */ = {
@@ -321,7 +321,7 @@
321321
);
322322
runOnlyForDeploymentPostprocessing = 0;
323323
shellPath = /bin/sh;
324-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
324+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
325325
showEnvVarsInLog = 0;
326326
};
327327
CBA7B196B73A5116959ADE29 /* [CP] Embed Pods Frameworks */ = {

Example/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ SPEC CHECKSUMS:
1313

1414
PODFILE CHECKSUM: c5456285278196ae1d72df7acbfd1db2fab11376
1515

16-
COCOAPODS: 1.1.1
16+
COCOAPODS: 1.2.1

KWVerificationCodeView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'KWVerificationCodeView'
3-
s.version = '0.1.1'
3+
s.version = '0.1.2'
44
s.summary = 'A verification code view with validation.'
55
s.description = 'A customisable verification code view with built in validation. Can be used for one time passwords (OTPs), email verification codes etc.'
66
s.homepage = 'https://github.com/keepworks/kwverificationcodeview'

KWVerificationCodeView/Classes/KWTextFieldView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ protocol KWTextFieldDelegate: class {
7676
// MARK: - Variables
7777
private var keyboardAppearance = UIKeyboardAppearance.default
7878
weak var delegate: KWTextFieldDelegate?
79+
80+
var code: String? {
81+
return numberTextField.text
82+
}
7983

8084
// MARK: - Lifecycle
8185
override init(frame: CGRect) {

KWVerificationCodeView/Classes/KWVerificationCodeView.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,15 @@ public protocol KWVerificationCodeViewDelegate: class {
9494
@IBOutlet weak private var textFieldView2: KWTextFieldView!
9595
@IBOutlet weak private var textFieldView3: KWTextFieldView!
9696
@IBOutlet weak private var textFieldView4: KWTextFieldView!
97+
@IBOutlet var view: UIView!
9798

9899
// MARK: - Variables
100+
public var isTappable: Bool = false {
101+
didSet {
102+
view.isUserInteractionEnabled = isTappable
103+
}
104+
}
105+
99106
private var keyboardAppearance = UIKeyboardAppearance.default
100107
private var textFieldFont = UIFont.systemFont(ofSize: 24.0)
101108

@@ -163,9 +170,11 @@ extension KWVerificationCodeView: KWTextFieldDelegate {
163170
return
164171
}
165172

166-
let validIndex = textFieldViews.index(of: textFieldView)! == 0 ? 0 : textFieldViews.index(of: textFieldView)! - 1
167-
textFieldViews[validIndex].activate()
168-
textFieldViews[validIndex].reset()
173+
if textFieldView.code == " " {
174+
let validIndex = textFieldViews.index(of: textFieldView)! == 0 ? 0 : textFieldViews.index(of: textFieldView)! - 1
175+
textFieldViews[validIndex].activate()
176+
textFieldViews[validIndex].reset()
177+
}
169178
}
170179

171180
func didChangeCharacters() {

KWVerificationCodeView/Classes/KWVerificationCodeView.xib

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16C68" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11762"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12121"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<objects>
@@ -15,6 +15,7 @@
1515
<outlet property="textFieldView2" destination="jRf-YT-Rjh" id="Wb0-Dc-FHp"/>
1616
<outlet property="textFieldView3" destination="uqQ-2Z-1XV" id="YWY-Vf-pos"/>
1717
<outlet property="textFieldView4" destination="vt9-dd-ekk" id="t2F-rY-Rzz"/>
18+
<outlet property="view" destination="DUS-Hj-ChZ" id="Kvn-eL-Ma1"/>
1819
</connections>
1920
</placeholder>
2021
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ The properties which can be directly set in the *Attributes Inspector* and their
4949

5050
- `Dark Keyboard` - Default keyboard apperance
5151

52+
### Variables
53+
54+
The `KWVerificationCodeView` has the following variables:
55+
56+
isTappable: Bool
57+
58+
Makes the KWVerficationCodeView tappable. Default value is `false`
59+
5260
### Methods
5361

5462
The `KWVerificationCodeView` has the following methods:

0 commit comments

Comments
 (0)