aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-07-24 09:27:51 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-07-24 09:27:51 +0800
commitf7ad978474f42eb96f4f6c79376391504cf228c1 (patch)
treebe472127595385f8c8558213a58b7d1a470ad760 /ui
parent02091486094dcc818096ce13a22cdc140a2e8347 (diff)
downloadtangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar.gz
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar.bz2
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar.lz
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar.xz
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.tar.zst
tangerine-wallet-browser-f7ad978474f42eb96f4f6c79376391504cf228c1.zip
camera working back and forth
Diffstat (limited to 'ui')
-rw-r--r--ui/app/actions.js21
-rw-r--r--ui/app/components/send/send-content/send-content.component.js2
-rw-r--r--ui/app/components/send/send.component.js12
-rw-r--r--ui/app/components/send/send.container.js2
4 files changed, 36 insertions, 1 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 6c947fc35..9aba6853d 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -302,6 +302,7 @@ var actions = {
CLEAR_PENDING_TOKENS: 'CLEAR_PENDING_TOKENS',
setPendingTokens,
clearPendingTokens,
+ scanQrCode,
}
module.exports = actions
@@ -2194,3 +2195,23 @@ function clearPendingTokens () {
type: actions.CLEAR_PENDING_TOKENS,
}
}
+
+function scanQrCode () {
+ log.debug(`background.scanQrCode`)
+ return (dispatch, getState) => {
+ dispatch(actions.showLoadingIndication())
+ return new Promise((resolve, reject) => {
+ background.scanQrCode((err, data) => {
+ log.debug(`background.scanQrCode resolved!`, err, data)
+ if (err) {
+ log.error(err)
+ dispatch(actions.displayWarning(err.message))
+ return reject(err)
+ }
+
+ dispatch(actions.hideLoadingIndication())
+ return resolve(data)
+ })
+ })
+ }
+}
diff --git a/ui/app/components/send/send-content/send-content.component.js b/ui/app/components/send/send-content/send-content.component.js
index 7a0b1a18e..566ee1c7f 100644
--- a/ui/app/components/send/send-content/send-content.component.js
+++ b/ui/app/components/send/send-content/send-content.component.js
@@ -11,6 +11,7 @@ export default class SendContent extends Component {
static propTypes = {
updateGas: PropTypes.func,
+ scanQrCode: PropTypes.func,
};
render () {
@@ -19,6 +20,7 @@ export default class SendContent extends Component {
<div className="send-v2__form">
<SendFromRow />
<SendToRow updateGas={(updateData) => this.props.updateGas(updateData)} />
+ <button onClick={_ => this.props.scanQrCode() }>or scan a QR code</button>
<SendAmountRow updateGas={(updateData) => this.props.updateGas(updateData)} />
<SendGasRow />
<SendHexDataRow />
diff --git a/ui/app/components/send/send.component.js b/ui/app/components/send/send.component.js
index 6f1b20c55..5e967251d 100644
--- a/ui/app/components/send/send.component.js
+++ b/ui/app/components/send/send.component.js
@@ -38,12 +38,19 @@ export default class SendTransactionScreen extends PersistentForm {
updateAndSetGasTotal: PropTypes.func,
updateSendErrors: PropTypes.func,
updateSendTokenBalance: PropTypes.func,
+ scanQrCode: PropTypes.func,
};
static contextTypes = {
t: PropTypes.func,
};
+ scanQrCode = async () => {
+ const scannedAddress = await this.props.scanQrCode()
+ console.log('QR-SCANNER: Got address (UI)', scannedAddress)
+ this.updateGas({ to: scannedAddress })
+ }
+
updateGas ({ to: updatedToAddress, amount: value } = {}) {
const {
amount,
@@ -170,7 +177,10 @@ export default class SendTransactionScreen extends PersistentForm {
return (
<div className="page-container">
<SendHeader history={history}/>
- <SendContent updateGas={(updateData) => this.updateGas(updateData)}/>
+ <SendContent
+ updateGas={(updateData) => this.updateGas(updateData)}
+ scanQrCode={_ => this.scanQrCode()}
+ />
<SendFooter history={history}/>
</div>
)
diff --git a/ui/app/components/send/send.container.js b/ui/app/components/send/send.container.js
index 44ebd2792..c3240be67 100644
--- a/ui/app/components/send/send.container.js
+++ b/ui/app/components/send/send.container.js
@@ -26,6 +26,7 @@ import {
updateSendTokenBalance,
updateGasData,
setGasTotal,
+ scanQrCode,
} from '../../actions'
import {
resetSendState,
@@ -89,5 +90,6 @@ function mapDispatchToProps (dispatch) {
},
updateSendErrors: newError => dispatch(updateSendErrors(newError)),
resetSendState: () => dispatch(resetSendState()),
+ scanQrCode: () => dispatch(scanQrCode()),
}
}