From 7909d4634c4f215b37ce39b9028f2f6bfd252f22 Mon Sep 17 00:00:00 2001 From: Alon Genosar Date: Thu, 18 Jul 2019 08:58:44 +0300 Subject: [PATCH] Eco 1557 localization back buttons (#38) * a * a * a * a --- .../notNibs/PasswordEntryViewController.swift | 7 ++++ .../View/notNibs/QRViewController.swift | 4 +++ .../View/notNibs/RestoreViewController.swift | 8 ++++- .../View/notNibs/SettingsViewController.swift | 33 ++++--------------- .../extensions/String+extensions.swift | 6 ++-- .../pt-BR.lproj/Localizable.strings | 7 ++++ .../EcosystemSampleApp/AppDelegate.swift | 21 ++---------- .../EcosystemSampleApp/Info.plist | 2 +- Podfile.lock | 2 +- 9 files changed, 40 insertions(+), 50 deletions(-) diff --git a/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/PasswordEntryViewController.swift b/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/PasswordEntryViewController.swift index 73a8272..00730db 100644 --- a/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/PasswordEntryViewController.swift +++ b/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/PasswordEntryViewController.swift @@ -106,6 +106,13 @@ class PasswordEntryViewController: BRViewController { passwordInput1.becomeFirstResponder() } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) +// navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back", +// in: KinBundle.ecosystem.rawValue, +// compatibleWith: nil), +// style: .plain) { [weak self] in self?.dismiss(animated: true, completion:nil) } + } override func willMove(toParent parent: UIViewController?) { super.willMove(toParent: parent) if parent == nil { diff --git a/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/QRViewController.swift b/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/QRViewController.swift index 13fcba9..56805ee 100644 --- a/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/QRViewController.swift +++ b/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/QRViewController.swift @@ -87,6 +87,10 @@ class QRViewController: BRViewController { } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) +// navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back", +// in: KinBundle.ecosystem.rawValue, +// compatibleWith: nil), +// style: .plain) { [weak self] in self?.dismiss(animated: true, completion: nil) } navigationController?.setNavigationBarHidden(false, animated: true) } diff --git a/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/RestoreViewController.swift b/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/RestoreViewController.swift index eea333f..12cd29b 100644 --- a/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/RestoreViewController.swift +++ b/KinEcosystem/KinEcosystem/BackupModule/View/notNibs/RestoreViewController.swift @@ -92,7 +92,13 @@ class RestoreViewController: BRViewController { passwordInput.becomeFirstResponder() } - + override func viewWillAppear(_ animated: Bool) { + +// navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back", +// in: KinBundle.ecosystem.rawValue, +// compatibleWith: nil), +// style: .plain) { [weak self] in self?.dismiss(animated: true, completion:nil) } + } @IBAction func passwordInputChanges(_ sender: PasswordEntryField) { if sender.entryState == .invalid { sender.entryState = .idle diff --git a/KinEcosystem/KinEcosystem/View/notNibs/SettingsViewController.swift b/KinEcosystem/KinEcosystem/View/notNibs/SettingsViewController.swift index 7a2aa39..521b807 100644 --- a/KinEcosystem/KinEcosystem/View/notNibs/SettingsViewController.swift +++ b/KinEcosystem/KinEcosystem/View/notNibs/SettingsViewController.swift @@ -38,63 +38,43 @@ class SettingsViewController: UITableViewController { private let brManager = BRManager(with: Kin.shared) let themeLinkBag = LinkBag() fileprivate var theme: Theme = .light - - private let rows: [Row] = [ - .backup, - .restore - ] - + private let rows: [Row] = [ .backup, .restore ] // MARK: Lifecycle - - override var title: String? { - set {} - get { - return "kinecosystem_settings_title".localized() - } - } - + override var title: String? { set {} get { return "kinecosystem_settings_title".localized() } } override func willMove(toParent parent: UIViewController?) { super.willMove(toParent: parent) if parent == nil { Kin.track { try SettingsBackButtonTapped(exitType: .xButton) } } } - override func viewDidLoad() { super.viewDidLoad() - Kin.track { try SettingsPageViewed() } tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") tableView.rowHeight = 54 tableView.separatorColor = .kinLightBlueGrey tableView.separatorInset = .zero tableView.tableFooterView = UIView() + navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(named: "back", in: KinBundle.ecosystem.rawValue,compatibleWith: nil),style: .plain) { [weak self] in + self?.navigationController?.popViewController(animated: true) + } } - override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none) } - // MARK: Table View - - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return rows.count - } - + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return rows.count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) let rowData = rows[indexPath.row] - cell.textLabel?.attributedText = rowData.title .styled(as: theme.subtitle14) .applyingTextAlignment(.left) cell.accessoryType = .disclosureIndicator cell.imageView?.image = UIImage(named: rowData.imageName, in: KinBundle.ecosystem.rawValue, compatibleWith: nil) - return cell } - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let phase = rows[indexPath.row].phase @@ -110,7 +90,6 @@ class SettingsViewController: UITableViewController { } } } - extension SettingsViewController: Themed { func applyTheme(_ theme: Theme) { self.theme = theme diff --git a/KinEcosystem/KinEcosystem/extensions/String+extensions.swift b/KinEcosystem/KinEcosystem/extensions/String+extensions.swift index 81647f5..41b6c87 100644 --- a/KinEcosystem/KinEcosystem/extensions/String+extensions.swift +++ b/KinEcosystem/KinEcosystem/extensions/String+extensions.swift @@ -16,8 +16,10 @@ public extension String { case invalidJSON } - func localized(_ args: CVarArg...) -> String { - return String(format: NSLocalizedString(self, tableName: nil, bundle: KinBundle.ecosystem.rawValue, value: "", comment: ""), arguments: args) + func localized(_ fallback:String = "") -> String { + let a = NSLocalizedString(self, tableName: nil, bundle: KinBundle.ecosystem.rawValue, value:"", comment: "") + let b = NSLocalizedString(self, tableName: "./en.lproj/Localizable", bundle: KinBundle.ecosystem.rawValue, value:fallback, comment: "") + return a != self ? a : b } func jwtJson() throws -> [String: Any] { diff --git a/KinEcosystem/KinEcosystem/pt-BR.lproj/Localizable.strings b/KinEcosystem/KinEcosystem/pt-BR.lproj/Localizable.strings index 08211b3..84b98a1 100644 --- a/KinEcosystem/KinEcosystem/pt-BR.lproj/Localizable.strings +++ b/KinEcosystem/KinEcosystem/pt-BR.lproj/Localizable.strings @@ -80,3 +80,10 @@ "kinecosystem_move_kin_accept_message" = "Para mandar Kin, %@ precisa ter acesso à informação da sua conta Kin (o endereço público) de %@."; "kinecosystem_move_kin_accept_button_title" = "Eu Concordo"; "kinecosystem_thisapp" = "este app"; + +"whats_kin" = "O que é Kin?"; +"kin_is_a_digital_currency" = "Kin é uma moeda digital que faz os seus aplicativos melhores ainda."; +"lets_go" = "Vamos lá"; +"what_are_you_in_the_mood_for" = "O que você está a fim de fazer?"; +"my_kin" = "Meu Kin"; +"balance" = "Saldo"; diff --git a/KinEcosystemSampleApp/EcosystemSampleApp/AppDelegate.swift b/KinEcosystemSampleApp/EcosystemSampleApp/AppDelegate.swift index dffab9d..704f3b1 100644 --- a/KinEcosystemSampleApp/EcosystemSampleApp/AppDelegate.swift +++ b/KinEcosystemSampleApp/EcosystemSampleApp/AppDelegate.swift @@ -9,46 +9,31 @@ import UIKit import HockeySDK import KinEcosystem -public func NSLocalizedString(_ key: String, tableName: String? = nil, bundle: Bundle = Bundle.main, value: String = "", comment: String) -> String { - let fallbackLanguage = "en" - guard let fallbackBundlePath = Bundle.main.path(forResource: fallbackLanguage, ofType: "lproj") else { return key } - guard let fallbackBundle = Bundle(path: fallbackBundlePath) else { return key } - let fallbackString = fallbackBundle.localizedString(forKey: key, value: comment, table: nil) - return Bundle.main.localizedString(forKey: key, value: fallbackString, table: nil) -} @UIApplicationMain - class AppDelegate: UIResponder, UIApplicationDelegate { - + class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - BITHockeyManager.shared().configure(withIdentifier: "b652ffb01ad64bdeabe07a50b2a8d8d1") + BITHockeyManager.shared().configure(withIdentifier: "90ae7adeee724658b6b9ec5448a09fb8") BITHockeyManager.shared().start() BITHockeyManager.shared().authenticator.authenticateInstallation() Kin.shared.setLogLevel(.verbose) return true } - func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. } - func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(_ application: UIApplication) { - // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + BITHockeyManager.shared().updateManager.checkForUpdate() } - func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } } - diff --git a/KinEcosystemSampleApp/EcosystemSampleApp/Info.plist b/KinEcosystemSampleApp/EcosystemSampleApp/Info.plist index 099dcee..a77f428 100644 --- a/KinEcosystemSampleApp/EcosystemSampleApp/Info.plist +++ b/KinEcosystemSampleApp/EcosystemSampleApp/Info.plist @@ -32,7 +32,7 @@ CFBundleVersion - 1 + 4 LSApplicationCategoryType LSRequiresIPhoneOS diff --git a/Podfile.lock b/Podfile.lock index 26628b9..d4151d9 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -72,4 +72,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 570bcbbb0fa47d5b85631e43b525d9fe7cb07a6a -COCOAPODS: 1.7.3 +COCOAPODS: 1.7.4