This commit is contained in:
marcosrdz 2020-11-20 23:33:29 -05:00
parent 22dd7b0a46
commit dc3a79881a
12 changed files with 17 additions and 17 deletions

View file

@ -29,7 +29,7 @@ struct FiatUnit: Codable {
}
return WidgetDataStore(rate: rateString, lastUpdate: lastUpdatedString, rateDouble: rateDouble)
} else {
guard let rateKey = rateKey, let rateDouble = json[rateKey] as? Double, let lastUpdated = json["timestamp"] as? Int else {
guard let rateKey = rateKey, let rateDict = json[rateKey] as? [String: Any], let rateDouble = rateDict["price"] as? Double, let lastUpdated = json["timestamp"] as? Int else {
return nil
}
return WidgetDataStore(rate: String(rateDouble), lastUpdate: String(lastUpdated), rateDouble: rateDouble)

View file

@ -18,9 +18,9 @@
<key>locale</key>
<string>es-AR</string>
<key>dataSource</key>
<string>https://api.yadio.io/rate</string>
<string>https://api.yadio.io/json</string>
<key>rateKey</key>
<string>rate</string>
<string>ARS</string>
</dict>
<dict>
<key>endPointKey</key>
@ -286,9 +286,9 @@
<key>locale</key>
<string>es-VE</string>
<key>dataSource</key>
<string>https://api.yadio.io/rate</string>
<string>https://api.yadio.io/json</string>
<key>rateKey</key>
<string>btc</string>
<string>VES</string>
</dict>
<dict>
<key>endPointKey</key>

View file

@ -28,7 +28,7 @@ struct MarketView: View {
Spacer()
HStack(alignment: .center, spacing: 0, content: {
Text("Sats/Dollar").bold().lineLimit(1).font(Font.system(size:11, weight: .medium, design: .default)).foregroundColor(.textColor)
Text("Sats/\(WidgetAPI.getUserPreferredCurrency())").bold().lineLimit(1).font(Font.system(size:11, weight: .medium, design: .default)).foregroundColor(.textColor)
Spacer()
Text(marketData.sats == "..." ? "..." : marketData.sats).padding(EdgeInsets(top: 2, leading: 4, bottom: 2, trailing: 4)).lineLimit(1).minimumScaleFactor(0.1).foregroundColor(.widgetBackground).font(Font.system(size:11, weight: .semibold, design: .default)).background(Color(red: 0.97, green: 0.21, blue: 0.38)).overlay(
RoundedRectangle(cornerRadius: 4.0)

View file

@ -234,7 +234,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"currency": "Currency",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Los precios son obtenidos de CoinDesk y Yadio.",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -224,7 +224,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"currency": "Mata Uang",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Prices are obtained from CoinDesk and Yadio",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -224,7 +224,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"currency": "Valuta",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Prices are obtained from CoinDesk and Yadio",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -230,7 +230,7 @@
"about_sm_twitter": "Sledujte nás na Twitteri",
"advanced_options": "Pokročilé nastavenia",
"currency": "Mena",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Prices are obtained from CoinDesk and Yadio",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -224,7 +224,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"currency": "Valuta",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Prices are obtained from CoinDesk and Yadio",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -224,7 +224,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"currency": "Para Birimi",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Prices are obtained from CoinDesk and Yadio",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -233,7 +233,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"currency": "货币",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Prices are obtained from CoinDesk and Yadio",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -230,7 +230,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"currency": "貨幣",
"currency_source": "Prices are obtained from CoinDesk",
"currency_source": "Prices are obtained from CoinDesk and Yadio",
"default_desc": "When disabled, BlueWallet will immediately open the selected wallet at launch.",
"default_info": "Default info",
"default_title": "On Launch",

View file

@ -1,6 +1,6 @@
export const FiatUnit = Object.freeze({
USD: { endPointKey: 'USD', symbol: '$', locale: 'en-US' },
ARS: { endPointKey: 'ARS', symbol: '$', locale: 'es-AR', dataSource: 'https://api.yadio.io/rate', rateKey: 'rate' },
ARS: { endPointKey: 'ARS', symbol: '$', locale: 'es-AR', dataSource: 'https://api.yadio.io/json', rateKey: 'ARS' },
AUD: { endPointKey: 'AUD', symbol: '$', locale: 'en-AU' },
BRL: { endPointKey: 'BRL', symbol: 'R$', locale: 'pt-BR' },
CAD: { endPointKey: 'CAD', symbol: '$', locale: 'en-CA' },
@ -33,7 +33,7 @@ export const FiatUnit = Object.freeze({
TWD: { endPointKey: 'TWD', symbol: 'NT$', locale: 'zh-Hant-TW' },
UAH: { endPointKey: 'UAH', symbol: '₴', locale: 'uk-UA' },
VEF: { endPointKey: 'VEF', symbol: 'Bs.', locale: 'es-VE' },
VES: { endPointKey: 'VES', symbol: 'Bs.', locale: 'es-VE', dataSource: 'https://api.yadio.io/rate', rateKey: 'btc' },
VES: { endPointKey: 'VES', symbol: 'Bs.', locale: 'es-VE', dataSource: 'https://api.yadio.io/json', rateKey: 'VES' },
ZAR: { endPointKey: 'ZAR', symbol: 'R', locale: 'en-ZA' },
});
@ -61,7 +61,7 @@ export class FiatServerResponse {
rate = response => {
const json = typeof response.body === 'string' ? JSON.parse(response.body) : response.body;
if (this.fiatUnit.dataSource) {
return json[this.fiatUnit.rateKey] * 1;
return json[this.fiatUnit.rateKey].price * 1;
} else {
return json.bpi[this.fiatUnit.endPointKey].rate_float * 1;
}