From d53b4b84f61a1c4b906b6fb9693da6180e000f50 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Mon, 26 Mar 2018 18:49:42 +0300 Subject: [PATCH 1/3] Private outlet fix --- CHANGELOG.md | 3 +++ LeadKitAdditions.podspec | 2 +- .../PassCode/View/BasePassCodeViewController.swift | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01bd1ae..5830578 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.1.5 +- **Update**: Passcode private configuration + ## 0.1.4 - **Update**: Refactor PassCode diff --git a/LeadKitAdditions.podspec b/LeadKitAdditions.podspec index 486883e..3e0c50b 100644 --- a/LeadKitAdditions.podspec +++ b/LeadKitAdditions.podspec @@ -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" diff --git a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift index fa300c8..212a317 100644 --- a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift +++ b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift @@ -183,9 +183,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 +204,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 From 15ccb075b44c8cf3e14fa14025d50283daec8843 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Mon, 26 Mar 2018 20:21:37 +0300 Subject: [PATCH 2/3] Update --- .../View/BasePassCodeViewController.swift | 22 +++++++++++++++---- .../ViewModel/BasePassCodeViewModel.swift | 4 ++-- Sources/Services/BiometricsService.swift | 4 +++- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift index 212a317..97f7b8f 100644 --- a/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift +++ b/Sources/Controllers/PassCode/View/BasePassCodeViewController.swift @@ -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)") diff --git a/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift b/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift index 85006d4..55c4328 100644 --- a/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift +++ b/Sources/Controllers/PassCode/ViewModel/BasePassCodeViewModel.swift @@ -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 { diff --git a/Sources/Services/BiometricsService.swift b/Sources/Services/BiometricsService.swift index fa257e9..cea4147 100644 --- a/Sources/Services/BiometricsService.swift +++ b/Sources/Services/BiometricsService.swift @@ -38,7 +38,9 @@ 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, From 11df63f2f4c358eff13d148e6718596325b69a71 Mon Sep 17 00:00:00 2001 From: Igor Kislyuk Date: Mon, 26 Mar 2018 20:22:45 +0300 Subject: [PATCH 3/3] Update --- Sources/Services/BiometricsService.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Services/BiometricsService.swift b/Sources/Services/BiometricsService.swift index cea4147..38af4da 100644 --- a/Sources/Services/BiometricsService.swift +++ b/Sources/Services/BiometricsService.swift @@ -40,12 +40,12 @@ public final class BiometricsService { - parameters: - description: prompt on the system alert - fallback: alternative action button title on system alert - - cancel: cancel Button title on the 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