/* global alert */ 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, }); } save = () => { this.setState({ isLoading: true }, async () => { this.state.URI = this.state.URI ? this.state.URI : ''; try { if (this.state.URI) { await LightningCustodianWallet.isValidNodeAddress(this.state.URI); // validating only if its not empty. empty means use default } await AsyncStorage.setItem(AppStorage.LNDHUB, this.state.URI); alert('Your changes have been saved successfully'); } catch (error) { alert('Not a valid LndHub URI'); console.log(error); } this.setState({ isLoading: false }); }); }; render() { return ( {loc.settings.lightning_settings_explain}