Merge pull request #35 from TouchInstinct/fix/general

Fix/general
This commit is contained in:
Igor Kislyuk 2018-03-26 20:27:49 +03:00 committed by GitHub
commit 17561204c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 13 deletions

View File

@ -1,5 +1,8 @@
# Changelog
## 0.1.5
- **Update**: Passcode private configuration
## 0.1.4
- **Update**: Refactor PassCode

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKitAdditions"
s.version = "0.1.4"
s.version = "0.1.5"
s.summary = "iOS framework with a bunch of tools for rapid development"
s.homepage = "https://github.com/TouchInstinct/LeadKitAdditions"
s.license = "Apache License, Version 2.0"

View File

@ -77,7 +77,7 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
initialLoadView()
initialDotNumberConfiguration()
configureBackgroundNotifications()
showBiometricsRequestIfNeeded(with: biometricsAuthorizationHint)
showBiometricsRequestIfNeeded()
}
override open func viewWillAppear(_ animated: Bool) {
@ -149,12 +149,14 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
}
}
private func showBiometricsRequestIfNeeded(with description: String) {
private func showBiometricsRequestIfNeeded() {
guard viewModel.isBiometricsEnabled && viewModel.controllerType == .enter else {
return
}
viewModel.authenticateUsingBiometrics(with: description)
viewModel.authenticateUsingBiometrics(with: biometricsAuthorizationHint,
fallback: biometricsFallbackButtonTitle,
cancel: biometricsCancelButtonTitle)
}
private func resetUI() {
@ -166,10 +168,22 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
/// Returns prompt that appears on touch id system alert
open var biometricsAuthorizationHint: String {
assertionFailure("You should override this var: touchIdHint")
assertionFailure("You should override this \(#function)")
return ""
}
/// Returns prompt that appears on touch id system alert
open var biometricsFallbackButtonTitle: String? {
assertionFailure("You should override this \(#function)")
return nil
}
/// Returns prompt that appears on touch id system alert
open var biometricsCancelButtonTitle: String? {
assertionFailure("You should override this \(#function)")
return nil
}
/// Override to point certain images
open func imageFor(type: PinImageType) -> UIImage {
assertionFailure("You should override this method: imageFor(type: PinImageType)")
@ -183,9 +197,9 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
}
/// Override to change action title text
open func actionTitle(for passCodeControllerState: PassCodeControllerState) -> String {
open func actionTitle(for passCodeControllerState: PassCodeControllerState) -> NSAttributedString {
assertionFailure("You should override this method: actionTitle(for passCodeControllerState: PassCodeControllerState)")
return ""
return NSAttributedString(string: "")
}
// MARK: - Functions that you can override to customize your controller
@ -204,7 +218,7 @@ open class BasePassCodeViewController: UIViewController, ConfigurableController
/// Override to change UI for state
open func configureUI(for passCodeControllerState: PassCodeControllerState) {
resetDotsUI()
titleLabel?.text = actionTitle(for: passCodeControllerState)
titleLabel?.attributedText = actionTitle(for: passCodeControllerState)
}
// MARK: - ConfigurableController

View File

@ -100,8 +100,8 @@ open class BasePassCodeViewModel: BaseViewModel {
passCodeHolder.reset()
}
public func authenticateUsingBiometrics(with description: String) {
biometricsService.authenticateWithBiometrics(with: description) { [weak self] success, error in
public func authenticateUsingBiometrics(with description: String, fallback: String?, cancel: String?) {
biometricsService.authenticateWithBiometrics(with: description, fallback: fallback, cancel: cancel) { [weak self] success, error in
if success {
self?.authSucceed(.touchId)
} else {

View File

@ -38,12 +38,14 @@ public final class BiometricsService {
Initiates system biometrics authentication process
- parameters:
- description: prompt on the system alert that describes what for user should attach finger to device
- description: prompt on the system alert
- fallback: alternative action button title on system alert
- cancel: cancel button title on the system alert
- authHandler: callback, with parameter, indicates if user authenticate successfuly
*/
public func authenticateWithBiometrics(with description: String,
fallback fallbackTitle: String? = nil,
cancel cancelTitle: String? = nil,
fallback fallbackTitle: String?,
cancel cancelTitle: String?,
authHandler: @escaping BiometricsAuthHandler) {
if #available(iOS 10.0, *) {
laContext.localizedCancelTitle = cancelTitle