diff --git a/GMERemittance/AppDelegate.swift b/GMERemittance/AppDelegate.swift index 41003033..54da6abe 100644 --- a/GMERemittance/AppDelegate.swift +++ b/GMERemittance/AppDelegate.swift @@ -269,7 +269,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // MARK: - BiometricAuthenticationViewControllerDelegate extension AppDelegate: BiometricAuthenticationViewControllerDelegate{ func viewController(_ viewController: BiometricAuthenticationViewController, informationTitleLabel titleLabel: UILabel) { - titleLabel.text = "bio_login_intro".localized() + titleLabel.text = "bio_login_intro_text".localized() } func didComplete(_ viewController: BiometricAuthenticationViewController) { diff --git a/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/View/BiometricAuthenticationViewController.swift b/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/View/BiometricAuthenticationViewController.swift index e0cc84d7..3d45e25e 100644 --- a/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/View/BiometricAuthenticationViewController.swift +++ b/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/View/BiometricAuthenticationViewController.swift @@ -10,125 +10,126 @@ import UIKit import LocalAuthentication enum BiometricAuthenticationPolicy { - case deviceOwnerAuthentication - case deviceOwnerAuthenticationWithBiometrics + case deviceOwnerAuthentication + case deviceOwnerAuthenticationWithBiometrics } enum BiometricAuthenticationError: Error { - case authenticationFailed - case userCancel - case userFallback - case biometryNotAvailable - case biometryNotEnrolled - case biometryLockout - case notBeConfigured - - var message: String { - let msg: String - - switch self { - case .authenticationFailed: - msg = "There was a problem verifying your identity." - case .userCancel: - msg = "You pressed cancel." - case .userFallback: - msg = "You pressed password." - case .biometryNotAvailable: - msg = "Face ID/Touch ID is not available." - case .biometryNotEnrolled: - msg = "Face ID/Touch ID is not set up." - case .biometryLockout: - msg = "Face ID/Touch ID is locked." - default: - msg = "Face ID/Touch ID may not be configured" - } - return msg + case authenticationFailed + case userCancel + case userFallback + case biometryNotAvailable + case biometryNotEnrolled + case biometryLockout + case notBeConfigured + + var message: String { + let msg: String + + switch self { + case .authenticationFailed: + msg = "There was a problem verifying your identity." + case .userCancel: + msg = "You pressed cancel." + case .userFallback: + msg = "You pressed password." + case .biometryNotAvailable: + msg = "Face ID/Touch ID is not available." + case .biometryNotEnrolled: + msg = "Face ID/Touch ID is not set up." + case .biometryLockout: + msg = "Face ID/Touch ID is locked." + default: + msg = "Face ID/Touch ID may not be configured" } + return msg + } } protocol BiometricAuthenticationViewControllerDelegate: class{ - func doSelectLocalAuthenticationPolicy(_ viewController: BiometricAuthenticationViewController) -> BiometricAuthenticationPolicy - - func viewController(_ viewController: BiometricAuthenticationViewController, informationTitleLabel titleLabel: UILabel ) - - func didComplete(_ viewController: BiometricAuthenticationViewController) - - func viewController(_ viewController: BiometricAuthenticationViewController, didFailWithError error: Error, errorMessage: String?) + func doSelectLocalAuthenticationPolicy(_ viewController: BiometricAuthenticationViewController) -> BiometricAuthenticationPolicy + + func viewController(_ viewController: BiometricAuthenticationViewController, informationTitleLabel titleLabel: UILabel ) + + func didComplete(_ viewController: BiometricAuthenticationViewController) + + func viewController(_ viewController: BiometricAuthenticationViewController, didFailWithError error: Error, errorMessage: String?) } extension BiometricAuthenticationViewControllerDelegate { - func doSelectLocalAuthenticationPolicy(_ viewController: BiometricAuthenticationViewController) -> BiometricAuthenticationPolicy{ - return .deviceOwnerAuthentication - } + func doSelectLocalAuthenticationPolicy(_ viewController: BiometricAuthenticationViewController) -> BiometricAuthenticationPolicy{ + return .deviceOwnerAuthentication + } } final class BiometricAuthenticationViewController: UIViewController, BiometricAuthenticationViewInterface { - - // MARK: Properties - var presenter: BiometricAuthenticationModuleInterface? - weak var delegate: BiometricAuthenticationViewControllerDelegate? - - private var isViewDidLoad = true - // MARK: IBOutlets - - @IBOutlet private weak var biometricAuthenticationImageButton: UIButton! - @IBOutlet private weak var informationLabel: UILabel! - - // MARK: VC's Life cycle - - override func viewDidLoad() { - super.viewDidLoad() - self.setup() + + // MARK: Properties + var presenter: BiometricAuthenticationModuleInterface? + weak var delegate: BiometricAuthenticationViewControllerDelegate? + + private var isViewDidLoad = true + // MARK: IBOutlets + + @IBOutlet private weak var biometricAuthenticationImageButton: UIButton! + @IBOutlet private weak var informationLabel: UILabel! + + // MARK: VC's Life cycle + + override func viewDidLoad() { + super.viewDidLoad() + self.setup() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + if self.isViewDidLoad{ + self.showAuthentication() + self.isViewDidLoad = false } - - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - - if self.isViewDidLoad{ - self.showAuthentication() - self.isViewDidLoad = false - } - } - - // MARK: IBActions - - @IBAction private func authenticationButtonTouch(_ sender: Any) { - self.showAuthentication() - } - - // MARK: Other Functions - - private func setup() { - // all setup should be done here - self.setUI() - self.delegate?.viewController(self, informationTitleLabel: self.informationLabel) - } - - private func setUI(){ - setBackground() - biometricAuthenticationImageButton.rounded() - } - - private func setBackground(){ - self.view.backgroundColor = AppConstants.themeRedColor - } - - private func showAuthentication(){ + } + + // MARK: IBActions + + @IBAction private func authenticationButtonTouch(_ sender: Any) { + self.showAuthentication() + } + + // MARK: Other Functions + + private func setup() { + // all setup should be done here + self.setUI() + self.delegate?.viewController(self, informationTitleLabel: self.informationLabel) + } + + private func setUI(){ + setBackground() + biometricAuthenticationImageButton.rounded() + biometricAuthenticationImageButton.setTitle("bio_press_button_title_text".localized(), for: .normal) + } + + private func setBackground(){ + self.view.backgroundColor = AppConstants.themeRedColor + } + + private func showAuthentication(){ + + guard + let isUseBiometricAuth = KeyChain.shared.get(key: .biometricAuth), + isUseBiometricAuth == "1" else { + let error = BiometricAuthenticationError.biometryNotAvailable - guard - let isUseBiometricAuth = KeyChain.shared.get(key: .biometricAuth), - isUseBiometricAuth == "1" else { - let error = BiometricAuthenticationError.biometryNotAvailable - - self.delegate?.viewController( - self, - didFailWithError: error, - errorMessage: error.message - ) - return - } - self.presenter?.showBiometricAuthentication() + self.delegate?.viewController( + self, + didFailWithError: error, + errorMessage: error.message + ) + return } + self.presenter?.showBiometricAuthentication() + } } diff --git a/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/Wireframe/BiometricAuthenticationWireframe.swift b/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/Wireframe/BiometricAuthenticationWireframe.swift index 55f3219b..860b574e 100644 --- a/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/Wireframe/BiometricAuthenticationWireframe.swift +++ b/GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/Wireframe/BiometricAuthenticationWireframe.swift @@ -38,7 +38,7 @@ extension BiometricAuthenticationWireframe: BiometricAuthenticationWireframeInpu let context = LAContext() var error: NSError? - let msg = "Confirm your fingerprint or face to authenticate." + let msg = "bio_message_title_text".localized() let vc = self.view as? BiometricAuthenticationViewController ?? BiometricAuthenticationViewController() diff --git a/GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotification.storyboard b/GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotification.storyboard index bda5b93e..868ee0c0 100644 --- a/GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotification.storyboard +++ b/GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotification.storyboard @@ -104,8 +104,8 @@ -