Skip to content

Commit

Permalink
- Added support for iOS 12
Browse files Browse the repository at this point in the history
- This closes #10, fixes #11, closes #12, fixes #13, closes #17
- Added oneTimeCode contentType option
- Added custom styling for active pinField
  • Loading branch information
xornorik committed Oct 28, 2018
1 parent 771fe6c commit f4986c7
Show file tree
Hide file tree
Showing 16 changed files with 315 additions and 309 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,32 @@ pinView.pinLength = 5
pinView.secureCharacter = "\u{25CF}"
pinView.interSpace = 5
pinView.textColor = UIColor.black
pinView.borderLineColor = UIColor.black
pinView.borderLineThickness = 1
pinView.shouldSecureText = true
pinView.style = .box

pinView.borderLineColor = UIColor.black
pinView.activeBorderLineColor = UIColor.lightGray
pinView.borderLineThickness = 1
pinView.activeBorderLineThickness = 3

pinView.font = UIFont.systemFont(ofSize: 15)
pinView.keyboardType = .phonePad
pinView.pinIinputAccessoryView = UIView()
pinView.placeholder = "******"
pinView.becomeFirstResponderAtIndex = 0
```
The `becomeFirstResponderAtIndex` property sets the pinField at the specified index as the first responder.
The `isContentTypeOneTimeCode` property sets the contentType of the first pinField to `.oneTimeCode` to leverage the iOS 12 feature where the passcode is directly fetched from the messages.

#### Styles
```swift
enum SVPinViewStyle : Int {
case none = 0
case underline
case box
case none = 0
case underline
case box
}
```
There are two inbuilt styes; `underline` & `box`. However, the *fieldBackgroundColor* & *fieldCornerRadius* properties can be used to create custom styles.
There are two inbuilt styes; `underline` & `box`. However, the *fieldBackgroundColor* & *fieldCornerRadius* properties along with *activeFieldBackgroundColor* & *activeCornerRadius* properties can be used to create custom styles.
```swift
pinView.style = .none
pinView.fieldBackgroundColor = UIColor.white
Expand All @@ -80,11 +84,16 @@ pinView.fieldCornerRadius = 0

### Callbacks

SVPinView has a *didFinish* callback, which gets executed after the pin has been entered. This is useful when a network call has to be made or for navigating to a different ViewController after the pin has been entered.

- **didFinishCallback**: Gets executed after the entire pin has been entered. This is useful when a network call has to be made or for navigating to a different ViewController after the pin has been entered.
- **didChangeCallback**: Gets executed when any of the pinFields have been changed. This gives additional control to the parent VC - Eg: if a submit button has to be enabled/disabled based on the pin validation.
```swift
pinView.didFinishCallback = { pin in
print("The pin entered is \(pin)")
print("The pin entered is \(pin)")
}
```
```swift
pinView.didChangeCallback = { pin in
submitButton.isEnabled = isValid(pin)
}
```

Expand Down
2 changes: 1 addition & 1 deletion SVPinView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |s|

s.name = "SVPinView"
s.version = "1.0.4"
s.version = "1.0.5"
s.summary = "SVPinView is a customisable library used for accepting alphanumeric pins or one-time passwords."

s.homepage = "https://github.com/xornorik/SVPinView"
Expand Down
6 changes: 3 additions & 3 deletions SVPinView/Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- SVPinView (1.0.2)
- SVPinView (1.0.5)

DEPENDENCIES:
- SVPinView (from `../../`)
Expand All @@ -9,8 +9,8 @@ EXTERNAL SOURCES:
:path: "../../"

SPEC CHECKSUMS:
SVPinView: 474daf1fb1bd31beb218e2c1f38a0e45c99a2542
SVPinView: 7b64d6ae30abbd46e3654bc876770ed07b074b06

PODFILE CHECKSUM: b9b57fc0cf7226021a70e6e19e5c127fb3eb5d37

