mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
Merge branch 'master' of github.com:BlueWallet/BlueWallet
This commit is contained in:
commit
a0e9c52773
@ -1127,6 +1127,7 @@ export class BlueBitcoinAmount extends Component {
|
||||
const amount = typeof this.props.amount === 'number' ? this.props.amount.toString() : this.props.amount;
|
||||
|
||||
return (
|
||||
<TouchableWithoutFeedback onPress={() => this.textInput.focus()}>
|
||||
<View>
|
||||
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
|
||||
<TextInput
|
||||
@ -1134,6 +1135,7 @@ export class BlueBitcoinAmount extends Component {
|
||||
onChangeText={text => this.props.onChangeText(text.replace(',', '.'))}
|
||||
placeholder="0"
|
||||
maxLength={10}
|
||||
ref={textInput => (this.textInput = textInput)}
|
||||
editable={!this.props.isLoading && !this.props.disabled}
|
||||
value={amount}
|
||||
placeholderTextColor={this.props.disabled ? '#99a0ab' : '#0f5cc0'}
|
||||
@ -1162,6 +1164,7 @@ export class BlueBitcoinAmount extends Component {
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
15
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);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.5.1</string>
|
||||
<string>3.5.2</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
@ -33,7 +33,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>201</string>
|
||||
<string>206</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
@ -126,7 +126,7 @@ strings.formatBalanceWithoutSuffix = (balance, toUnit) => {
|
||||
return currency.satoshiToLocalCurrency(balance);
|
||||
}
|
||||
}
|
||||
return balance;
|
||||
return balance.toString();
|
||||
};
|
||||
|
||||
module.exports = strings;
|
||||
|
@ -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' },
|
||||
});
|
||||
|
@ -166,7 +166,6 @@ export default class LNDViewInvoice extends Component {
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
marginTop: 8,
|
||||
paddingHorizontal: 16,
|
||||
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Picker } from 'react-native';
|
||||
import { BlueLoading, SafeBlueArea, BlueCard, BlueNavigationStyle } from '../../BlueComponents';
|
||||
import { FlatList, TouchableOpacity } from 'react-native';
|
||||
import { BlueLoading, BlueText, SafeBlueArea, BlueListItem, BlueCard, BlueNavigationStyle } from '../../BlueComponents';
|
||||
import PropTypes from 'prop-types';
|
||||
/** @type {AppStorage} */
|
||||
let BlueApp = require('../../BlueApp');
|
||||
import { Icon } from 'react-native-elements';
|
||||
let loc = require('../../loc');
|
||||
|
||||
export default class Language extends Component {
|
||||
@ -17,16 +16,47 @@ export default class Language extends Component {
|
||||
this.state = {
|
||||
isLoading: true,
|
||||
language: loc.getLanguage(),
|
||||
availableLanguages: [
|
||||
{ label: 'English', value: 'en' },
|
||||
{ label: 'Русский', value: 'ru' },
|
||||
{ label: 'Українська', value: 'ua' },
|
||||
{ label: 'Spanish', value: 'es' },
|
||||
{ label: 'Portuguese (BR)', value: 'pt_br' },
|
||||
{ label: 'Portuguese (PT)', value: 'pt_pt' },
|
||||
{ label: 'Deutsch (DE)', value: 'de_de' },
|
||||
{ label: 'Česky (CZ)', value: 'cs_cz' },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
storageIsEncrypted: await BlueApp.storageIsEncrypted(),
|
||||
});
|
||||
}
|
||||
|
||||
renderItem = ({ item }) => {
|
||||
return (
|
||||
<TouchableOpacity
|
||||
onPress={() => {
|
||||
console.log('setLanguage', item.value);
|
||||
loc.setLanguage(item.value);
|
||||
loc.saveLanguage(item.value);
|
||||
return this.setState({ language: item.value });
|
||||
}}
|
||||
>
|
||||
<BlueListItem
|
||||
title={item.label}
|
||||
{...(this.state.language === item.value
|
||||
? {
|
||||
rightIcon: <Icon name="check" type="font-awesome" color="#0c2550" />,
|
||||
}
|
||||
: { hideChevron: true })}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
if (this.state.isLoading) {
|
||||
return <BlueLoading />;
|
||||
@ -34,25 +64,15 @@ export default class Language extends Component {
|
||||
|
||||
return (
|
||||
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
||||
<FlatList
|
||||
style={{ flex: 1 }}
|
||||
keyExtractor={(_item, index) => `${index}`}
|
||||
data={this.state.availableLanguages}
|
||||
extraData={this.state.availableLanguages}
|
||||
renderItem={this.renderItem}
|
||||
/>
|
||||
<BlueCard>
|
||||
<Picker
|
||||
selectedValue={this.state.language}
|
||||
onValueChange={(itemValue, itemIndex) => {
|
||||
console.log('setLanguage', itemValue);
|
||||
loc.setLanguage(itemValue);
|
||||
loc.saveLanguage(itemValue);
|
||||
return this.setState({ language: itemValue });
|
||||
}}
|
||||
>
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="English" value="en" />
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="Русский" value="ru" />
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="Українська" value="ua" />
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="Spanish" value="es" />
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="Portuguese (BR)" value="pt_br" />
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="Portuguese (PT)" value="pt_pt" />
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="Deutsch (DE)" value="de_de" />
|
||||
<Picker.Item color={BlueApp.settings.foregroundColor} label="Česky (CZ)" value="cs_cz" />
|
||||
</Picker>
|
||||
<BlueText>When selecting a new language, restarting Blue Wallet may be required for the change to take effect.</BlueText>
|
||||
</BlueCard>
|
||||
</SafeBlueArea>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user