2019-12-24 23:44:33 -06:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2019-08-19 21:17:24 +01:00
|
|
|
import { ScrollView, View, Switch, TouchableOpacity } from 'react-native';
|
2019-05-19 20:49:42 +01:00
|
|
|
import {
|
|
|
|
BlueText,
|
2019-12-24 23:44:33 -06:00
|
|
|
BlueNavigationStyle,
|
2019-05-19 20:49:42 +01:00
|
|
|
BlueCard,
|
|
|
|
BlueLoading,
|
|
|
|
SafeBlueArea,
|
|
|
|
BlueHeaderDefaultSub,
|
|
|
|
BlueListItem,
|
|
|
|
} from '../../BlueComponents';
|
|
|
|
import { AppStorage } from '../../class';
|
2019-10-29 23:00:07 -04:00
|
|
|
import { useNavigation } from 'react-navigation-hooks';
|
2020-03-20 15:25:23 +00:00
|
|
|
const BlueApp: AppStorage = require('../../BlueApp');
|
2019-10-29 23:00:07 -04:00
|
|
|
const loc = require('../../loc');
|
2018-09-30 04:31:09 -04:00
|
|
|
|
2019-12-24 23:44:33 -06:00
|
|
|
const Settings = () => {
|
2019-10-29 23:00:07 -04:00
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
|
|
|
|
const [advancedModeEnabled, setAdvancedModeEnabled] = useState(false);
|
|
|
|
const { navigate } = useNavigation();
|
2018-09-30 04:31:09 -04:00
|
|
|
|
2019-10-29 23:00:07 -04:00
|
|
|
useEffect(() => {
|
|
|
|
(async () => {
|
2020-03-20 15:25:23 +00:00
|
|
|
setAdvancedModeEnabled(await BlueApp.isAdancedModeEnabled());
|
2019-10-29 23:00:07 -04:00
|
|
|
setIsLoading(false);
|
|
|
|
})();
|
|
|
|
});
|
2018-09-30 04:31:09 -04:00
|
|
|
|
2019-10-29 23:00:07 -04:00
|
|
|
const onAdvancedModeSwitch = async value => {
|
|
|
|
setAdvancedModeEnabled(value);
|
2020-03-20 15:25:23 +00:00
|
|
|
await BlueApp.setIsAdancedModeEnabled(value);
|
2019-10-29 23:00:07 -04:00
|
|
|
};
|
2019-05-19 20:49:42 +01:00
|
|
|
|
2019-10-29 23:00:07 -04:00
|
|
|
const onShowAdvancedOptions = () => {
|
|
|
|
setShowAdvancedOptions(!showAdvancedOptions);
|
|
|
|
};
|
|
|
|
|
|
|
|
return isLoading ? (
|
|
|
|
<BlueLoading />
|
|
|
|
) : (
|
|
|
|
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
|
|
|
|
<BlueHeaderDefaultSub leftText={loc.settings.header} rightComponent={null} />
|
|
|
|
<ScrollView>
|
|
|
|
{BlueApp.getWallets().length > 1 && (
|
|
|
|
<BlueListItem component={TouchableOpacity} onPress={() => navigate('DefaultView')} title="On Launch" />
|
|
|
|
)}
|
2020-03-20 15:25:23 +00:00
|
|
|
<BlueListItem title="Security" onPress={() => navigate('EncryptStorage')} component={TouchableOpacity} testID="SecurityButton" />
|
2019-10-29 23:00:07 -04:00
|
|
|
<BlueListItem title={loc.settings.lightning_settings} component={TouchableOpacity} onPress={() => navigate('LightningSettings')} />
|
|
|
|
<BlueListItem title={loc.settings.language} component={TouchableOpacity} onPress={() => navigate('Language')} />
|
|
|
|
<BlueListItem title={loc.settings.currency} component={TouchableOpacity} onPress={() => navigate('Currency')} />
|
|
|
|
<BlueListItem title={'Electrum server'} component={TouchableOpacity} onPress={() => navigate('ElectrumSettings')} />
|
|
|
|
<BlueListItem title={loc.settings.advanced_options} component={TouchableOpacity} onPress={onShowAdvancedOptions} />
|
|
|
|
{showAdvancedOptions && (
|
|
|
|
<BlueCard>
|
|
|
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
|
|
<BlueText>{loc.settings.enable_advanced_mode}</BlueText>
|
|
|
|
<Switch value={advancedModeEnabled} onValueChange={onAdvancedModeSwitch} />
|
|
|
|
</View>
|
|
|
|
</BlueCard>
|
|
|
|
)}
|
2018-09-30 04:31:09 -04:00
|
|
|
|
2020-03-19 15:51:35 +00:00
|
|
|
<BlueListItem title={loc.settings.about} component={TouchableOpacity} onPress={() => navigate('About')} testID="AboutButton" />
|
2019-10-29 23:00:07 -04:00
|
|
|
</ScrollView>
|
|
|
|
</SafeBlueArea>
|
|
|
|
);
|
|
|
|
};
|
2019-12-24 23:44:33 -06:00
|
|
|
Settings.navigationOptions = {
|
|
|
|
...BlueNavigationStyle,
|
|
|
|
};
|
|
|
|
export default Settings;
|