Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRCL-2841 : Trading Network current value not shown on Settings #19

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ParticlesKit
import PlatformUI
import PlatformUIJedio
import JedioKit
import dydxStateManager

class SettingsLandingViewPresenter: SettingsViewPresenter {

Expand All @@ -31,13 +32,13 @@ class SettingsLandingViewPresenter: SettingsViewPresenter {
}
}

var localizerKeyLookup: [String: String] {
var localizerKeyLookup: [String: String]? {
switch self {
// extracting the localizer key lookup from the definition file reduces sources of truth for the key value mapping
case .language: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_language.json")
case .theme: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_theme.json")
// this one is hardcoded for now, there is no field input definition file for environment selection yet
case .env: return envLocalizerKeyLookup
case .env: return nil
case .colorPreference: return SettingsLandingViewPresenter.extractLocalizerKeyLookup(fromDefinitionFile: "settings_direction_color_preference.json")
}
}
Expand All @@ -58,21 +59,19 @@ class SettingsLandingViewPresenter: SettingsViewPresenter {
return dictionary
}

private static let envLocalizerKeyLookup: [String: String] = [
"dydxprotocol-testnet": "APP.HEADER.TESTNET",
"1": "APP.HEADER.MAINNET"
]

override func createOutputItem(output: FieldOutput) -> FieldOutputTextViewModel {
let textViewModel = super.createOutputItem(output: output)

guard let link = output.link,
let deepLink = DeepLink(rawValue: link),
let localizerKey = SettingsStore.shared?.value(forKey: deepLink.settingsStoreKey) as? String,
let displayTextKey = deepLink.localizerKeyLookup[localizerKey]
let localizerKey = SettingsStore.shared?.value(forKey: deepLink.settingsStoreKey) as? String
else { return textViewModel }

textViewModel.text = DataLocalizer.shared?.localize(path: displayTextKey, params: nil)
if let displayTextKey = deepLink.localizerKeyLookup?[localizerKey] {
textViewModel.text = DataLocalizer.shared?.localize(path: displayTextKey, params: nil)
} else if let env = AbacusStateManager.shared.availableEnvironments.first(where: { $0.type == localizerKey }) {
textViewModel.text = env.localizedString
}

return textViewModel
}
Expand Down
Loading