|
@ -1,9 +1,8 @@ |
|
|
import React, { Component } from 'react'; |
|
|
import React, { Component } from 'react'; |
|
|
import { Picker } from 'react-native'; |
|
|
import { FlatList, TouchableOpacity } from 'react-native'; |
|
|
import { BlueLoading, SafeBlueArea, BlueCard, BlueNavigationStyle } from '../../BlueComponents'; |
|
|
import { BlueLoading, BlueText, SafeBlueArea, BlueListItem, BlueCard, BlueNavigationStyle } from '../../BlueComponents'; |
|
|
import PropTypes from 'prop-types'; |
|
|
import PropTypes from 'prop-types'; |
|
|
/** @type {AppStorage} */ |
|
|
import { Icon } from 'react-native-elements'; |
|
|
let BlueApp = require('../../BlueApp'); |
|
|
|
|
|
let loc = require('../../loc'); |
|
|
let loc = require('../../loc'); |
|
|
|
|
|
|
|
|
export default class Language extends Component { |
|
|
export default class Language extends Component { |
|
@ -17,16 +16,47 @@ export default class Language extends Component { |
|
|
this.state = { |
|
|
this.state = { |
|
|
isLoading: true, |
|
|
isLoading: true, |
|
|
language: loc.getLanguage(), |
|
|
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() { |
|
|
async componentDidMount() { |
|
|
this.setState({ |
|
|
this.setState({ |
|
|
isLoading: false, |
|
|
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() { |
|
|
render() { |
|
|
if (this.state.isLoading) { |
|
|
if (this.state.isLoading) { |
|
|
return <BlueLoading />; |
|
|
return <BlueLoading />; |
|
@ -34,25 +64,15 @@ export default class Language extends Component { |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}> |
|
|
<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> |
|
|
<BlueCard> |
|
|
<Picker |
|
|
<BlueText>When selecting a new language, restarting Blue Wallet may be required for the change to take effect.</BlueText> |
|
|
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> |
|
|
|
|
|
</BlueCard> |
|
|
</BlueCard> |
|
|
</SafeBlueArea> |
|
|
</SafeBlueArea> |
|
|
); |
|
|
); |
|
|