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..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)") @@ -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 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..38af4da 100644 --- a/Sources/Services/BiometricsService.swift +++ b/Sources/Services/BiometricsService.swift @@ -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