import React, { Component } from 'react';
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';
import PropTypes from 'prop-types';
import { AppStorage } from '../../class';
let loc = require('../../loc');
export default class Settings extends Component {
static navigationOptions = {
...BlueNavigationStyle,
};
constructor(props) {
super(props);
this.state = {
isLoading: true,
language: loc.getLanguage(),
};
}
async componentDidMount() {
let advancedModeEnabled = !!(await AsyncStorage.getItem(AppStorage.ADVANCED_MODE_ENABLED));
this.setState({
isLoading: false,
advancedModeEnabled,
});
}
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 });
}
render() {
if (this.state.isLoading) {
return ;
}
return (
this.props.navigation.navigate('EncryptStorage')}>
this.props.navigation.navigate('LightningSettings')}>
this.props.navigation.navigate('Language')}>
this.props.navigation.navigate('Currency')}>
this.setState({ showAdvancedOptions: !this.state.showAdvancedOptions })}>
{this.state.showAdvancedOptions && (
{loc.settings.enable_advanced_mode}
this.onAdvancedModeSwitch(value)} />
)}
this.props.navigation.navigate('About')}>
);
}
}
Settings.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
goBack: PropTypes.func,
}),
};