Skip to content

Commit

Permalink
Merge branch 'upgrade-swift5' into 'master'
Browse files Browse the repository at this point in the history
Upgrade to Swift 5 (Podspec v0.4.0)

- Upgrade Code to Swift 5
- Add `focus()` method

See merge request keepworks/KWVerificationCodeView!10
  • Loading branch information
pavankotesh committed Aug 9, 2019
2 parents 70a5267 + 479db92 commit 25377f4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
21 changes: 12 additions & 9 deletions Example/KWVerificationCodeView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,16 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
Expand All @@ -229,6 +229,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -270,7 +271,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/KWVerificationCodeView/KWVerificationCodeView.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -279,7 +280,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-KWVerificationCodeView_Example/Pods-KWVerificationCodeView_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
8A96BB52F0E82B4C4B2EC0C9 /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -373,6 +374,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -429,6 +431,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -487,7 +490,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "com.keepworks.KWVerificationCodeView-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand All @@ -505,7 +508,7 @@
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "com.keepworks.KWVerificationCodeView-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand All @@ -524,7 +527,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -538,7 +541,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
KWVerificationCodeView: f9ad2952977379d34752a61967dd9b4cca3c0cde
KWVerificationCodeView: ad0d493e30d203c45f21f3d7b6a4d2b64be53252

PODFILE CHECKSUM: c5456285278196ae1d72df7acbfd1db2fab11376

COCOAPODS: 1.5.3
COCOAPODS: 1.7.4
2 changes: 1 addition & 1 deletion KWVerificationCodeView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'KWVerificationCodeView'
s.version = '0.3.0'
s.version = '0.4.0'
s.summary = 'A verification code view with validation.'
s.description = 'A customisable verification code view with built in validation. Can be used for one time passwords (OTPs), email verification codes etc.'
s.homepage = 'https://github.com/keepworks/kwverificationcodeview'
Expand Down
8 changes: 6 additions & 2 deletions KWVerificationCodeView/Classes/KWVerificationCodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ public protocol KWVerificationCodeViewDelegate: class {
}

// MARK: - Public Methods
public func focus() {
textFieldViews[0].numberTextField.becomeFirstResponder()
}

public func getVerificationCode() -> String {
var verificationCode = ""
for textFieldView in textFieldViews {
Expand Down Expand Up @@ -215,7 +219,7 @@ public protocol KWVerificationCodeViewDelegate: class {
// MARK: - KWTextFieldDelegate
extension KWVerificationCodeView: KWTextFieldDelegate {
func moveToNext(_ textFieldView: KWTextFieldView) {
let validIndex = textFieldViews.index(of: textFieldView) == textFieldViews.count - 1 ? textFieldViews.index(of: textFieldView)! : textFieldViews.index(of: textFieldView)! + 1
let validIndex = textFieldViews.firstIndex(of: textFieldView) == textFieldViews.count - 1 ? textFieldViews.firstIndex(of: textFieldView)! : textFieldViews.firstIndex(of: textFieldView)! + 1
textFieldViews[validIndex].activate()
}

Expand All @@ -225,7 +229,7 @@ extension KWVerificationCodeView: KWTextFieldDelegate {
}

if textFieldView.code == " " {
let validIndex = textFieldViews.index(of: textFieldView)! == 0 ? 0 : textFieldViews.index(of: textFieldView)! - 1
let validIndex = textFieldViews.firstIndex(of: textFieldView)! == 0 ? 0 : textFieldViews.firstIndex(of: textFieldView)! - 1
textFieldViews[validIndex].activate()
textFieldViews[validIndex].reset()
}
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ Returns true when the entered code is valid.

getVerificationCode() -> String

Focus on First Text Field

focus()

Returns the validation code.

clear()
Expand Down

0 comments on commit 25377f4

Please sign in to comment.