Skip to content

Commit

Permalink
- This fixes #6, closes #20, fixes #21, fixes #22, fixes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
xornorik committed Jan 26, 2019
1 parent 38015eb commit b4bc4b5
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SVPinView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
29 changes: 16 additions & 13 deletions SVPinView/Example/Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions SVPinView/Example/SVPinViewExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = Xornorik;
TargetAttributes = {
B31AAF802089DD67004F5BE4 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1010;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.SafariKeychain = {
Expand Down Expand Up @@ -249,13 +250,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -306,13 +309,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -354,7 +359,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xornorik.SVPinView;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -371,7 +376,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xornorik.SVPinView;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SVPinViewExample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>SVPinViewExample.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../Source/Classes/SVPinView.swift"
timestampString = "570204688.883473"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "371"
endingLineNumber = "371"
landmarkName = "textFieldDidBeginEditing(_:)"
landmarkType = "7">
<Locations>
<Location
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SVPinView.SVPinView.textFieldDidBeginEditing(__C.UITextField) -&gt; ()"
moduleName = "SVPinView"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/srinivasvemuri/Documents/Srinivas/Libraries/SVPinView/SVPinView/Source/Classes/SVPinView.swift"
timestampString = "570199929.4264621"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "367"
endingLineNumber = "367"
offsetFromSymbolStart = "399">
</Location>
<Location
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "SVPinView.SVPinView.textFieldDidBeginEditing(__C.UITextField) -&gt; ()"
moduleName = "SVPinView"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/srinivasvemuri/Documents/Srinivas/Libraries/SVPinView/SVPinView/Source/Classes/SVPinView.swift"
timestampString = "570199929.4291379"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "367"
endingLineNumber = "367"
offsetFromSymbolStart = "2400">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
2 changes: 1 addition & 1 deletion SVPinView/Example/SVPinViewExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
13 changes: 8 additions & 5 deletions SVPinView/Example/SVPinViewExample/PinViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PinViewController: UIViewController {

func configurePinView() {

pinView.pinLength = 6
pinView.pinLength = 4
pinView.secureCharacter = "\u{25CF}"
pinView.interSpace = 10
pinView.textColor = UIColor.white
Expand All @@ -51,8 +51,8 @@ class PinViewController: UIViewController {
pinView.pinInputAccessoryView = { () -> UIView in
let doneToolbar: UIToolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: 320, height: 50))
doneToolbar.barStyle = UIBarStyle.default
let flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
let done: UIBarButtonItem = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.done, target: self, action: #selector(dismissKeyboard))
let flexSpace = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil)
let done: UIBarButtonItem = UIBarButtonItem(title: "Done", style: UIBarButtonItem.Style.done, target: self, action: #selector(dismissKeyboard))

var items = [UIBarButtonItem]()
items.append(flexSpace)
Expand All @@ -64,6 +64,9 @@ class PinViewController: UIViewController {
}()

pinView.didFinishCallback = didFinishEnteringPin(pin:)
pinView.didChangeCallback = { pin in
print("The entered pin is \(pin)")
}
}

@objc func dismissKeyboard() {
Expand Down Expand Up @@ -126,8 +129,8 @@ class PinViewController: UIViewController {

// MARK: Helper Functions
func showAlert(title:String, message:String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}

Expand Down
17 changes: 10 additions & 7 deletions SVPinView/Source/Classes/SVPinView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public class SVPinView: UIView {
loadView()
}

public override init(frame: CGRect) {
super.init(frame: frame)
loadView()
}

private func loadView() {
let podBundle = Bundle(for: SVPinView.self)
let nib = UINib(nibName: "SVPinView", bundle: podBundle)
Expand All @@ -82,6 +87,8 @@ public class SVPinView: UIView {
flowLayout.scrollDirection = .vertical //weird!!!
collectionView.isScrollEnabled = false

password = [String](repeating: "", count: pinLength)

self.addSubview(view)
view.frame = bounds
view.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, UIView.AutoresizingMask.flexibleHeight]
Expand Down Expand Up @@ -143,12 +150,8 @@ public class SVPinView: UIView {
// store text
let text = textField.text ?? ""
let passwordIndex = index - 1
if password.count > (passwordIndex) {
// delete if space
password[passwordIndex] = text == " " ? "" : text
} else {
password.append(text)
}
// delete if space
password[passwordIndex] = text == " " ? "" : text
validateAndSendCallback()
}

Expand Down Expand Up @@ -212,7 +215,7 @@ public class SVPinView: UIView {
public func getPin() -> String {

guard !isLoading else { return "" }

print("~~~~\(password)")
guard password.count == pinLength && password.joined().trimmingCharacters(in: CharacterSet(charactersIn: " ")).count == pinLength else {
return ""
}
Expand Down
Loading

0 comments on commit b4bc4b5

Please sign in to comment.