import React, { Component } from 'react'; import { Dimensions, ActivityIndicator, View } from 'react-native'; import Ionicons from 'react-native-vector-icons/Ionicons'; import { BlueSpacing, BlueSpacing40, BlueFormInput, BlueButton, SafeBlueArea, BlueCard, BlueText, BlueFormLabel, BlueFormInputAddress, } from '../../BlueComponents'; import PropTypes from 'prop-types'; let EV = require('../../events'); /** @type {AppStorage} */ let BlueApp = require('../../BlueApp'); const { height, width } = Dimensions.get('window'); const aspectRatio = height / width; let isIpad; if (aspectRatio > 1.6) { isIpad = false; } else { isIpad = true; } export default class WalletDetails extends Component { static navigationOptions = { tabBarIcon: ({ tintColor, focused }) => ( ), }; constructor(props) { super(props); let address = props.navigation.state.params.address; /** @type {AbstractWallet} */ let wallet; for (let w of BlueApp.getWallets()) { if (w.getAddress() === address) { // found our wallet wallet = w; } } this.state = { confirmDelete: false, isLoading: true, wallet, }; } async componentDidMount() { this.setState({ isLoading: false, }); } async setLabel(text) { this.state.wallet.label = text; this.setState({ labelChanged: true, }); /* also, a hack to make screen update new typed text */ } render() { if (this.state.isLoading) { return ( ); } return ( {(() => { if (isIpad) { return ; } else { return ; } })()} Address: Type: Label: { this.setLabel(text); }} /> {(() => { if (this.state.confirmDelete) { return ( Are you sure? { BlueApp.deleteWallet(this.state.wallet); await BlueApp.saveToDisk(); EV(EV.enum.TRANSACTIONS_COUNT_CHANGED); EV(EV.enum.WALLETS_COUNT_CHANGED); this.props.navigation.goBack(); }} title="Yes, delete" /> { this.setState({ confirmDelete: false }); }} title="No, cancel" /> ); } else { return ( { this.setState({ confirmDelete: true }); }} title="Delete this wallet" /> {(() => { if (isIpad) { return ; } else { return ( this.props.navigation.navigate('WalletExport', { address: this.state.wallet.getAddress(), }) } title="Export / backup" /> ); } })()} ); } })()} ); } } WalletDetails.propTypes = { navigation: PropTypes.shape({ state: PropTypes.shape({ params: PropTypes.shape({ address: PropTypes.string, }), }), navigate: PropTypes.func, goBack: PropTypes.func, }), };