-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP for a new Receive Modal / Send Modal / Initial work for token bal…
…ances
- Loading branch information
1 parent
cc2b1f5
commit 856318c
Showing
35 changed files
with
475 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// @flow | ||
import React, { Component } from 'react' | ||
import styles from './CopyToClipboard.scss' | ||
import Tooltip from '../Tooltip' | ||
import { clipboard } from 'electron' | ||
import Copy from 'react-icons/lib/md/content-copy' | ||
import CheckCircle from 'react-icons/lib/md/check-circle' | ||
import classNames from 'classnames' | ||
import { ONE_SECOND_MS } from '../../core/time' | ||
|
||
type Props = { | ||
text: string, | ||
tooltip?: string, | ||
className?: string, | ||
style?: Object | ||
} | ||
|
||
type State = { | ||
copyIconShown: boolean | ||
} | ||
|
||
class CopyToClipboard extends Component<Props, State> { | ||
state = { | ||
copyIconShown: true | ||
} | ||
|
||
copyText = (text: string) => { | ||
clipboard.writeText(text) | ||
this.setState({ | ||
copyIconShown: false | ||
}) | ||
setTimeout(() => { | ||
this.setState({ | ||
copyIconShown: true | ||
}) | ||
}, ONE_SECOND_MS) | ||
} | ||
|
||
render () { | ||
const { text, tooltip = '', className = '', style } = this.props | ||
const { copyIconShown } = this.state | ||
return ( | ||
<span | ||
onClick={() => this.copyText(text)} | ||
className={classNames(styles.copyKey, className)} | ||
style={style} | ||
> | ||
{tooltip ? <Tooltip title={tooltip}>{copyIconShown ? <Copy /> : <CheckCircle />}</Tooltip> : <Copy />} | ||
</span>) | ||
} | ||
} | ||
|
||
export default CopyToClipboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.copyKey { | ||
margin-left: 5px; | ||
color: #000; | ||
&:hover { | ||
opacity: .7; | ||
cursor: pointer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './CopyToClipboard' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// @flow | ||
import React, { Component } from 'react' | ||
import BaseModal from '../BaseModal' | ||
import styles from './ReceiveModal.scss' | ||
import QRCode from 'qrcode/lib/browser' | ||
import CopyToClipboard from '../../CopyToClipboard' | ||
|
||
type Props = { | ||
address: string, | ||
hideModal: Function, | ||
} | ||
|
||
class ReceiveModal extends Component<Props> { | ||
canvas: ?HTMLCanvasElement | ||
|
||
render () { | ||
const { hideModal, address } = this.props | ||
return ( | ||
<BaseModal | ||
onAfterOpen={() => { | ||
QRCode.toCanvas(this.canvas, address, { version: 5 }, (err) => { | ||
if (err) console.log(err) | ||
}) | ||
}} | ||
title='NEO/GAS Wallet Address' | ||
hideModal={hideModal} | ||
style={{ | ||
content: { | ||
width: '420px', | ||
height: '390px' | ||
} | ||
}} | ||
> | ||
<div className={styles.textContainer}> | ||
<div>Your Public Neo Address:</div> | ||
<div className={styles.address}> | ||
<strong>{address}</strong> | ||
<CopyToClipboard text={address} tooltip='Copy Public Address' /> | ||
</div> | ||
<div className={styles.canvas}><canvas ref={(node) => { this.canvas = node }} /></div> | ||
<div>Only send NEO/GAS to this address</div> | ||
<div>Sending any other digital asset will result in permanent loss.</div> | ||
</div> | ||
</BaseModal> | ||
) | ||
} | ||
} | ||
|
||
export default ReceiveModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.textContainer { | ||
padding: 20px 0; | ||
} | ||
|
||
.canvas { | ||
margin: 10px 0; | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ReceiveModal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// @flow | ||
import React, { Component } from 'react' | ||
import BaseModal from '../BaseModal' | ||
import styles from './SendModal.scss' | ||
|
||
type Props = { | ||
neo: number, | ||
gas: number, | ||
hideModal: Function, | ||
} | ||
|
||
class SendModal extends Component<Props> { | ||
canvas: ?HTMLCanvasElement | ||
state = { | ||
sendAmount: '', | ||
sendAddress: '', | ||
sendAsset: '' | ||
} | ||
|
||
render () { | ||
const { hideModal, neo, gas } = this.props | ||
const { sendAddress, sendAmount, sendAsset } = this.state | ||
|
||
return ( | ||
<BaseModal | ||
title='Send' | ||
hideModal={hideModal} | ||
style={{ | ||
content: { | ||
width: '420px', | ||
height: '390px' | ||
} | ||
}} | ||
> | ||
<div className={styles.textContainer}> | ||
<div id='sendAddress' className={styles.row}> | ||
<label className={styles.label}>Address:</label> | ||
<input | ||
autoFocus | ||
type='text' | ||
placeholder='Where to send the asset (address)' | ||
value={sendAddress} | ||
onChange={(e) => this.setState({ sendAddress: e.target.value })} | ||
/> | ||
</div> | ||
<div id='sendAmount' className={styles.row}> | ||
<label className={styles.label}>Amount:</label> | ||
<input | ||
type='text' | ||
value={sendAmount} | ||
placeholder='Amount' | ||
onChange={(e) => this.setState({ sendAmount: e.target.value })} | ||
/> | ||
</div> | ||
<div id='sendAmount' className={styles.row}> | ||
<label className={styles.label}>Amount:</label> | ||
<div className={styles.sendAmount}> | ||
<select className={styles.sendAmountSelect}> | ||
<option value='NEO'>NEO</option> | ||
<option value='GAS'>GAS</option> | ||
<option value='RPX'>RPX</option> | ||
</select> | ||
<div>{neo} NEO</div> | ||
</div> | ||
</div> | ||
<button className={styles.sendButton} id='doSend' onClick={this.openAndValidate}>Send Asset</button> | ||
</div> | ||
</BaseModal> | ||
) | ||
} | ||
} | ||
|
||
export default SendModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.textContainer { | ||
} | ||
|
||
.canvas { | ||
margin: 10px 0; | ||
text-align: center; | ||
} | ||
|
||
.row { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.label { | ||
padding: 10px 0; | ||
} | ||
|
||
.sendAmount { | ||
display: flex; | ||
} | ||
|
||
.sendAmountSelect { | ||
margin-right: 10px; | ||
} | ||
|
||
.sendButton { | ||
margin-top: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './SendModal' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.