2018-09-30 10:31:09 +02:00
|
|
|
import React, { Component } from 'react';
|
2019-05-19 21:49:42 +02:00
|
|
|
import { ScrollView, Switch, TouchableOpacity } from 'react-native';
|
|
|
|
import {
|
|
|
|
BlueText,
|
|
|
|
BlueCard,
|
|
|
|
BlueLoading,
|
|
|
|
SafeBlueArea,
|
|
|
|
BlueNavigationStyle,
|
|
|
|
BlueHeaderDefaultSub,
|
|
|
|
BlueListItem,
|
|
|
|
} from '../../BlueComponents';
|
|
|
|
import AsyncStorage from '@react-native-community/async-storage';
|
2018-09-30 10:31:09 +02:00
|
|
|
import PropTypes from 'prop-types';
|
2019-05-19 21:49:42 +02:00
|
|
|
import { AppStorage } from '../../class';
|
2018-09-30 10:31:09 +02:00
|
|
|
let loc = require('../../loc');
|
|
|
|
|
|
|
|
export default class Settings extends Component {
|
|
|
|
static navigationOptions = {
|
2018-10-29 23:11:48 +01:00
|
|
|
...BlueNavigationStyle,
|
2018-09-30 10:31:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isLoading: true,
|
|
|
|
language: loc.getLanguage(),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount() {
|
2019-05-19 21:49:42 +02:00
|
|
|
let advancedModeEnabled = !!(await AsyncStorage.getItem(AppStorage.ADVANCED_MODE_ENABLED));
|
2018-09-30 10:31:09 +02:00
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
2019-05-19 21:49:42 +02:00
|
|
|
advancedModeEnabled,
|
2018-09-30 10:31:09 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-05-19 21:49:42 +02:00
|
|
|
async onAdvancedModeSwitch(value) {
|
|
|
|
if (value) {
|
|
|
|
await AsyncStorage.setItem(AppStorage.ADVANCED_MODE_ENABLED, '1');
|
|
|
|
} else {
|
|
|
|
await AsyncStorage.removeItem(AppStorage.ADVANCED_MODE_ENABLED);
|
|
|
|
}
|
|
|
|
this.setState({ advancedModeEnabled: value });
|
|
|
|
}
|
|
|
|
|
2018-09-30 10:31:09 +02:00
|
|
|
render() {
|
|
|
|
if (this.state.isLoading) {
|
|
|
|
return <BlueLoading />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
|
|
|
<BlueHeaderDefaultSub leftText={loc.settings.header} rightComponent={null} />
|
|
|
|
<ScrollView maxHeight={450}>
|
2018-10-29 23:11:48 +01:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('EncryptStorage')}>
|
|
|
|
<BlueListItem title={loc.settings.encrypt_storage} />
|
|
|
|
</TouchableOpacity>
|
2018-11-04 22:21:07 +01:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('LightningSettings')}>
|
2019-01-11 20:02:25 +01:00
|
|
|
<BlueListItem title={loc.settings.lightning_settings} />
|
2018-11-04 22:21:07 +01:00
|
|
|
</TouchableOpacity>
|
2018-10-29 23:11:48 +01:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('Language')}>
|
2018-10-30 10:35:24 +01:00
|
|
|
<BlueListItem title={loc.settings.language} />
|
2018-10-29 23:11:48 +01:00
|
|
|
</TouchableOpacity>
|
2018-12-24 07:14:53 +01:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('Currency')}>
|
|
|
|
<BlueListItem title={loc.settings.currency} />
|
|
|
|
</TouchableOpacity>
|
2019-07-18 12:22:01 +02:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('ElectrumSettings')}>
|
|
|
|
<BlueListItem title={'Electrum server'} />
|
|
|
|
</TouchableOpacity>
|
2019-05-19 21:49:42 +02:00
|
|
|
<TouchableOpacity onPress={() => this.setState({ showAdvancedOptions: !this.state.showAdvancedOptions })}>
|
|
|
|
<BlueListItem title={loc.settings.advanced_options} />
|
|
|
|
</TouchableOpacity>
|
|
|
|
{this.state.showAdvancedOptions && (
|
|
|
|
<BlueCard>
|
|
|
|
<BlueText>{loc.settings.enable_advanced_mode}</BlueText>
|
|
|
|
<Switch value={this.state.advancedModeEnabled} onValueChange={value => this.onAdvancedModeSwitch(value)} />
|
|
|
|
</BlueCard>
|
|
|
|
)}
|
|
|
|
|
2018-10-29 23:11:48 +01:00
|
|
|
<TouchableOpacity onPress={() => this.props.navigation.navigate('About')}>
|
|
|
|
<BlueListItem title={loc.settings.about} />
|
|
|
|
</TouchableOpacity>
|
2018-09-30 10:31:09 +02:00
|
|
|
</ScrollView>
|
|
|
|
</SafeBlueArea>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings.propTypes = {
|
|
|
|
navigation: PropTypes.shape({
|
|
|
|
navigate: PropTypes.func,
|
|
|
|
goBack: PropTypes.func,
|
|
|
|
}),
|
|
|
|
};
|