Browse Source

ready for multi language

pull/1/head
james 5 years ago
parent
commit
7cfaad43ed
  1. 2
      GMERemittance/AppDelegate.swift
  2. 207
      GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/View/BiometricAuthenticationViewController.swift
  3. 2
      GMERemittance/Module/BiometricAuthModules/BiometricAuthentication/User Interface/Wireframe/BiometricAuthenticationWireframe.swift
  4. 7
      GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotification.storyboard
  5. 92
      GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotificationViewController.swift
  6. 2
      GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift
  7. 4
      GMERemittance/SideMenu/SettingViewController.swift
  8. 14
      en.lproj/Localizable.strings

2
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) {

207
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()
}
}

2
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()

7
GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotification.storyboard

@ -104,8 +104,8 @@
</view>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="(manual: Settings -&gt; Use FaceID &amp; TouchID)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xFc-vx-98G">
<rect key="frame" x="59" y="424.5" width="257.5" height="17"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="(Manual: Settings -&gt; Use FaceID &amp; TouchID)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xFc-vx-98G">
<rect key="frame" x="59.5" y="424.5" width="256.5" height="17"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="14"/>
<color key="textColor" red="0.18823529410000001" green="0.24313725489999999" blue="0.62352941179999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
@ -128,6 +128,9 @@
<viewLayoutGuide key="safeArea" id="n22-XI-gDD"/>
</view>
<connections>
<outlet property="contentLabel" destination="sEb-0Y-7MN" id="Ept-ly-T9u"/>
<outlet property="manualLabel" destination="xFc-vx-98G" id="dmg-iB-AHt"/>
<outlet property="titleLabel" destination="FJX-hI-Ewa" id="zwL-G4-yRQ"/>
<outlet property="useBiometricAuthButton" destination="H6Q-aV-Mdd" id="2GS-d3-GuJ"/>
<outlet property="usePasswordButton" destination="X1c-21-gtS" id="FeD-RW-RZN"/>
</connections>

92
GMERemittance/Module/BiometricAuthModules/BiometricAuthenticationNotification/User Interface/View/BiometricAuthenticationNotificationViewController.swift

@ -9,50 +9,64 @@
import UIKit
class BiometricAuthenticationNotificationViewController: UIViewController {
// MARK: Properties
var presenter: BiometricAuthenticationNotificationModuleInterface?
// MARK: IBOutlets
@IBOutlet weak var useBiometricAuthButton: UIButton!
@IBOutlet weak var usePasswordButton: UIButton!
// MARK: VC's Life cycle
override func viewDidLoad() {
super.viewDidLoad()
self.setup()
}
// MARK: IBActions
@IBAction func touchUseBiometricAuth(_ sender: UIButton) {
BiometricAuthenticationWireframe().showBiometricAuthentication() { error in
if error != nil {
KeyChain.shared.save(data: "0", key: .biometricAuth)
} else {
KeyChain.shared.save(data: "1", key: .biometricAuth)
}
self.dismiss(animated: true, completion: nil)
}
}
@IBAction func touchUsePassword(_ sender: UIButton) {
// MARK: Properties
var presenter: BiometricAuthenticationNotificationModuleInterface?
// MARK: IBOutlets
@IBOutlet weak var useBiometricAuthButton: UIButton!
@IBOutlet weak var usePasswordButton: UIButton!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var contentLabel: UILabel!
@IBOutlet weak var manualLabel: UILabel!
// MARK: VC's Life cycle
override func viewDidLoad() {
super.viewDidLoad()
self.setup()
}
// MARK: IBActions
@IBAction func touchUseBiometricAuth(_ sender: UIButton) {
BiometricAuthenticationWireframe().showBiometricAuthentication() { error in
if error != nil {
KeyChain.shared.save(data: "0", key: .biometricAuth)
self.dismiss(animated: true, completion: nil)
} else {
KeyChain.shared.save(data: "1", key: .biometricAuth)
}
self.dismiss(animated: true, completion: nil)
}
// MARK: Other Functions
}
@IBAction func touchUsePassword(_ sender: UIButton) {
KeyChain.shared.save(data: "0", key: .biometricAuth)
self.dismiss(animated: true, completion: nil)
}
// MARK: Other Functions
private func setup() {
// all setup should be done here
useBiometricAuthButton.rounded()
usePasswordButton.rounded()
private func setup() {
// all setup should be done here
useBiometricAuthButton.rounded()
usePasswordButton.rounded()
}
setMultiLanguage()
}
private func setMultiLanguage() {
titleLabel.text = "biometric_noti_title_text".localized()
contentLabel.text = "biometric_noti_content_text".localized()
manualLabel.text = "biometric_noti_manual_text".localized()
usePasswordButton.setTitle("biometric_noti_biometric_use_button_text", for: .normal)
usePasswordButton.setTitle("biometric_noti_password_use_button_text", for: .normal)
}
}
// MARK: BiometricAuthenticationNotificationViewInterface
extension BiometricAuthenticationNotificationViewController: BiometricAuthenticationNotificationViewInterface {
}

2
GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift

@ -401,7 +401,7 @@ extension SendMoneyVerificationViewController: TransKeyViewDelegate {
extension SendMoneyVerificationViewController: BiometricAuthenticationViewControllerDelegate {
func viewController(_ viewController: BiometricAuthenticationViewController, informationTitleLabel titleLabel: UILabel) {
titleLabel.text = "Please enter authentication information for Remittance"
titleLabel.text = "bio_sendmoney_intro_text".localized()
}
func didComplete(_ viewController: BiometricAuthenticationViewController) {

4
GMERemittance/SideMenu/SettingViewController.swift

@ -106,13 +106,13 @@ class SettingViewController: UIViewController {
self.changePasswordButton.setTitle("change_password_text".localized(), for: .normal)
self.settingButton.setTitle("language_text".localized(), for: .normal)
self.settingLabel.text = "setting_text".localized()
useBiometricAuthLabel.text = "use_biometric_authentication".localized()
useBiometricAuthLabel.text = "use_biometric_authentication_text".localized()
}
private func configureLanguage() {
self.changePasswordButton.setTitle("change_password_text".localized(), for: .normal)
self.settingButton.setTitle("language_text".localized(), for: .normal)
useBiometricAuthLabel.text = "use_biometric_authentication".localized()
useBiometricAuthLabel.text = "use_biometric_authentication_text".localized()
}
func setupLanguages() {

14
en.lproj/Localizable.strings

@ -415,8 +415,18 @@
"referral_code_text" = "Referral Code (Optional)";
// Biometric authenticaton
"use_biometric_authentication" = "Use TouchID & FaceID";
"bio_login_intro" = "Please enter authentication information for login";
"use_biometric_authentication_text" = "Use FaceID & TouchID";
"bio_login_intro_text" = "Please enter authentication information for login";
"bio_sendmoney_intro_text" = "Please enter authentication information for Remittance";
"bio_message_title_text" = "Confirm your FaceID or TouchID to authenticate.";
"bio_press_button_title_text" = ">> Press to authenticate";
// Biometric authentication notification
"biometric_noti_title_text" = "If use FaceID & TouchID, can quickly and securely use app";
"biometric_noti_content_text" = "Remember, only registered users with FaceID & TouchID can use these app.";
"biometric_noti_manual_text" = "(Manual: Settings -> Use FaceID & TouchID)";
"biometric_noti_biometric_use_button_text" = "Use FaceID & TouchID";
"biometric_noti_password_use_button_text" = "Continue only using password";
// RewardGroup
"reward_group_title_text" = "Reward";

Loading…
Cancel
Save