Browse Source

FIX: Fixed an issue in currency settings where the checkmark wouldn't be in the correct preference

ADD: Added AUD, VEF, and ZAR fiats.
localNotifications^2
Marcos Rodriguez Vélez 6 years ago
parent
commit
f5704a9832
  1. 15
      currency.js
  2. 3
      models/fiatUnit.js
  3. 1
      screen/lnd/lndViewInvoice.js
  4. 7
      screen/settings/currency.js

15
currency.js

@ -78,11 +78,24 @@ function satoshiToLocalCurrency(satoshi) {
.toString(10);
b = parseFloat(b).toFixed(2);
const formatter = new Intl.NumberFormat(preferredFiatCurrency.locale, {
let formatter;
try {
formatter = new Intl.NumberFormat(preferredFiatCurrency.locale, {
style: 'currency',
currency: preferredFiatCurrency.endPointKey,
minimumFractionDigits: 2,
});
} catch (error) {
console.warn(error);
console.log(error);
formatter = new Intl.NumberFormat(FiatUnit.USD.locale, {
style: 'currency',
currency: preferredFiatCurrency.endPointKey,
minimumFractionDigits: 2,
});
}
return formatter.format(b);
}

3
models/fiatUnit.js

@ -1,5 +1,6 @@
export const FiatUnit = Object.freeze({
USD: { endPointKey: 'USD', symbol: '$', locale: 'en-US' },
AUD: { endPointKey: 'AUD', symbol: '$', locale: 'en-AU' },
EUR: { endPointKey: 'EUR', symbol: '€', locale: 'en-EN' },
GBP: { endPointKey: 'GBP', symbol: '£', locale: 'en-GB' },
RUB: { endPointKey: 'RUB', symbol: '₽', locale: 'ru-RU' },
@ -7,4 +8,6 @@ export const FiatUnit = Object.freeze({
CNY: { endPointKey: 'CNY', symbol: '¥', locale: 'zh-CN' },
JPY: { endPointKey: 'JPY', symbol: '¥', locale: 'ja-JP' },
INR: { endPointKey: 'INR', symbol: '₹', locale: 'hi-HN' },
VEF: { endPointKey: 'VEF', symbol: 'Bs.', locale: 'es-VE' },
ZAR: { endPointKey: 'ZAR', symbol: 'R', locale: 'en-ZA' },
});

1
screen/lnd/lndViewInvoice.js

@ -166,7 +166,6 @@ export default class LNDViewInvoice extends Component {
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
marginTop: 8,
paddingHorizontal: 16,

7
screen/settings/currency.js

@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { FlatList, TouchableOpacity, ActivityIndicator, View } from 'react-native';
import { SafeBlueArea, BlueNavigationStyle, BlueListItem } from '../../BlueComponents';
import { SafeBlueArea, BlueNavigationStyle, BlueListItem, BlueText, BlueCard } from '../../BlueComponents';
import PropTypes from 'prop-types';
import { Icon } from 'react-native-elements';
import { FiatUnit } from '../../models/fiatUnit';
@ -24,7 +24,7 @@ export default class Currency extends Component {
if (preferredCurrency === null) {
throw Error();
}
this.setState({ selectedCurrency: JSON.parse(preferredCurrency) });
this.setState({ selectedCurrency: preferredCurrency });
} catch (_error) {
this.setState({ selectedCurrency: FiatUnit.USD });
}
@ -68,6 +68,9 @@ export default class Currency extends Component {
extraData={this.state.data}
renderItem={this.renderItem}
/>
<BlueCard>
<BlueText>Prices are obtained from CoinDesk</BlueText>
</BlueCard>
</SafeBlueArea>
);
}

Loading…
Cancel
Save