import React, { Component } from 'react'; import { Dimensions, ActivityIndicator, View } from 'react-native'; import QRCode from 'react-native-qrcode-svg'; import { BlueSpacing20, SafeBlueArea, BlueText, BlueNavigationStyle, BlueCopyTextToClipboard } from '../../BlueComponents'; import PropTypes from 'prop-types'; import Privacy from '../../Privacy'; /** @type {AppStorage} */ let BlueApp = require('../../BlueApp'); let loc = require('../../loc'); const { height, width } = Dimensions.get('window'); export default class WalletXpub extends Component { static navigationOptions = ({ navigation }) => ({ ...BlueNavigationStyle(navigation, true), title: loc.wallets.xpub.title, headerLeft: null, }); constructor(props) { super(props); let secret = props.navigation.state.params.secret; let wallet; for (let w of BlueApp.getWallets()) { if (w.getSecret() === secret) { // found our wallet wallet = w; } } this.state = { isLoading: true, wallet, xpub: wallet.getXpub(), xpubText: wallet.getXpub(), qrCodeHeight: height > width ? width - 40 : width / 2, }; } async componentDidMount() { Privacy.enableBlur(); this.setState({ isLoading: false, }); } componentWillUnmount() { Privacy.disableBlur(); } onLayout = () => { const { height } = Dimensions.get('window'); this.setState({ qrCodeHeight: height > width ? width - 40 : width / 2 }); }; render() { if (this.state.isLoading) { return ( ); } return ( {this.state.wallet.typeReadable} ); } } WalletXpub.propTypes = { navigation: PropTypes.shape({ state: PropTypes.shape({ params: PropTypes.shape({ secret: PropTypes.string, }), }), navigate: PropTypes.func, goBack: PropTypes.func, }), };