import React, { Component } from 'react'; import { TextInput, FlatList, ScrollView, Linking, TouchableOpacity, Clipboard, StyleSheet, TouchableWithoutFeedback, Keyboard, Text, View, } from 'react-native'; import { BlueNavigationStyle, SafeBlueArea, BlueCard, BlueText } from '../../BlueComponents'; import PropTypes from 'prop-types'; import Privacy from '../../Privacy'; import { BitcoinUnit } from '../../models/bitcoinUnits'; /** @type {AppStorage} */ const BlueApp = require('../../BlueApp'); const loc = require('../../loc'); const currency = require('../../currency'); export default class SendCreate extends Component { static navigationOptions = () => ({ ...BlueNavigationStyle, title: loc.send.create.details, }); constructor(props) { super(props); console.log('send/create constructor'); this.state = { isLoading: false, fee: props.navigation.getParam('fee'), recipients: props.navigation.getParam('recipients'), memo: props.navigation.getParam('memo') || '', size: Math.round(props.navigation.getParam('tx').length / 2), tx: props.navigation.getParam('tx'), satoshiPerByte: props.navigation.getParam('satoshiPerByte'), wallet: props.navigation.getParam('wallet'), feeSatoshi: props.navigation.getParam('feeSatoshi'), }; } async componentDidMount() { Privacy.enableBlur(); console.log('send/create - componentDidMount'); } componentWillUnmount() { Privacy.disableBlur(); } _renderItem = ({ index, item }) => { return ( <> {loc.send.create.to} {item.address} {loc.send.create.amount} {item.amount === BitcoinUnit.MAX ? currency.satoshiToBTC(this.state.wallet.getBalance()) - this.state.fee : item.amount || currency.satoshiToBTC(item.value)}{' '} {BitcoinUnit.BTC} {this.state.recipients.length > 1 && ( {index + 1} of {this.state.recipients.length} )} ); }; renderSeparator = () => { return ; }; render() { return ( {loc.send.create.this_is_hex} Clipboard.setString(this.state.tx)}> Copy and broadcast later Linking.openURL('https://coinb.in/?verify=' + this.state.tx)}> Verify on coinb.in 1} extraData={this.state.recipients} data={this.state.recipients} renderItem={this._renderItem} keyExtractor={(_item, index) => `${index}`} ItemSeparatorComponent={this.renderSeparator} /> {loc.send.create.fee} {this.state.fee} {BitcoinUnit.BTC} {loc.send.create.tx_size} {this.state.size} bytes {loc.send.create.satoshi_per_byte} {this.state.satoshiPerByte} Sat/B {this.state.memo.length > 0 && ( <> {loc.send.create.memo} {this.state.memo} )} ); } } const styles = StyleSheet.create({ transactionDetailsTitle: { color: '#0c2550', fontWeight: '500', fontSize: 17, marginBottom: 2, }, transactionDetailsSubtitle: { color: '#9aa0aa', fontWeight: '500', fontSize: 15, marginBottom: 20, }, }); SendCreate.propTypes = { navigation: PropTypes.shape({ goBack: PropTypes.func, getParam: PropTypes.func, navigate: PropTypes.func, dismiss: PropTypes.func, state: PropTypes.shape({ params: PropTypes.shape({ amount: PropTypes.string, fee: PropTypes.number, address: PropTypes.string, memo: PropTypes.string, }), }), }), };