import React, { Component } from 'react';
import { AsyncStorage, View, TextInput, Linking } from 'react-native';
import { AppStorage } from '../../class';
import { BlueLoading, BlueSpacing20, BlueButton, SafeBlueArea, BlueCard, BlueNavigationStyle, BlueText } from '../../BlueComponents';
import PropTypes from 'prop-types';
import { Button } from 'react-native-elements';
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
let loc = require('../../loc');
export default class LightningSettings extends Component {
static navigationOptions = () => ({
...BlueNavigationStyle(),
title: loc.settings.lightning_settings,
});
constructor(props) {
super(props);
this.state = {
isLoading: true,
};
}
async componentDidMount() {
let URI = await AsyncStorage.getItem(AppStorage.LNDHUB);
this.setState({
isLoading: false,
URI,
defaultURI: new LightningCustodianWallet().getBaseURI(),
});
}
async save() {
this.state.URI = this.state.URI ? this.state.URI : '';
await AsyncStorage.setItem(AppStorage.LNDHUB, this.state.URI);
// set each lnd wallets and re-init api
for (/** @type {LightningCustodianWallet} */ let w of BlueApp.getWallets()) {
if (w.type === LightningCustodianWallet.type) {
w.setBaseURI(this.state.URI);
w.init();
console.log('inited', w.baseURI);
}
}
}
render() {
if (this.state.isLoading) {
return ;
}
return (
{loc.settings.lightning_settings_explain}
);
}
}
LightningSettings.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
goBack: PropTypes.func,
}),
};