Browse Source

Merge branch 'master' of github.com:BlueWallet/BlueWallet into receiveBase

# Conflicts:
#	screen/send/details.js
localNotifications
Marcos Rodriguez Vélez 6 years ago
parent
commit
47e54314a6
  1. 53
      BlueComponents.js
  2. 5
      MainBottomTabs.js
  3. 2
      loc/en.js
  4. 2
      loc/es.js
  5. 2
      loc/pt_BR.js
  6. 2
      loc/pt_PT.js
  7. 2
      loc/ru.js
  8. 2
      loc/ua.js
  9. 66
      package-lock.json
  10. 13
      screen/receive/details.js
  11. 192
      screen/receive/receiveAmount.js
  12. 111
      screen/send/details.js

53
BlueComponents.js

@ -1,6 +1,7 @@
/** @type {AppStorage} */
import React, { Component } from 'react';
import Ionicons from 'react-native-vector-icons/Ionicons';
import PropTypes from 'prop-types';
import { Icon, Button, FormLabel, FormInput, Text, Header, List, ListItem } from 'react-native-elements';
import {
TouchableOpacity,
@ -24,6 +25,7 @@ import { HDLegacyP2PKHWallet } from './class/hd-legacy-p2pkh-wallet';
import { HDLegacyBreadwalletWallet } from './class/hd-legacy-breadwallet-wallet';
import { HDSegwitP2SHWallet } from './class/hd-segwit-p2sh-wallet';
import { LightningCustodianWallet } from './class/lightning-custodian-wallet';
import { BitcoinUnit } from './models/bitcoinUnits';
let loc = require('./loc/');
/** @type {AppStorage} */
let BlueApp = require('./BlueApp');
@ -1104,3 +1106,54 @@ export class WalletsCarousel extends Component {
);
}
}
export class BlueBitcoinAmount extends Component {
static propTypes = {
isLoading: PropTypes.bool,
amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChangeText: PropTypes.func,
disabled: PropTypes.bool,
};
render() {
const amount = typeof this.props.amount === 'number' ? this.props.amount.toString() : this.props.amount;
return (
<View>
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
<TextInput
keyboardType="numeric"
onChangeText={text => this.props.onChangeText(text.replace(',', '.'))}
placeholder="0"
maxLength={10}
editable={!this.props.isLoading && !this.props.disabled}
value={amount}
placeholderTextColor={this.props.disabled ? '#99a0ab' : '#0f5cc0'}
style={{
color: this.props.disabled ? '#99a0ab' : '#0f5cc0',
fontSize: 36,
fontWeight: '600',
}}
/>
<Text
style={{
color: this.props.disabled ? '#99a0ab' : '#0f5cc0',
fontSize: 16,
marginHorizontal: 4,
paddingBottom: 6,
fontWeight: '600',
alignSelf: 'flex-end',
}}
>
{' ' + BitcoinUnit.BTC}
</Text>
</View>
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
{loc.formatBalance(amount || 0, BitcoinUnit.LOCAL_CURRENCY)}
</Text>
</View>
</View>
);
}
}

5
MainBottomTabs.js

@ -25,6 +25,7 @@ import rbf from './screen/transactions/RBF';
import createrbf from './screen/transactions/RBF-create';
import receiveDetails from './screen/receive/details';
import setReceiveAmount from './screen/receive/receiveAmount';
import sendDetails from './screen/send/details';
import sendScanQrAddress from './screen/send/scanQrAddress';
@ -222,6 +223,10 @@ const MainBottomTabs = createStackNavigator(
screen: receiveDetails,
},
ReceiveAmount: {
screen: setReceiveAmount,
},
//
// LND:

2
loc/en.js