COCOAPODS: 1.5.0
COCOAPODS: 1.5.3
4 changes: 2 additions & 2 deletions SVPinView/Example/Pods/Local Podspecs/SVPinView.podspec.json

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

6 changes: 3 additions & 3 deletions SVPinView/Example/Pods/Manifest.lock

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

270 changes: 141 additions & 129 deletions SVPinView/Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

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.

7 changes: 7 additions & 0 deletions SVPinView/Example/SVPinViewExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
02DB209E217C614000CE469C /* SVPinViewExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SVPinViewExample.entitlements; sourceTree = "<group>"; };
0D937BCAD12D8DEB5C39314F /* Pods-SVPinViewExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SVPinViewExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SVPinViewExample/Pods-SVPinViewExample.debug.xcconfig"; sourceTree = "<group>"; };
762AB709897C249EA93A3C59 /* Pods_SVPinViewExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SVPinViewExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B31AAF812089DD67004F5BE4 /* SVPinViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SVPinViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -70,6 +71,7 @@
B31AAF832089DD67004F5BE4 /* SVPinViewExample */ = {
isa = PBXGroup;
children = (
02DB209E217C614000CE469C /* SVPinViewExample.entitlements */,
B31AAF842089DD67004F5BE4 /* AppDelegate.swift */,
B31AAF862089DD67004F5BE4 /* PinViewController.swift */,
B31AAF882089DD67004F5BE4 /* Main.storyboard */,
Expand Down Expand Up @@ -123,6 +125,11 @@
B31AAF802089DD67004F5BE4 = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.SafariKeychain = {
enabled = 0;
};
};
};
};
};
Expand Down
2 changes: 0 additions & 2 deletions SVPinView/Example/SVPinViewExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

14 changes: 13 additions & 1 deletion SVPinView/Example/SVPinViewExample/PinViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ class PinViewController: UIViewController {
pinView.interSpace = 10
pinView.textColor = UIColor.white
pinView.borderLineColor = UIColor.white
pinView.activeBorderLineColor = UIColor.white
pinView.borderLineThickness = 1
pinView.shouldSecureText = true
pinView.allowsWhitespaces = false
pinView.style = .none
pinView.fieldBackgroundColor = UIColor.white.withAlphaComponent(0.3)
pinView.activeFieldBackgroundColor = UIColor.white.withAlphaComponent(0.5)
pinView.fieldCornerRadius = 15
pinView.activeFieldCornerRadius = 15
pinView.placeholder = "******"
pinView.becomeFirstResponderAtIndex = 0

pinView.font = UIFont.systemFont(ofSize: 15)
pinView.keyboardType = .phonePad
pinView.pinIinputAccessoryView = { () -> UIView in
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)
Expand Down Expand Up @@ -94,15 +98,23 @@ class PinViewController: UIViewController {
switch style {
case .none:
pinView.fieldBackgroundColor = UIColor.white.withAlphaComponent(0.3)
pinView.activeFieldBackgroundColor = UIColor.white.withAlphaComponent(0.5)
pinView.fieldCornerRadius = 15
pinView.activeFieldCornerRadius = 15
pinView.style = style
case .box:
pinView.activeBorderLineThickness = 4
pinView.fieldBackgroundColor = UIColor.clear
pinView.activeFieldBackgroundColor = UIColor.clear
pinView.fieldCornerRadius = 0
pinView.activeFieldCornerRadius = 0
pinView.style = style
case .underline:
pinView.activeBorderLineThickness = 4
pinView.fieldBackgroundColor = UIColor.clear
pinView.activeFieldBackgroundColor = UIColor.clear
pinView.fieldCornerRadius = 0
pinView.activeFieldCornerRadius = 0
pinView.style = style
}
clearPin()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?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/>
</plist>
Binary file modified SVPinView/Screenshots/IBInspectables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SVPinView/Screenshots/SVPinView.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f4986c7

Please sign in to comment.