From f1d662b868bb1b19ed6625159a505c78ed8feaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Fri, 21 Dec 2018 13:35:48 +0100 Subject: [PATCH 01/12] Updated react-native-custom-qr-codes package --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index d809dc5b..7551e992 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { From 97fce4c4c40d8e5fa98e064102a68eaf5c0d708a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Fri, 21 Dec 2018 13:38:42 +0100 Subject: [PATCH 02/12] Feature: let user set amount and label on receive screen --- loc/en.js | 2 + screen/receive/details.js | 135 +++++++++++++++++++++++++++++--------- 2 files changed, 107 insertions(+), 30 deletions(-) diff --git a/loc/en.js b/loc/en.js index db0923f9..34c6c643 100644 --- a/loc/en.js +++ b/loc/en.js @@ -153,6 +153,8 @@ module.exports = { title: 'Share this address with payer', share: 'share', copiedToClipboard: 'Copied to clipboard.', + amount: 'amount to receive (BTC)', + label: 'note to sender', }, }, buyBitcoin: { diff --git a/screen/receive/details.js b/screen/receive/details.js index ffcf97e3..01e48cf1 100644 --- a/screen/receive/details.js +++ b/screen/receive/details.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { Animated, StyleSheet, View, TouchableOpacity, Clipboard, Share } from 'react-native'; +import { Animated, StyleSheet, View, TouchableOpacity, Clipboard, Share, TextInput, KeyboardAvoidingView } from 'react-native'; import { QRCode } from 'react-native-custom-qr-codes'; import bip21 from 'bip21'; import { BlueLoading, SafeBlueArea, BlueButton, BlueNavigationStyle, is } from '../../BlueComponents'; @@ -26,6 +26,8 @@ export default class ReceiveDetails extends Component { address: address, secret: secret, addressText: '', + amount: undefined, + label: undefined, }; // EV(EV.enum.RECEIVE_ADDRESS_CHANGED, this.refreshFunction.bind(this)); @@ -77,44 +79,117 @@ export default class ReceiveDetails extends Component { }); }; + setAmount = value => { + if (!value || parseFloat(value) <= 0) { + this.setState({ amount: undefined }); + } else { + this.setState({ amount: value }); + } + }; + + setLabel = text => { + if (!text) { + this.setState({ label: undefined }); + } else { + this.setState({ label: text }); + } + }; + render() { console.log('render() receive/details, address,secret=', this.state.address, ',', this.state.secret); if (this.state.isLoading) { return ; } + const { amount, label } = this.state; + return ( - - - - - {this.state.addressText} - - - - - { - Share.share({ - message: this.state.address, - }); - }} - title={loc.receive.details.share} - /> - + + + + + + {this.state.addressText} + + + + + + + + + + + { + Share.share({ + message: this.state.address, + }); + }} + title={loc.receive.details.share} + /> + + ); From 1a8b8b6d27007980874ff3e0a56930fbeaf9837c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Fri, 21 Dec 2018 14:01:29 +0100 Subject: [PATCH 03/12] Added missing translation keys --- loc/es.js | 2 ++ loc/pt_BR.js | 2 ++ loc/pt_PT.js | 2 ++ loc/ru.js | 2 ++ loc/ua.js | 2 ++ 5 files changed, 10 insertions(+) diff --git a/loc/es.js b/loc/es.js index 4761eb50..b4acc71e 100644 --- a/loc/es.js +++ b/loc/es.js @@ -154,6 +154,8 @@ module.exports = { title: 'Comparte esta dirección con el pagador', share: 'Compartir', copiedToClipboard: 'Copiado a portapapeles.', + amount: 'amount to receive (BTC)', + label: 'note to sender', }, }, buyBitcoin: { diff --git a/loc/pt_BR.js b/loc/pt_BR.js index 00e3d88e..dc39bcfc 100644 --- a/loc/pt_BR.js +++ b/loc/pt_BR.js @@ -155,6 +155,8 @@ module.exports = { title: 'Partilhar este endereço com o pagador', share: 'partilhar', copiedToClipboard: 'copiado para clip board', + amount: 'amount to receive (BTC)', + label: 'note to sender', }, }, buyBitcoin: { diff --git a/loc/pt_PT.js b/loc/pt_PT.js index 08309f8f..4bd3b045 100644 --- a/loc/pt_PT.js +++ b/loc/pt_PT.js @@ -159,6 +159,8 @@ module.exports = { title: 'Partilhar este endereço com o pagador', share: 'partilhar', copiedToClipboard: 'copiado para clip board', + amount: 'amount to receive (BTC)', + label: 'note to sender', }, }, settings: { diff --git a/loc/ru.js b/loc/ru.js index ece81d44..09fed2e3 100644 --- a/loc/ru.js +++ b/loc/ru.js @@ -158,6 +158,8 @@ module.exports = { title: 'Покажите этот адрес плательщику', share: 'Отправить', copiedToClipboard: 'скопировано', + amount: 'amount to receive (BTC)', + label: 'note to sender', }, }, settings: { diff --git a/loc/ua.js b/loc/ua.js index f5b5bc2d..ecad96f2 100644 --- a/loc/ua.js +++ b/loc/ua.js @@ -153,6 +153,8 @@ module.exports = { title: 'Покажіть цю адресу платникові', share: 'Відправити', copiedToClipboard: 'Зкопіювано', + amount: 'amount to receive (BTC)', + label: 'note to sender', }, }, buyBitcoin: { From 85867728d85a133f2eec6849f412199afebcb2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Tue, 25 Dec 2018 15:16:23 +0100 Subject: [PATCH 04/12] Created common component for setting Bitcoin amount --- BlueComponents.js | 51 ++++++++++++++++++++++++++++++++++++++++++ screen/send/details.js | 40 +++++---------------------------- 2 files changed, 57 insertions(+), 34 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 21ccdc35..0b1ef5e0 100644 --- a/BlueComponents.js +++ b/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'); @@ -1102,3 +1104,52 @@ export class WalletsCarousel extends Component { ); } } + +export class BlueBitcoinAmount extends Component { + static propTypes = { + isLoading: PropTypes.bool, + amount: PropTypes.string, + onChangeText: PropTypes.func, + disabled: PropTypes.bool, + }; + + render() { + return ( + + + this.props.onChangeText(text.replace(',', '.'))} + placeholder="0" + maxLength={10} + editable={!this.props.isLoading && !this.props.disabled} + value={this.props.amount} + placeholderTextColor="#0f5cc0" + style={{ + color: '#0f5cc0', + fontSize: 36, + fontWeight: '600', + }} + /> + + {' ' + BitcoinUnit.BTC} + + + + + {loc.formatBalance(this.props.amount || 0, BitcoinUnit.LOCAL_CURRENCY)} + + + + ); + } +} diff --git a/screen/send/details.js b/screen/send/details.js index bcd0d303..ebcfd748 100644 --- a/screen/send/details.js +++ b/screen/send/details.js @@ -14,7 +14,7 @@ import { Text, } from 'react-native'; import { Icon } from 'react-native-elements'; -import { BlueNavigationStyle, BlueButton } 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'; @@ -485,39 +485,11 @@ export default class SendDetails extends Component { - - 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', - }} - /> - - {' ' + BitcoinUnit.BTC} - - - - - {loc.formatBalance(this.state.amount || 0, BitcoinUnit.LOCAL_CURRENCY)} - - + this.setState({ amount: text })} + /> Date: Tue, 25 Dec 2018 15:25:12 +0100 Subject: [PATCH 05/12] Created separate screen for setting amount to receive --- MainBottomTabs.js | 5 ++ loc/en.js | 4 +- loc/es.js | 4 +- loc/pt_BR.js | 4 +- loc/pt_PT.js | 4 +- loc/ru.js | 4 +- loc/ua.js | 4 +- package-lock.json | 64 +++++++------- screen/receive/details.js | 146 +++++++++----------------------- screen/receive/receiveAmount.js | 145 +++++++++++++++++++++++++++++++ 10 files changed, 234 insertions(+), 150 deletions(-) create mode 100644 screen/receive/receiveAmount.js diff --git a/MainBottomTabs.js b/MainBottomTabs.js index f6d38de7..d2646959 100644 --- a/MainBottomTabs.js +++ b/MainBottomTabs.js @@ -24,6 +24,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'; @@ -166,6 +167,10 @@ const MainBottomTabs = createStackNavigator( screen: receiveDetails, }, + ReceiveAmount: { + screen: setReceiveAmount, + }, + // // LND: diff --git a/loc/en.js b/loc/en.js index 34c6c643..8950dd93 100644 --- a/loc/en.js +++ b/loc/en.js @@ -153,8 +153,8 @@ module.exports = { title: 'Share this address with payer', share: 'share', copiedToClipboard: 'Copied to clipboard.', - amount: 'amount to receive (BTC)', - label: 'note to sender', + label: 'Description', + setAmount: 'Receive with amount', }, }, buyBitcoin: { diff --git a/loc/es.js b/loc/es.js index b4acc71e..69b3542d 100644 --- a/loc/es.js +++ b/loc/es.js @@ -154,8 +154,8 @@ module.exports = { title: 'Comparte esta dirección con el pagador', share: 'Compartir', copiedToClipboard: 'Copiado a portapapeles.', - amount: 'amount to receive (BTC)', - label: 'note to sender', + label: 'Description', + setAmount: 'Receive with amount', }, }, buyBitcoin: { diff --git a/loc/pt_BR.js b/loc/pt_BR.js index dc39bcfc..bc331a0b 100644 --- a/loc/pt_BR.js +++ b/loc/pt_BR.js @@ -155,8 +155,8 @@ module.exports = { title: 'Partilhar este endereço com o pagador', share: 'partilhar', copiedToClipboard: 'copiado para clip board', - amount: 'amount to receive (BTC)', - label: 'note to sender', + label: 'Description', + setAmount: 'Receive with amount', }, }, buyBitcoin: { diff --git a/loc/pt_PT.js b/loc/pt_PT.js index 4bd3b045..30790570 100644 --- a/loc/pt_PT.js +++ b/loc/pt_PT.js @@ -159,8 +159,8 @@ module.exports = { title: 'Partilhar este endereço com o pagador', share: 'partilhar', copiedToClipboard: 'copiado para clip board', - amount: 'amount to receive (BTC)', - label: 'note to sender', + label: 'Description', + setAmount: 'Receive with amount', }, }, settings: { diff --git a/loc/ru.js b/loc/ru.js index 09fed2e3..15f0df6f 100644 --- a/loc/ru.js +++ b/loc/ru.js @@ -158,8 +158,8 @@ module.exports = { title: 'Покажите этот адрес плательщику', share: 'Отправить', copiedToClipboard: 'скопировано', - amount: 'amount to receive (BTC)', - label: 'note to sender', + label: 'Description', + setAmount: 'Receive with amount', }, }, settings: { diff --git a/loc/ua.js b/loc/ua.js index ecad96f2..29f5b4e5 100644 --- a/loc/ua.js +++ b/loc/ua.js @@ -153,8 +153,8 @@ module.exports = { title: 'Покажіть цю адресу платникові', share: 'Відправити', copiedToClipboard: 'Зкопіювано', - amount: 'amount to receive (BTC)', - label: 'note to sender', + label: 'Description', + setAmount: 'Receive with amount', }, }, buyBitcoin: { diff --git a/package-lock.json b/package-lock.json index 7551e992..636a1dbe 100644 --- a/package-lock.json +++ b/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": { @@ -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": { diff --git a/screen/receive/details.js b/screen/receive/details.js index 01e48cf1..7fe6c42c 100644 --- a/screen/receive/details.js +++ b/screen/receive/details.js @@ -1,8 +1,8 @@ import React, { Component } from 'react'; -import { Animated, StyleSheet, View, TouchableOpacity, Clipboard, Share, TextInput, KeyboardAvoidingView } from 'react-native'; +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'); @@ -26,8 +26,6 @@ export default class ReceiveDetails extends Component { address: address, secret: secret, addressText: '', - amount: undefined, - label: undefined, }; // EV(EV.enum.RECEIVE_ADDRESS_CHANGED, this.refreshFunction.bind(this)); @@ -79,117 +77,52 @@ export default class ReceiveDetails extends Component { }); }; - setAmount = value => { - if (!value || parseFloat(value) <= 0) { - this.setState({ amount: undefined }); - } else { - this.setState({ amount: value }); - } - }; - - setLabel = text => { - if (!text) { - this.setState({ label: undefined }); - } else { - this.setState({ label: text }); - } - }; - render() { console.log('render() receive/details, address,secret=', this.state.address, ',', this.state.secret); if (this.state.isLoading) { return ; } - const { amount, label } = this.state; - return ( - - - - - - {this.state.addressText} - - - - - - - - - - - { - Share.share({ - message: this.state.address, - }); - }} - title={loc.receive.details.share} - /> - - + + + + + {this.state.addressText} + + + + + { + this.props.navigation.navigate('ReceiveAmount', { + address: this.state.address, + }); + }} + /> + { + Share.share({ + message: this.state.address, + }); + }} + title={loc.receive.details.share} + /> + ); @@ -208,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, diff --git a/screen/receive/receiveAmount.js b/screen/receive/receiveAmount.js new file mode 100644 index 00000000..68c64237 --- /dev/null +++ b/screen/receive/receiveAmount.js @@ -0,0 +1,145 @@ +import React, { Component } from 'react'; +import { StyleSheet, View, Share, TextInput, KeyboardAvoidingView, Clipboard, Animated, TouchableOpacity } from 'react-native'; +import { QRCode } from 'react-native-custom-qr-codes'; +import bip21 from 'bip21'; +import { SafeBlueArea, BlueButton, BlueNavigationStyle, is, BlueBitcoinAmount, BlueText } from '../../BlueComponents'; +import PropTypes from 'prop-types'; +/** @type {AppStorage} */ +let BlueApp = require('../../BlueApp'); +let loc = require('../../loc'); + +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.address); + setTimeout(() => this.setState({ addressText: this.state.address }), 1000); + }); + }; + + 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 })} /> + + ); + } + + renderWithSetAmount() { + return ( + + + {this.state.label} + + + + + + + {this.state.addressText} + + + { + Share.share({ + message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), + }); + }} + title={loc.receive.details.share} + /> + + ); + } + + render() { + return ( + + + + + this.setState({ amount: text })} + disabled={this.state.amountSet} + /> + {this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()} + + + + + ); + } +} + +const styles = StyleSheet.create({ + address: { + marginVertical: 32, + fontSize: 15, + color: '#9aa0aa', + textAlign: 'center', + }, +}); From f22f3e6a5a02a28c50d7a9bd11713f6e0da98774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Thu, 27 Dec 2018 11:30:50 +0100 Subject: [PATCH 06/12] Show BTC input as disabled when disabled --- BlueComponents.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 0b1ef5e0..77b07e60 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -1124,16 +1124,16 @@ export class BlueBitcoinAmount extends Component { maxLength={10} editable={!this.props.isLoading && !this.props.disabled} value={this.props.amount} - placeholderTextColor="#0f5cc0" + placeholderTextColor={this.props.disabled ? '#99a0ab' : '#0f5cc0'} style={{ - color: '#0f5cc0', + color: this.props.disabled ? '#99a0ab' : '#0f5cc0', fontSize: 36, fontWeight: '600', }} /> Date: Thu, 27 Dec 2018 14:48:00 +0100 Subject: [PATCH 07/12] Fix: Display share button correctly --- screen/receive/details.js | 2 +- screen/receive/receiveAmount.js | 48 ++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/screen/receive/details.js b/screen/receive/details.js index 7fe6c42c..7be4857f 100644 --- a/screen/receive/details.js +++ b/screen/receive/details.js @@ -100,7 +100,7 @@ export default class ReceiveDetails extends Component { - + { diff --git a/screen/receive/receiveAmount.js b/screen/receive/receiveAmount.js index 68c64237..ba8b54e6 100644 --- a/screen/receive/receiveAmount.js +++ b/screen/receive/receiveAmount.js @@ -93,24 +93,13 @@ export default class ReceiveAmount extends Component { logo={require('../../img/qr-code.png')} /> - - - {this.state.addressText} - - - { - Share.share({ - message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), - }); - }} - title={loc.receive.details.share} - /> + + + + {this.state.addressText} + + + ); } @@ -118,8 +107,7 @@ export default class ReceiveAmount extends Component { render() { return ( - - + {this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()} + {this.state.amountSet && ( + { + Share.share({ + message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), + }); + }} + title={loc.receive.details.share} + /> + )} - ); } From a8923c6850fd355761d2b845affbce81cd64b7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Sat, 29 Dec 2018 17:25:31 +0100 Subject: [PATCH 08/12] Fix: Amount needs to be string --- BlueComponents.js | 8 +++-- screen/receive/receiveAmount.js | 58 ++++++++++++++++----------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 77b07e60..64f412f3 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -1108,12 +1108,14 @@ export class WalletsCarousel extends Component { export class BlueBitcoinAmount extends Component { static propTypes = { isLoading: PropTypes.bool, - amount: PropTypes.string, + 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 ( @@ -1123,7 +1125,7 @@ export class BlueBitcoinAmount extends Component { placeholder="0" maxLength={10} editable={!this.props.isLoading && !this.props.disabled} - value={this.props.amount} + value={amount} placeholderTextColor={this.props.disabled ? '#99a0ab' : '#0f5cc0'} style={{ color: this.props.disabled ? '#99a0ab' : '#0f5cc0', @@ -1146,7 +1148,7 @@ export class BlueBitcoinAmount extends Component { - {loc.formatBalance(this.props.amount || 0, BitcoinUnit.LOCAL_CURRENCY)} + {loc.formatBalance(amount || 0, BitcoinUnit.LOCAL_CURRENCY)} diff --git a/screen/receive/receiveAmount.js b/screen/receive/receiveAmount.js index ba8b54e6..c3ce3370 100644 --- a/screen/receive/receiveAmount.js +++ b/screen/receive/receiveAmount.js @@ -107,35 +107,35 @@ export default class ReceiveAmount extends Component { render() { return ( - - - this.setState({ amount: text })} - disabled={this.state.amountSet} - /> - {this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()} - - {this.state.amountSet && ( - { - Share.share({ - message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), - }); - }} - title={loc.receive.details.share} - /> - )} - + + + this.setState({ amount: text })} + disabled={this.state.amountSet} + /> + {this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()} + + {this.state.amountSet && ( + { + Share.share({ + message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), + }); + }} + title={loc.receive.details.share} + /> + )} + ); } From d347fcf45076c2c835cdd550c02a3c485615a1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Sat, 29 Dec 2018 17:42:04 +0100 Subject: [PATCH 09/12] Fix: Use QRFast for long strings --- screen/receive/receiveAmount.js | 47 ++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/screen/receive/receiveAmount.js b/screen/receive/receiveAmount.js index c3ce3370..7cf45fda 100644 --- a/screen/receive/receiveAmount.js +++ b/screen/receive/receiveAmount.js @@ -1,12 +1,24 @@ import React, { Component } from 'react'; -import { StyleSheet, View, Share, TextInput, KeyboardAvoidingView, Clipboard, Animated, TouchableOpacity } from 'react-native'; -import { QRCode } from 'react-native-custom-qr-codes'; +import { + StyleSheet, + View, + Share, + TextInput, + KeyboardAvoidingView, + Clipboard, + Animated, + TouchableOpacity, + Platform, Dimensions +} 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, is, 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 }) => ({ @@ -45,6 +57,13 @@ export default class ReceiveAmount extends Component { }); }; + determineSize = () => { + if (width > 312) { + return width - 48; + } + return 312; + }; + renderDefault() { return ( @@ -85,13 +104,23 @@ export default class ReceiveAmount extends Component { {this.state.label} - + {(Platform.OS === 'ios' || this.state.wallet.getSecret().length < 54) ? ( + + ) : ( + + )} From 6c7db12e342c33e3c10eff57ed105166b803d5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0ev=C4=8D=C3=ADk?= Date: Sat, 29 Dec 2018 20:51:14 +0100 Subject: [PATCH 10/12] Fix: Removed unused constant --- screen/receive/receiveAmount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen/receive/receiveAmount.js b/screen/receive/receiveAmount.js index 7cf45fda..a552288f 100644 --- a/screen/receive/receiveAmount.js +++ b/screen/receive/receiveAmount.js @@ -13,7 +13,7 @@ import { import { QRCode as QRSlow } from "react-native-custom-qr-codes"; import QRFast from 'react-native-qrcode'; import bip21 from 'bip21'; -import { SafeBlueArea, BlueButton, BlueNavigationStyle, is, BlueBitcoinAmount, BlueText } from '../../BlueComponents'; +import { SafeBlueArea, BlueButton, BlueNavigationStyle, BlueBitcoinAmount, BlueText } from '../../BlueComponents'; import PropTypes from 'prop-types'; /** @type {AppStorage} */ let BlueApp = require('../../BlueApp'); From a4c839f1dea42b0673f0dc6e067eaab50b1d82f1 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Sun, 30 Dec 2018 20:10:28 +0000 Subject: [PATCH 11/12] FIX: crash on android; FIX: scroll for android (too high screen); FIX: while bip21 should be shared or copied --- screen/receive/receiveAmount.js | 76 +++++++++++++++++---------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/screen/receive/receiveAmount.js b/screen/receive/receiveAmount.js index a552288f..bfc9d664 100644 --- a/screen/receive/receiveAmount.js +++ b/screen/receive/receiveAmount.js @@ -8,9 +8,11 @@ import { Clipboard, Animated, TouchableOpacity, - Platform, Dimensions -} from "react-native"; -import { QRCode as QRSlow } from "react-native-custom-qr-codes"; + 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'; @@ -52,7 +54,7 @@ export default class ReceiveAmount extends Component { copyToClipboard = () => { this.setState({ addressText: loc.receive.details.copiedToClipboard }, () => { - Clipboard.setString(this.state.address); + Clipboard.setString(bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label })); setTimeout(() => this.setState({ addressText: this.state.address }), 1000); }); }; @@ -104,7 +106,7 @@ export default class ReceiveAmount extends Component { {this.state.label} - {(Platform.OS === 'ios' || this.state.wallet.getSecret().length < 54) ? ( + {Platform.OS === 'ios' || bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }).length < 54 ? ( - ) : ( + ) : ( - {this.state.addressText} + {bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label })} @@ -136,35 +138,37 @@ export default class ReceiveAmount extends Component { render() { return ( - - - this.setState({ amount: text })} - disabled={this.state.amountSet} - /> - {this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()} - - {this.state.amountSet && ( - { - Share.share({ - message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), - }); - }} - title={loc.receive.details.share} - /> - )} - + + + + this.setState({ amount: text })} + disabled={this.state.amountSet} + /> + {this.state.amountSet ? this.renderWithSetAmount() : this.renderDefault()} + + {this.state.amountSet && ( + { + Share.share({ + message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), + }); + }} + title={loc.receive.details.share} + /> + )} + + ); } From b52392eb116869f7d07e6025b679139f97d9a0c2 Mon Sep 17 00:00:00 2001 From: Overtorment Date: Sun, 30 Dec 2018 20:25:08 +0000 Subject: [PATCH 12/12] REF --- screen/receive/receiveAmount.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/screen/receive/receiveAmount.js b/screen/receive/receiveAmount.js index bfc9d664..5aee92b2 100644 --- a/screen/receive/receiveAmount.js +++ b/screen/receive/receiveAmount.js @@ -54,7 +54,7 @@ export default class ReceiveAmount extends Component { copyToClipboard = () => { this.setState({ addressText: loc.receive.details.copiedToClipboard }, () => { - Clipboard.setString(bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label })); + Clipboard.setString(this.state.bip21); setTimeout(() => this.setState({ addressText: this.state.address }), 1000); }); }; @@ -94,7 +94,15 @@ export default class ReceiveAmount extends Component { editable={!this.state.isLoading} /> - this.setState({ amountSet: true })} /> + { + this.setState({ + amountSet: true, + bip21: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), + }); + }} + /> ); } @@ -106,9 +114,9 @@ export default class ReceiveAmount extends Component { {this.state.label} - {Platform.OS === 'ios' || bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }).length < 54 ? ( + {Platform.OS === 'ios' || this.state.bip21.length < 54 ? ( ) : ( - {bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label })} + {this.state.bip21} @@ -161,7 +169,7 @@ export default class ReceiveAmount extends Component { }} onPress={async () => { Share.share({ - message: bip21.encode(this.state.address, { amount: this.state.amount, label: this.state.label }), + message: this.state.bip21, }); }} title={loc.receive.details.share}