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' },
|
2019-06-05 20:32:23 +02:00
|
|
|
{ label: 'Afrikaans (AFR)', value: 'zar_afr' },
|
2019-02-19 22:07:47 +01:00
|
|
|
{ label: 'Chinese (ZH)', value: 'zh_cn' },
|
2019-09-20 13:20:28 +02:00
|
|
|
{ label: 'Chinese (TW)', value: 'zh_tw' },
|
2019-01-08 03:05:40 +01:00
|
|
|
{ label: 'Croatian (HR)', value: 'hr_hr' },
|
2019-09-20 13:20:28 +02:00
|
|
|
{ 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-11 21:23:59 +01:00
|
|
|
{ label: 'Español (ES)', value: 'es' },
|
2019-06-05 20:32:23 +02:00
|
|
|
{ label: 'Ελληνικά (EL)', value: 'el' },
|
2019-03-14 11:53:53 +01:00
|
|
|
{ label: 'Italiano (IT)', value: 'it' },
|
2019-03-15 00:05:44 +01:00
|
|
|
{ label: 'Suomi (FI)', value: 'fi_fi' },
|
2019-01-06 17:10:25 +01:00
|
|
|
{ label: 'Français (FR)', value: 'fr_fr' },
|
2019-02-14 00:20:10 +01:00
|
|
|
{ label: 'Indonesia (ID)', value: 'id_id' },
|
2019-06-19 22:45:33 +02:00
|
|
|
{ label: 'Magyar (HU)', value: 'hu_hu' },
|
2019-01-10 06:11:39 +01:00
|
|
|
{ label: '日本語 (JP)', value: 'jp_jp' },
|
2019-01-11 21:23:59 +01:00
|
|
|
{ label: 'Nederlands (NL)', value: 'nl_nl' },
|
2019-06-05 20:32:23 +02:00
|
|
|
{ label: 'Norsk (NB)', value: 'nb_no' },
|
|
|
|
{ label: 'Português (BR)', value: 'pt_br' },
|
|
|
|
{ label: 'Português (PT)', value: 'pt_pt' },
|
2019-01-06 17:46:31 +01:00
|
|
|
{ label: 'Русский', value: 'ru' },
|
2019-03-19 09:44:42 +01:00
|
|
|
{ label: 'Svenska (SE)', value: 'sv_se' },
|
2019-01-06 17:46:31 +01:00
|
|
|
{ label: 'Thai (TH)', value: 'th_th' },
|
2019-09-20 17:20:38 +02:00
|
|
|
{ label: 'Vietnamese (VN)', value: 'vi_vn' },
|
2019-01-06 17:46:31 +01:00
|
|
|
{ label: 'Українська', value: 'ua' },
|
2019-03-16 13:53:31 +01:00
|
|
|
{ label: 'Türkçe (TR)', value: 'tr_tr' },
|
2019-06-05 20:32:23 +02:00
|
|
|
{ label: 'Xhosa (XHO)', value: 'zar_xho' },
|
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.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-24 21:31:03 +01:00
|
|
|
<BlueText>When selecting a new language, restarting BlueWallet 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,
|
|
|
|
}),
|
|
|
|
};
|