Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
Eco 1557 localization back buttons (#38)
Browse files Browse the repository at this point in the history
* a

* a

* a

* a
  • Loading branch information
Alon Genosar authored Jul 18, 2019
1 parent 5cc82df commit 7909d46
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -110,7 +90,6 @@ class SettingsViewController: UITableViewController {
}
}
}

extension SettingsViewController: Themed {
func applyTheme(_ theme: Theme) {
self.theme = theme
Expand Down
6 changes: 4 additions & 2 deletions KinEcosystem/KinEcosystem/extensions/String+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
7 changes: 7 additions & 0 deletions KinEcosystem/KinEcosystem/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
21 changes: 3 additions & 18 deletions KinEcosystemSampleApp/EcosystemSampleApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:.
}
}

2 changes: 1 addition & 1 deletion KinEcosystemSampleApp/EcosystemSampleApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<string>4</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 570bcbbb0fa47d5b85631e43b525d9fe7cb07a6a

COCOAPODS: 1.7.3
COCOAPODS: 1.7.4

0 comments on commit 7909d46

Please sign in to comment.