Add new section with translation and refactoring of the old code.

pull/2/head
Oleg Gordiichuk 7 years ago committed by Michael Scoff
parent 899499eda7
commit b283986c3a
  1. 4
      Trust/Core/Formatters/CurrencyFormatter.swift
  2. 4
      Trust/EtherClient/CoinMarket/CoinMarketClient.swift
  3. 1
      Trust/Localization/en.lproj/Localizable.strings
  4. 1
      Trust/Localization/es.lproj/Localizable.strings
  5. 1
      Trust/Localization/ru.lproj/Localizable.strings
  6. 2
      Trust/Settings/Coordinators/ExchangeRateCoordinator.swift
  7. 1
      Trust/Settings/Coordinators/SettingsCoordinator.swift
  8. 1
      Trust/Settings/Types/SettingsAction.swift
  9. 18
      Trust/Settings/ViewControllers/SettingsViewController.swift
  10. 4
      Trust/Settings/ViewModels/SettingsViewModel.swift
  11. 2
      Trust/Tokens/Types/TokensDataStore.swift

@ -5,10 +5,10 @@ import Foundation
class CurrencyFormatter {
static var formatter: NumberFormatter {
let formatter = NumberFormatter()
//TODO: use current locale when available this feature
formatter.locale = Locale(identifier: "en_US")
formatter.minimumFractionDigits = 2
formatter.maximumFractionDigits = 2
formatter.currencyCode = Config().currency.rawValue
formatter.numberStyle = .currency
return formatter
}

@ -3,10 +3,6 @@
import Foundation
import Moya
enum Currency: String {
case USD
}
enum TrustMarketService {
case prices(currency: Currency, symbols: [String])
}

@ -62,6 +62,7 @@
"settings.feedback.email.title" = "Trust Feedback";
"settings.navigation.title" = "Settings";
"settings.network.button.title" = "Network";
"settings.currency.button.title" = "Currency";
"settings.openSourceDevelopment.label.title" = "Open Source Development";
"settings.privacyPolicy.button.title" = "Privacy Policy";
"settings.pushNotifications.button.title" = "Push Notifications";

@ -62,6 +62,7 @@
"settings.feedback.email.title" = "Comentarios sobre Trust";
"settings.navigation.title" = "Configuración";
"settings.network.button.title" = "Red";
"settings.currency.button.title" = "Moneda";
"settings.openSourceDevelopment.label.title" = "Desarrollo en abierto";
"settings.privacyPolicy.button.title" = "Política de privacidad";
"settings.pushNotifications.button.title" = "Notificaciones Push";

@ -63,6 +63,7 @@
"settings.feedback.email.title" = "Trust - Обратная связь ";
"settings.navigation.title" = "Настройки";
"settings.network.button.title" = "Сеть";
"settings.currency.button.title" = "Валюта";
"settings.openSourceDevelopment.label.title" = "Разработка с открытым исходным кодом";
"settings.privacyPolicy.button.title" = "Политика Конфиденциальности";
"settings.pushNotifications.button.title" = "Push-Уведомления";

@ -19,7 +19,7 @@ class ExchangeRateCoordinator: NSObject {
}
func fetch() {
provider.request(.prices(currency: .USD, symbols:["ETH"])) { (result) in
provider.request(.prices(currency: Config().currency, symbols:["ETH"])) { (result) in
guard case .success(let response) = result else { return }
do {
guard let ticker = try response.map([CoinTicker].self, atKeyPath: "response", using: JSONDecoder()).first else { return }

@ -62,6 +62,7 @@ extension SettingsCoordinator: SettingsViewControllerDelegate {
case .wallets:
showAccounts()
case .RPCServer: break
case .currency: break
case .donate: break
case .pushNotifications(let enabled):
switch enabled {

@ -5,6 +5,7 @@ import Foundation
enum SettingsAction {
case wallets
case RPCServer
case currency
case donate(address: Address)
case pushNotifications(enabled: Bool)
}

@ -77,6 +77,24 @@ class SettingsViewController: FormViewController {
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.settings_server()
}
+++ Section(NSLocalizedString("settings.currency.button.title", value: "Currency", comment: ""))
<<< PushRow<String> {
$0.title = NSLocalizedString("settings.currency.button.title", value: "Currency", comment: "")
$0.options = viewModel.currency
$0.value = config.currency.rawValue
$0.displayValueFor = { value in
return value
}
}.onChange { row in
self.config.currency = Currency(rawValue: row.value ?? "USD")!
self.run(action: .currency)
}.onPresent { _, selectorController in
selectorController.enableDeselection = false
}.cellSetup { cell, _ in
cell.imageView?.image = R.image.settings_server()
}
<<< AppFormAppearance.button { button in
button.cellStyle = .value1

@ -20,6 +20,10 @@ struct SettingsViewModel {
RPCServer.ropsten,
]
}
var currency: [String] {
return Currency.allValues.map{$0.rawValue}.sorted()
}
var passcodeTitle: String {
switch BiometryAuthenticationType.current {

@ -154,7 +154,7 @@ class TokensDataStore {
func updatePrices() {
var symbols = objects.map { $0.symbol }
symbols.append("ETH")
provider.request(.prices(currency: .USD, symbols: symbols)) { result in
provider.request(.prices(currency: Config().currency, symbols: symbols)) { result in
guard case .success(let response) = result else { return }
do {
let tickers = try response.map([CoinTicker].self, atKeyPath: "response", using: JSONDecoder())

Loading…
Cancel
Save