@ -159,6 +159,8 @@ module.exports = {
title: 'Share this address with payer',
share: 'share',
copiedToClipboard: 'Copied to clipboard.',
label: 'Description',
setAmount: 'Receive with amount',
},
},
buyBitcoin: {

2
loc/es.js

@ -160,6 +160,8 @@ module.exports = {
title: 'Comparte esta dirección con el pagador',
share: 'Compartir',
copiedToClipboard: 'Copiado a portapapeles.',
label: 'Description',
setAmount: 'Receive with amount',
},
},
buyBitcoin: {

2
loc/pt_BR.js

@ -161,6 +161,8 @@ module.exports = {
title: 'Partilhar este endereço com o pagador',
share: 'partilhar',
copiedToClipboard: 'copiado para clip board',
label: 'Description',
setAmount: 'Receive with amount',
},
},
buyBitcoin: {

2
loc/pt_PT.js

@ -165,6 +165,8 @@ module.exports = {
title: 'Partilhar este endereço com o pagador',
share: 'partilhar',
copiedToClipboard: 'copiado para clip board',
label: 'Description',
setAmount: 'Receive with amount',
},
},
settings: {

2
loc/ru.js

@ -164,6 +164,8 @@ module.exports = {
title: 'Покажите этот адрес плательщику',
share: 'Отправить',
copiedToClipboard: 'скопировано',
label: 'Description',
setAmount: 'Receive with amount',
},
},
settings: {

2
loc/ua.js

@ -159,6 +159,8 @@ module.exports = {
title: 'Покажіть цю адресу платникові',
share: 'Відправити',
copiedToClipboard: 'Зкопіювано',
label: 'Description',
setAmount: 'Receive with amount',
},
},
buyBitcoin: {

66
package-lock.json

@ -1,6 +1,6 @@
{
"name": "BlueWallet",
"version": "3.3.0",
"version": "3.4.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -1446,7 +1446,7 @@
},
"abstract-leveldown": {
"version": "0.12.3",
"resolved": "http://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-0.12.3.tgz",
"resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-0.12.3.tgz",
"integrity": "sha1-EWsexcdxDvei1XBnaLvbREC+EHA=",
"requires": {
"xtend": "~3.0.0"
@ -1557,7 +1557,7 @@
},
"ansi-escapes": {
"version": "3.1.0",
"resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz",
"integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw=="
},
"ansi-gray": {
@ -1961,7 +1961,7 @@
},
"array-equal": {
"version": "1.0.0",
"resolved": "http://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
"integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=",
"dev": true
},
@ -2050,7 +2050,7 @@
},
"util": {
"version": "0.10.3",
"resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"requires": {
"inherits": "2.0.1"
@ -4007,7 +4007,7 @@
},
"es6-promisify": {
"version": "5.0.0",
"resolved": "http://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
"requires": {
"es6-promise": "^4.0.3"
@ -4266,7 +4266,7 @@
},
"doctrine": {
"version": "1.5.0",
"resolved": "http://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz",
"integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=",
"dev": true,
"requires": {
@ -4284,7 +4284,7 @@
},
"eslint-plugin-node": {
"version": "6.0.1",
"resolved": "http://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz",
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-6.0.1.tgz",
"integrity": "sha512-Q/Cc2sW1OAISDS+Ji6lZS2KV4b7ueA/WydVWd1BECTQwVvfQy5JAi3glhINoKzoMnfnuRgNP+ZWKrGAbp3QDxw==",
"dev": true,
"requires": {
@ -4345,7 +4345,7 @@
},
"espree": {
"version": "3.5.4",
"resolved": "http://registry.npmjs.org/espree/-/espree-3.5.4.tgz",
"resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz",
"integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==",
"dev": true,
"requires": {
@ -4394,7 +4394,7 @@
},
"event-target-shim": {
"version": "1.1.1",
"resolved": "http://registry.npmjs.org/event-target-shim/-/event-target-shim-1.1.1.tgz",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-1.1.1.tgz",
"integrity": "sha1-qG5e5r2qFgVEddp5fM3fDFVphJE="
},
"eventemitter3": {
@ -4404,7 +4404,7 @@
},
"events": {
"version": "1.1.1",
"resolved": "http://registry.npmjs.org/events/-/events-1.1.1.tgz",
"resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
"integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ="
},
"evp_bytestokey": {
@ -4511,7 +4511,7 @@
},
"fast-deep-equal": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
"dev": true
},
@ -4775,7 +4775,7 @@
},
"fs-extra": {
"version": "1.0.0",
"resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz",
"integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=",
"requires": {
"graceful-fs": "^4.1.2",
@ -6843,7 +6843,7 @@
},
"jest-get-type": {
"version": "22.4.3",
"resolved": "http://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz",
"resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.4.3.tgz",
"integrity": "sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==",
"dev": true
},
@ -8385,7 +8385,7 @@
},
"lodash.isempty": {
"version": "4.4.0",
"resolved": "http://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz",
"resolved": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz",
"integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4="
},
"lodash.memoize": {
@ -8798,12 +8798,12 @@
},
"mime-db": {
"version": "1.23.0",
"resolved": "http://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz",
"integrity": "sha1-oxtAcK2uon1zLqMzdApk0OyaZlk="
},
"mime-types": {
"version": "2.1.11",
"resolved": "http://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz",
"integrity": "sha1-wlnEcb2oCKhdbNGTtDCl+uRHOzw=",
"requires": {
"mime-db": "~1.23.0"
@ -9397,7 +9397,7 @@
},
"npmlog": {
"version": "2.0.4",
"resolved": "http://registry.npmjs.org/npmlog/-/npmlog-2.0.4.tgz",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-2.0.4.tgz",
"integrity": "sha1-mLUlMPJRTKkNCexbIsiEZyI3VpI=",
"requires": {
"ansi": "~0.3.1",
@ -9568,7 +9568,7 @@
"dependencies": {
"ansi-escapes": {
"version": "1.4.0",
"resolved": "http://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz",
"integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4="
},
"ansi-styles": {
@ -9688,7 +9688,7 @@
},
"os-homedir": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"dev": true
},
@ -9725,7 +9725,7 @@
},
"os-tmpdir": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
},
"p-defer": {
@ -9834,7 +9834,7 @@
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-is-inside": {
@ -9901,7 +9901,7 @@
},
"pify": {
"version": "2.3.0",
"resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw="
},
"pinkie": {
@ -10584,7 +10584,7 @@
},
"react-native-elements": {
"version": "0.19.1",
"resolved": "http://registry.npmjs.org/react-native-elements/-/react-native-elements-0.19.1.tgz",
"resolved": "https://registry.npmjs.org/react-native-elements/-/react-native-elements-0.19.1.tgz",
"integrity": "sha1-+Stp2GShUCFdAfgf48UqnK2oPkU=",
"requires": {
"lodash.isempty": "^4.4.0",
@ -11057,7 +11057,7 @@
},
"regexpp": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz",
"integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==",
"dev": true
},
@ -11089,7 +11089,7 @@
"dependencies": {
"jsesc": {
"version": "0.5.0",
"resolved": "http://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0="
}
}
@ -11218,7 +11218,7 @@
},
"require-uncached": {
"version": "1.0.3",
"resolved": "http://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz",
"resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz",
"integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=",
"dev": true,
"requires": {
@ -11331,7 +11331,7 @@
"dependencies": {
"fs-extra": {
"version": "0.22.1",
"resolved": "http://registry.npmjs.org/fs-extra/-/fs-extra-0.22.1.tgz",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.22.1.tgz",
"integrity": "sha1-X9b4BJ3JdsoZ6yNV1lgXPKvM4FY=",
"dev": true,
"requires": {
@ -11406,7 +11406,7 @@
},
"safe-regex": {
"version": "1.1.0",
"resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
"integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
"requires": {
"ret": "~0.1.10"
@ -11792,7 +11792,7 @@
},
"serialize-error": {
"version": "2.1.0",
"resolved": "http://registry.npmjs.org/serialize-error/-/serialize-error-2.1.0.tgz",
"resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-2.1.0.tgz",
"integrity": "sha1-ULZ51WNc34Rme9yOWa9OW4HV9go="
},
"serve-static": {
@ -11912,7 +11912,7 @@
},
"xmlbuilder": {
"version": "8.2.2",
"resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-8.2.2.tgz",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-8.2.2.tgz",
"integrity": "sha1-aSSGc0ELS6QuGmE2VR0pIjNap3M="
}
}
@ -12364,7 +12364,7 @@
},
"strip-ansi": {
"version": "3.0.1",
"resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
"requires": {
"ansi-regex": "^2.0.0"
@ -12377,7 +12377,7 @@
},
"strip-eof": {
"version": "1.0.0",
"resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
},
"strip-json-comments": {

13
screen/receive/details.js

@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { Animated, StyleSheet, View, TouchableOpacity, Clipboard, Share } from 'react-native';
import { QRCode } from 'react-native-custom-qr-codes';
import bip21 from 'bip21';
import { BlueLoading, SafeBlueArea, BlueButton, BlueNavigationStyle, is } from '../../BlueComponents';
import { BlueLoading, SafeBlueArea, BlueButton, BlueButtonLink, BlueNavigationStyle, is } from '../../BlueComponents';
import PropTypes from 'prop-types';
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
@ -100,7 +100,15 @@ export default class ReceiveDetails extends Component {
</Animated.Text>
</TouchableOpacity>
</View>
<View style={{ marginBottom: 24 }}>
<View style={{ marginBottom: 24, alignItems: 'center' }}>
<BlueButtonLink
title={loc.receive.details.setAmount}
onPress={() => {
this.props.navigation.navigate('ReceiveAmount', {
address: this.state.address,
});
}}
/>
<BlueButton
icon={{
name: 'share-alternative',
@ -133,6 +141,7 @@ const styles = StyleSheet.create({
ReceiveDetails.propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.function,
navigate: PropTypes.function,
state: PropTypes.shape({
params: PropTypes.shape({
address: PropTypes.string,

192
screen/receive/receiveAmount.js

@ -0,0 +1,192 @@
import React, { Component } from 'react';
import {
StyleSheet,
View,
Share,
TextInput,
KeyboardAvoidingView,
Clipboard,
Animated,
TouchableOpacity,
Platform,
Dimensions,
ScrollView,
} from 'react-native';
import { QRCode as QRSlow } from 'react-native-custom-qr-codes';
import QRFast from 'react-native-qrcode';
import bip21 from 'bip21';
import { SafeBlueArea, BlueButton, BlueNavigationStyle, BlueBitcoinAmount, BlueText } 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,
};
}
copyToClipboard = () => {
this.setState({ addressText: loc.receive.details.copiedToClipboard }, () => {
Clipboard.setString(this.state.bip21);
setTimeout(() => this.setState({ addressText: this.state.address }), 1000);
});
};
determineSize = () => {
if (width > 312) {
return width - 48;
}
return 312;
};
renderDefault() {
return (
<View>
<View
style={{
flexDirection: 'row',
borderColor: '#d2d2d2',
borderBottomColor: '#d2d2d2',
borderWidth: 1.0,
borderBottomWidth: 0.5,
backgroundColor: '#f5f5f5',
minHeight: 44,
height: 44,
marginHorizontal: 20,
alignItems: 'center',
marginVertical: 8,
borderRadius: 4,
}}
>
<TextInput
onChangeText={text => 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}
/>
</View>
<BlueButton
title="Create"
onPress={() => {
this.setState({
amountSet: true,
bip21: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }),
});
}}
/>
</View>
);
}
renderWithSetAmount() {
return (
<View style={{ justifyContent: 'space-between' }}>
<BlueText style={{ color: '#0c2550', fontWeight: '600', textAlign: 'center', paddingBottom: 24 }} numberOfLines={1}>
{this.state.label}
</BlueText>
<View style={{ justifyContent: 'center', alignItems: 'center', paddingHorizontal: 16 }}>
{Platform.OS === 'ios' || this.state.bip21.length < 54 ? (
<QRSlow
content={this.state.bip21}
size={this.determineSize()}
color={BlueApp.settings.foregroundColor}
backgroundColor={BlueApp.settings.brandingColor}
logo={require('../../img/qr-code.png')}
ecl={'Q'}
/>
) : (
<QRFast
value={this.state.bip21}
size={this.determineSize()}
fgColor={BlueApp.settings.brandingColor}
bgColor={BlueApp.settings.foregroundColor}
/>
)}
</View>
<View style={{ marginBottom: 24, alignItems: 'center', justifyContent: 'space-between' }}>
<TouchableOpacity onPress={this.copyToClipboard}>
<Animated.Text style={styles.address} numberOfLines={0}>
{this.state.bip21}
</Animated.Text>
</TouchableOpacity>
</View>
</View>
);
}
render() {
return (
<SafeBlueArea style={{ flex: 1 }}>
<ScrollView>
<View style={{ flex: 1, backgroundColor: '#FFFFFF', justifyContent: 'space-between' }}>
<KeyboardAvoidingView behavior="position">
<BlueBitcoinAmount
amount={this.state.amount || ''}
onChangeText={text => this.setState({ amount: text })}
disabled={this.state.amountSet}
/>
{this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()}
</KeyboardAvoidingView>
{this.state.amountSet && (
<BlueButton
buttonStyle={{
alignSelf: 'center',
marginBottom: 24,
}}
icon={{
name: 'share-alternative',
type: 'entypo',
color: BlueApp.settings.buttonTextColor,
}}
onPress={async () => {
Share.share({
message: this.state.bip21,
});
}}
title={loc.receive.details.share}
/>
)}
</View>
</ScrollView>
</SafeBlueArea>
);
}
}
const styles = StyleSheet.create({
address: {
marginVertical: 32,
fontSize: 15,
color: '#9aa0aa',
textAlign: 'center',
},
});

111
screen/send/details.js

@ -14,7 +14,7 @@ import {
Text,
} from 'react-native';
import { Icon } from 'react-native-elements';
import { BlueNavigationStyle, BlueButton, BlueLoading } from '../../BlueComponents';
import { BlueNavigationStyle, BlueButton, BlueBitcoinAmount } from '../../BlueComponents';
import PropTypes from 'prop-types';
import Modal from 'react-native-modal';
import NetworkTransactionFees, { NetworkTransactionFee } from '../../models/networkTransactionFees';
@ -22,7 +22,6 @@ import BitcoinBIP70TransactionDecode from '../../bip70/bip70';
import { BitcoinUnit } from '../../models/bitcoinUnits';
import { HDLegacyP2PKHWallet, HDSegwitP2SHWallet } from '../../class';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
const bip21 = require('bip21');
let EV = require('../../events');
let BigNumber = require('bignumber.js');
@ -41,9 +40,6 @@ export default class SendDetails extends Component {
constructor(props) {
super(props);
this.state = { isLoading: true };
const wallets = BlueApp.getWallets();
console.log('props.navigation.state.params=', props.navigation.state.params);
let address;
let memo;
@ -53,39 +49,37 @@ export default class SendDetails extends Component {
if (props.navigation.state.params) fromAddress = props.navigation.state.params.fromAddress;
let fromSecret;
if (props.navigation.state.params) fromSecret = props.navigation.state.params.fromSecret;
let fromWallet;
if (!BlueApp.getWallets().some(item => item.type !== LightningCustodianWallet.type) && typeof address === 'undefined') {
alert('Before sending Bitcoins, you must first add a Bitcoin wallet.');
props.navigation.dismiss();
} else {
for (let w of wallets) {
if (w.getSecret() === fromSecret) {
fromWallet = w;
break;
}
let fromWallet = null;
if (w.getAddress() === fromAddress) {
fromWallet = w;
}
}
const wallets = BlueApp.getWallets();
// fallback to first wallet if it exists
if (!fromWallet && wallets[0]) fromWallet = wallets[0];
for (let w of wallets) {
if (w.getSecret() === fromSecret) {
fromWallet = w;
break;
}
this.state = {
isFeeSelectionModalVisible: false,
fromAddress,
fromWallet,
fromSecret,
isLoading: false,
address,
memo,
fee: 1,
networkTransactionFees: new NetworkTransactionFee(1, 1, 1),
feeSliderValue: 1,
bip70TransactionExpiration: null,
};
if (w.getAddress() === fromAddress) {
fromWallet = w;
}
}
// fallback to first wallet if it exists
if (!fromWallet && wallets[0]) fromWallet = wallets[0];
this.state = {
isFeeSelectionModalVisible: false,
fromAddress,
fromWallet,
fromSecret,
isLoading: true,
address,
memo,
fee: 1,
networkTransactionFees: new NetworkTransactionFee(1, 1, 1),
feeSliderValue: 1,
bip70TransactionExpiration: null,
};
}
async componentDidMount() {
@ -130,7 +124,7 @@ export default class SendDetails extends Component {
fee: response.halfHourFee,
networkTransactionFees: response,
feeSliderValue: response.halfHourFee,
isLoading: typeof this.state.fromWallet !== 'object',
isLoading: false,
});
});
if (recommendedFees) {
@ -138,7 +132,7 @@ export default class SendDetails extends Component {
fee: recommendedFees.halfHourFee,
networkTransactionFees: recommendedFees,
feeSliderValue: recommendedFees.halfHourFee,
isLoading: typeof this.state.fromWallet !== 'object',
isLoading: false,
});
if (this.props.navigation.state.params.uri) {
@ -478,10 +472,10 @@ export default class SendDetails extends Component {
};
render() {
if (this.state.isLoading || typeof this.state.fromWallet === 'undefined') {
if (!this.state.fromWallet.getAddress) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<BlueLoading />
<View style={{ flex: 1, paddingTop: 20 }}>
<Text>System error: Source wallet not found (this should never happen)</Text>
</View>
);
}
@ -491,39 +485,11 @@ export default class SendDetails extends Component {
<View style={{ flex: 1, justifyContent: 'space-between' }}>
<View style={{ flex: 1, backgroundColor: '#FFFFFF' }}>
<KeyboardAvoidingView behavior="position">
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
<TextInput
keyboardType="numeric"
onChangeText={text => this.setState({ amount: text.replace(',', '.') })}
placeholder="0"
maxLength={10}
editable={!this.state.isLoading}
value={this.state.amount}
placeholderTextColor="#0f5cc0"
style={{
color: '#0f5cc0',
fontSize: 36,
fontWeight: '600',
}}
/>
<Text
style={{
color: '#0f5cc0',
fontSize: 16,
marginHorizontal: 4,
paddingBottom: 6,
fontWeight: '600',
alignSelf: 'flex-end',
}}
>
{' ' + BitcoinUnit.BTC}
</Text>
</View>
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
{loc.formatBalance(this.state.amount || 0, BitcoinUnit.LOCAL_CURRENCY)}
</Text>
</View>
<BlueBitcoinAmount
isLoading={this.state.isLoading}
amount={this.state.amount}
onChangeText={text => this.setState({ amount: text })}
/>
<View
style={{
flexDirection: 'row',
@ -664,7 +630,6 @@ SendDetails.propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.function,
navigate: PropTypes.func,
dismiss: PropTypes.function,
state: PropTypes.shape({
params: PropTypes.shape({
address: PropTypes.string,

Loading…
Cancel
Save