2019-01-15 18:02:49 -08:00
|
|
|
// @flow
|
2019-02-04 20:41:45 -08:00
|
|
|
|
2019-02-10 08:49:24 -08:00
|
|
|
import React, { PureComponent } from 'react';
|
2019-01-15 18:02:49 -08:00
|
|
|
import styled from 'styled-components';
|
|
|
|
|
2019-02-04 19:16:25 -08:00
|
|
|
import { ColumnComponent } from './column';
|
2019-01-15 18:02:49 -08:00
|
|
|
import { QRCode } from './qrcode';
|
|
|
|
|
2019-01-17 12:26:46 -08:00
|
|
|
import eyeIcon from '../assets/images/eye.png';
|
|
|
|
|
2019-01-15 18:02:49 -08:00
|
|
|
const AddressWrapper = styled.div`
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
background-color: #000;
|
|
|
|
border-radius: 6px;
|
|
|
|
padding: 7px 13px;
|
2019-02-11 05:37:50 -08:00
|
|
|
margin-bottom: 10px;
|
2019-01-15 18:02:49 -08:00
|
|
|
width: 100%;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Input = styled.input`
|
2019-02-07 08:31:59 -08:00
|
|
|
border-radius: ${props => props.theme.boxBorderRadius};
|
2019-01-15 18:02:49 -08:00
|
|
|
border: none;
|
2019-02-15 18:59:05 -08:00
|
|
|
background-color: ${props => props.theme.colors.inputBg};
|
2019-02-07 08:31:59 -08:00
|
|
|
color: ${props => props.theme.colors.text};
|
2019-01-15 18:02:49 -08:00
|
|
|
padding: 15px;
|
|
|
|
width: 100%;
|
|
|
|
outline: none;
|
2019-02-07 08:31:59 -08:00
|
|
|
font-family: ${props => props.theme.fontFamily};
|
2019-01-15 18:02:49 -08:00
|
|
|
|
|
|
|
::placeholder {
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const QRCodeWrapper = styled.div`
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
2019-02-15 18:59:05 -08:00
|
|
|
background-color: ${props => props.theme.colors.qrCodeWrapperBg}
|
2019-01-15 18:02:49 -08:00
|
|
|
border-radius: 6px;
|
|
|
|
padding: 20px;
|
2019-02-11 05:37:50 -08:00
|
|
|
margin-bottom: 10px;
|
2019-01-15 18:02:49 -08:00
|
|
|
width: 100%;
|
|
|
|
`;
|
|
|
|
|
2019-02-10 08:49:24 -08:00
|
|
|
const IconButton = styled.button`
|
|
|
|
background: transparent;
|
|
|
|
cursor: pointer;
|
|
|
|
outline: none;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const IconImage = styled.img`
|
|
|
|
max-width: 15px;
|
|
|
|
`;
|
|
|
|
|
2019-01-15 18:02:49 -08:00
|
|
|
type Props = {
|
|
|
|
address: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
type State = {
|
2019-02-10 08:49:24 -08:00
|
|
|
showQRCode: boolean,
|
2019-01-15 18:02:49 -08:00
|
|
|
};
|
|
|
|
|
2019-02-10 08:49:24 -08:00
|
|
|
export class WalletAddress extends PureComponent<Props, State> {
|
2019-02-04 19:16:25 -08:00
|
|
|
state = {
|
2019-02-10 08:49:24 -08:00
|
|
|
showQRCode: false,
|
2019-01-28 05:03:11 -08:00
|
|
|
};
|
2019-01-15 18:02:49 -08:00
|
|
|
|
2019-02-10 08:49:24 -08:00
|
|
|
show = () => this.setState(() => ({ showQRCode: true }));
|
2019-01-15 18:02:49 -08:00
|
|
|
|
2019-02-10 08:49:24 -08:00
|
|
|
hide = () => this.setState(() => ({ showQRCode: false }));
|
2019-01-15 18:02:49 -08:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { address } = this.props;
|
2019-02-10 08:49:24 -08:00
|
|
|
const { showQRCode } = this.state;
|
|
|
|
const toggleVisibility = showQRCode ? this.hide : this.show;
|
2019-01-15 18:02:49 -08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ColumnComponent width='100%'>
|
|
|
|
<AddressWrapper>
|
|
|
|
<Input
|
2019-02-10 08:49:24 -08:00
|
|
|
value={address}
|
2019-02-06 19:06:48 -08:00
|
|
|
onChange={() => {}}
|
2019-01-15 18:02:49 -08:00
|
|
|
onFocus={event => event.currentTarget.select()}
|
|
|
|
/>
|
2019-02-10 08:49:24 -08:00
|
|
|
<IconButton onClick={toggleVisibility}>
|
|
|
|
<IconImage
|
|
|
|
src={eyeIcon}
|
|
|
|
alt='See QRCode'
|
|
|
|
/>
|
|
|
|
</IconButton>
|
|
|
|
<IconButton onClick={() => {}}>
|
|
|
|
<IconImage
|
|
|
|
src={eyeIcon}
|
|
|
|
alt='Copy Address'
|
|
|
|
/>
|
|
|
|
</IconButton>
|
2019-01-15 18:02:49 -08:00
|
|
|
</AddressWrapper>
|
2019-02-10 08:49:24 -08:00
|
|
|
{!showQRCode ? null : (
|
2019-02-04 20:41:45 -08:00
|
|
|
<QRCodeWrapper>
|
|
|
|
<QRCode value={address} />
|
|
|
|
</QRCodeWrapper>
|
|
|
|
)}
|
2019-02-04 19:16:25 -08:00
|
|
|
</ColumnComponent>
|
2019-01-15 18:02:49 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|