import React, { Component } from 'react'; import { View, Share, TextInput, KeyboardAvoidingView, Dimensions, ScrollView } from 'react-native'; import QRCode from 'react-native-qrcode-svg'; import bip21 from 'bip21'; import { SafeBlueArea, BlueCard, BlueButton, BlueNavigationStyle, BlueBitcoinAmount, BlueText, BlueCopyTextToClipboard, } from '../../BlueComponents'; import PropTypes from 'prop-types'; /** @type {AppStorage} */ let BlueApp = require('../../BlueApp'); let loc = require('../../loc'); const { width } = Dimensions.get('window'); export default class ReceiveAmount extends Component { static navigationOptions = ({ navigation }) => ({ ...BlueNavigationStyle(navigation, true), title: loc.receive.header, headerLeft: null, }); static propTypes = { navigation: PropTypes.shape({ state: PropTypes.shape({ params: PropTypes.shape({ address: PropTypes.string, }), }), }), }; constructor(props) { super(props); let address = props.navigation.state.params.address; this.state = { address: address, addressText: address, amount: undefined, label: undefined, amountSet: false, }; } determineSize = () => { if (width > 312) { return width - 48; } return 312; }; renderDefault() { return ( this.setState({ label: text })} placeholder={loc.receive.details.label} value={this.state.label || ''} numberOfLines={1} style={{ flex: 1, marginHorizontal: 8, minHeight: 33 }} editable={!this.state.isLoading} /> { this.setState({ amountSet: true, bip21: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), }); }} /> ); } renderWithSetAmount() { return ( {this.state.label} ); } render() { return ( this.setState({ amount: text })} disabled={this.state.amountSet} /> {this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()} {this.state.amountSet && ( { Share.share({ message: this.state.bip21, }); }} title={loc.receive.details.share} /> )} ); } }