#73 Using Modal for wrapping Send and Receive Tokens components

This commit is contained in:
apanizo 2018-10-24 10:17:13 +02:00
parent 659215bb7e
commit de8031a246
1 changed files with 43 additions and 5 deletions

View File

@ -17,6 +17,8 @@ import Table from '~/components/Table'
import { sm, xs } from '~/theme/variables' import { sm, xs } from '~/theme/variables'
import { getBalanceData, generateColumns, BALANCE_TABLE_ASSET_ID, type BalanceRow, filterByZero } from './dataFetcher' import { getBalanceData, generateColumns, BALANCE_TABLE_ASSET_ID, type BalanceRow, filterByZero } from './dataFetcher'
import Tokens from './Tokens' import Tokens from './Tokens'
import Send from './Send'
import Receive from './Receive'
type State = { type State = {
hideZero: boolean, hideZero: boolean,
@ -79,7 +81,9 @@ type Props = {
class Balances extends React.Component<Props, State> { class Balances extends React.Component<Props, State> {
state = { state = {
hideZero: false, hideZero: false,
showToken: true, showToken: false,
showSend: false,
showReceive: false,
} }
onShowToken = () => { onShowToken = () => {
@ -90,6 +94,22 @@ class Balances extends React.Component<Props, State> {
this.setState(() => ({ showToken: false })) this.setState(() => ({ showToken: false }))
} }
onShowSend = () => {
this.setState(() => ({ showSend: true }))
}
onHideSend = () => {
this.setState(() => ({ showSend: false }))
}
onShowReceive = () => {
this.setState(() => ({ showReceive: true }))
}
onHideReceive = () => {
this.setState(() => ({ showReceive: false }))
}
handleChange = (e: SyntheticInputEvent<HTMLInputElement>) => { handleChange = (e: SyntheticInputEvent<HTMLInputElement>) => {
const { checked } = e.target const { checked } = e.target
@ -97,7 +117,9 @@ class Balances extends React.Component<Props, State> {
} }
render() { render() {
const { hideZero, showToken } = this.state const {
hideZero, showToken, showReceive, showSend,
} = this.state
const { classes } = this.props const { classes } = this.props
const columns = generateColumns() const columns = generateColumns()
@ -131,7 +153,7 @@ class Balances extends React.Component<Props, State> {
handleClose={this.onHideToken} handleClose={this.onHideToken}
open={showToken} open={showToken}
> >
<Tokens /> <Tokens onClose={this.onHideToken} />
</Modal> </Modal>
</Col> </Col>
</Row> </Row>
@ -150,11 +172,11 @@ class Balances extends React.Component<Props, State> {
)) } )) }
<TableCell component="th" scope="row"> <TableCell component="th" scope="row">
<Row align="end" className={classes.actions}> <Row align="end" className={classes.actions}>
<Button variant="contained" size="small" color="secondary" className={classes.send}> <Button variant="contained" size="small" color="secondary" className={classes.send} onClick={this.onShowSend}>
<CallMade className={classNames(classes.leftIcon, classes.iconSmall)} /> <CallMade className={classNames(classes.leftIcon, classes.iconSmall)} />
Send Send
</Button> </Button>
<Button variant="contained" size="small" color="secondary" className={classes.receive}> <Button variant="contained" size="small" color="secondary" className={classes.receive} onClick={this.onShowReceive}>
<CallReceived className={classNames(classes.leftIcon, classes.iconSmall)} /> <CallReceived className={classNames(classes.leftIcon, classes.iconSmall)} />
Receive Receive
</Button> </Button>
@ -163,6 +185,22 @@ class Balances extends React.Component<Props, State> {
</TableRow> </TableRow>
))} ))}
</Table> </Table>
<Modal
title="Send Tokens"
description="Send Tokens Form"
handleClose={this.onHideSend}
open={showSend}
>
<Send onClose={this.onHideSend} />
</Modal>
<Modal
title="Receive Tokens"
description="Receive Tokens Form"
handleClose={this.onHideReceive}
open={showReceive}
>
<Receive onClose={this.onHideReceive} />
</Modal>
</React.Fragment> </React.Fragment>
) )
} }