2018-09-30 10:31:09 +02:00
|
|
|
import React, { Component } from 'react';
|
2019-01-04 04:28:15 +01:00
|
|
|
import { FlatList, TouchableOpacity } from 'react-native';
|
|
|
|
import { BlueLoading, BlueText, SafeBlueArea, BlueListItem, BlueCard, BlueNavigationStyle } from '../../BlueComponents';
|
2018-09-30 10:31:09 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2019-01-04 04:28:15 +01:00
|
|
|
import { Icon } from 'react-native-elements';
|
2018-09-30 10:31:09 +02:00
|
|
|
let loc = require('../../loc');
|
|
|
|
|
|
|
|
export default class Language extends Component {
|
2018-10-29 23:11:48 +01:00
|
|
|
static navigationOptions = () => ({
|
|
|
|
...BlueNavigationStyle(),
|
|
|
|
title: loc.settings.language,
|
|
|
|
});
|
2018-09-30 10:31:09 +02:00
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isLoading: true,
|
|
|
|
language: loc.getLanguage(),
|
2019-01-04 04:28:15 +01:00
|
|
|
availableLanguages: [
|
|
|
|
{ label: 'English', value: 'en' },
|
|
|
|
{ label: 'Česky (CZ)', value: 'cs_cz' },
|
2019-01-06 17:46:31 +01:00
|
|
|
{ label: 'Danish (DK)', value: 'da_dk' },
|
|
|
|
{ label: 'Deutsch (DE)', value: 'de_de' },
|
2019-01-05 13:23:59 +01:00
|
|
|
{ label: 'Dutch (NL)', value: 'nl_nl' },
|
2019-01-06 17:10:25 +01:00
|
|
|
{ label: 'Français (FR)', value: 'fr_fr' },
|
2019-01-06 17:46:31 +01:00
|
|
|
{ label: 'Portuguese (BR)', value: 'pt_br' },
|
|
|
|
{ label: 'Portuguese (PT)', value: 'pt_pt' },
|
|
|
|
{ label: 'Русский', value: 'ru' },
|
|
|
|
{ label: 'Spanish', value: 'es' },
|
|
|
|
{ label: 'Thai (TH)', value: 'th_th' },
|
|
|
|
{ label: 'Українська', value: 'ua' },
|
2019-01-04 04:28:15 +01:00
|
|
|
],
|
2018-09-30 10:31:09 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount() {
|
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-01-04 04:28:15 +01:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-09-30 10:31:09 +02:00
|
|
|
render() {
|
|
|
|
if (this.state.isLoading) {
|
|
|
|
return <BlueLoading />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
2019-01-04 04:28:15 +01:00
|
|
|
<FlatList
|
|
|
|
style={{ flex: 1 }}
|
|
|
|
keyExtractor={(_item, index) => `${index}`}
|
|
|
|
data={this.state.availableLanguages}
|
|
|
|
extraData={this.state.availableLanguages}
|
|
|
|
renderItem={this.renderItem}
|
|
|
|
/>
|
2018-09-30 10:31:09 +02:00
|
|
|
<BlueCard>
|
2019-01-04 04:28:15 +01:00
|
|
|
<BlueText>When selecting a new language, restarting Blue Wallet may be required for the change to take effect.</BlueText>
|
2018-09-30 10:31:09 +02:00
|
|
|
</BlueCard>
|
|
|
|
</SafeBlueArea>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Language.propTypes = {
|
|
|
|
navigation: PropTypes.shape({
|
|
|
|
navigate: PropTypes.func,
|
|
|
|
goBack: PropTypes.func,
|
|
|
|
}),
|
|
|
|
};
|