2018-11-23 15:23:41 -08:00
|
|
|
// @flow
|
2019-02-04 20:41:45 -08:00
|
|
|
|
2019-01-31 13:28:06 -08:00
|
|
|
import React, { PureComponent } from 'react';
|
2019-02-18 09:25:16 -08:00
|
|
|
import styled, { withTheme } from 'styled-components';
|
2019-01-23 21:08:20 -08:00
|
|
|
import { Transition, animated } from 'react-spring';
|
2019-01-07 10:06:40 -08:00
|
|
|
|
2019-02-18 09:25:16 -08:00
|
|
|
import { DARK } from '../constants/themes';
|
|
|
|
|
2019-01-07 10:06:40 -08:00
|
|
|
import { InputLabelComponent } from '../components/input-label';
|
|
|
|
import { RowComponent } from '../components/row';
|
2019-01-23 21:08:20 -08:00
|
|
|
import { TextComponent } from '../components/text';
|
2019-01-15 18:02:49 -08:00
|
|
|
import { WalletAddress } from '../components/wallet-address';
|
2019-01-07 10:06:40 -08:00
|
|
|
|
2019-02-18 09:25:16 -08:00
|
|
|
import MenuIconDark from '../assets/images/menu_icon_dark.svg';
|
|
|
|
import MenuIconLight from '../assets/images/menu_icon_light.svg';
|
|
|
|
import PlusIconDark from '../assets/images/plus_icon_dark.svg';
|
|
|
|
import PlusIconLight from '../assets/images/plus_icon_light.svg';
|
2019-01-30 07:16:10 -08:00
|
|
|
|
|
|
|
import type { addressType } from '../redux/modules/receive';
|
2019-01-07 10:06:40 -08:00
|
|
|
|
2019-01-08 08:01:57 -08:00
|
|
|
const Row = styled(RowComponent)`
|
|
|
|
margin-bottom: 10px;
|
|
|
|
`;
|
|
|
|
|
2019-01-07 10:06:40 -08:00
|
|
|
const Label = styled(InputLabelComponent)`
|
2019-01-23 21:08:20 -08:00
|
|
|
text-transform: uppercase;
|
2019-02-07 08:31:59 -08:00
|
|
|
color: ${props => props.theme.colors.transactionsDate};
|
|
|
|
font-size: ${props => `${props.theme.fontSize.regular * 0.9}em`};
|
|
|
|
font-weight: ${props => String(props.theme.fontWeight.bold)};
|
2019-01-23 21:08:20 -08:00
|
|
|
margin-bottom: 5px;
|
|
|
|
`;
|
|
|
|
|
2019-01-30 07:16:10 -08:00
|
|
|
const ActionButton = styled.button`
|
2019-01-23 21:08:20 -08:00
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
cursor: pointer;
|
|
|
|
width: 100%;
|
2019-02-07 08:31:59 -08:00
|
|
|
color: ${props => props.theme.colors.text};
|
2019-01-23 21:08:20 -08:00
|
|
|
outline: none;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2019-02-17 19:56:50 -08:00
|
|
|
margin: 15px 0;
|
2019-01-23 21:08:20 -08:00
|
|
|
opacity: 0.7;
|
2019-02-17 19:56:50 -08:00
|
|
|
width: auto;
|
2019-01-23 21:08:20 -08:00
|
|
|
|
|
|
|
&:hover {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
2019-01-07 10:06:40 -08:00
|
|
|
`;
|
2018-11-23 15:23:41 -08:00
|
|
|
|
2019-02-17 19:56:50 -08:00
|
|
|
const ActionText = styled(TextComponent)`
|
|
|
|
white-space: nowrap;
|
|
|
|
`;
|
|
|
|
|
2019-01-30 07:16:10 -08:00
|
|
|
const ActionIcon = styled.img`
|
2019-01-23 21:08:20 -08:00
|
|
|
width: 25px;
|
|
|
|
height: 25px;
|
2019-02-07 08:31:59 -08:00
|
|
|
border: 1px solid ${props => props.theme.colors.text};
|
2019-01-23 21:08:20 -08:00
|
|
|
border-radius: 100%;
|
|
|
|
margin-right: 11.5px;
|
2019-02-18 09:25:16 -08:00
|
|
|
padding: 2px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const PlusIcon = styled(ActionIcon)`
|
|
|
|
padding: 6.5px;
|
2019-01-23 21:08:20 -08:00
|
|
|
`;
|
|
|
|
|
|
|
|
const RevealsMain = styled.div`
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
position: relative;
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-start;
|
|
|
|
justify-content: flex-start;
|
|
|
|
`;
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
addresses: Array<string>,
|
|
|
|
loadAddresses: () => void,
|
2019-01-30 07:16:10 -08:00
|
|
|
getNewAddress: ({ type: addressType }) => void,
|
2019-02-18 09:25:16 -08:00
|
|
|
theme: AppTheme,
|
2019-01-23 21:08:20 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
type State = {
|
|
|
|
showAdditionalOptions: boolean,
|
2019-01-28 07:05:03 -08:00
|
|
|
};
|
2019-01-23 21:08:20 -08:00
|
|
|
|
2019-02-18 09:25:16 -08:00
|
|
|
class Component extends PureComponent<Props, State> {
|
2019-01-23 21:08:20 -08:00
|
|
|
state = {
|
|
|
|
showAdditionalOptions: false,
|
|
|
|
};
|
|
|
|
|
2019-01-21 10:37:04 -08:00
|
|
|
componentDidMount() {
|
|
|
|
const { loadAddresses } = this.props;
|
|
|
|
|
|
|
|
loadAddresses();
|
|
|
|
}
|
|
|
|
|
2019-01-23 21:08:20 -08:00
|
|
|
toggleAdditionalOptions = () => this.setState((prevState: State) => ({
|
|
|
|
showAdditionalOptions: !prevState.showAdditionalOptions,
|
|
|
|
}));
|
|
|
|
|
2019-01-31 13:28:06 -08:00
|
|
|
generateNewAddress = (type: addressType) => {
|
|
|
|
const { getNewAddress } = this.props;
|
|
|
|
|
|
|
|
getNewAddress({ type });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2019-02-18 09:25:16 -08:00
|
|
|
const { addresses, theme } = this.props;
|
2019-01-23 21:08:20 -08:00
|
|
|
const { showAdditionalOptions } = this.state;
|
|
|
|
const buttonText = `${showAdditionalOptions ? 'Hide' : 'Show'} Other Address Types`;
|
|
|
|
|
2019-01-31 13:28:06 -08:00
|
|
|
const shieldedAddresses = addresses.filter(addr => addr.startsWith('z'));
|
|
|
|
const transparentAddresses = addresses.filter(addr => addr.startsWith('t'));
|
|
|
|
|
2019-02-18 09:25:16 -08:00
|
|
|
|
|
|
|
const seeMoreIcon = theme.mode === DARK
|
|
|
|
? MenuIconDark
|
|
|
|
: MenuIconLight;
|
|
|
|
|
|
|
|
const plusIcon = theme.mode === DARK
|
|
|
|
? PlusIconDark
|
|
|
|
: PlusIconLight;
|
|
|
|
|
2019-01-23 21:08:20 -08:00
|
|
|
return (
|
2019-01-31 13:28:06 -08:00
|
|
|
<div>
|
2019-01-23 21:08:20 -08:00
|
|
|
<Label value='Shielded Address' />
|
2019-01-31 13:28:06 -08:00
|
|
|
{shieldedAddresses.map(addr => (
|
2019-02-17 19:56:50 -08:00
|
|
|
<WalletAddress
|
|
|
|
key={addr}
|
|
|
|
address={addr}
|
|
|
|
/>
|
2019-01-31 13:28:06 -08:00
|
|
|
))}
|
2019-02-17 19:56:50 -08:00
|
|
|
<Row justifyContent='space-between'>
|
2019-02-06 19:06:48 -08:00
|
|
|
<ActionButton onClick={() => this.generateNewAddress('shielded')}>
|
2019-02-18 09:25:16 -08:00
|
|
|
<PlusIcon
|
|
|
|
src={plusIcon}
|
2019-02-17 19:56:50 -08:00
|
|
|
alt='New Shielded Address'
|
|
|
|
/>
|
|
|
|
<ActionText value='New Shielded Address' />
|
2019-01-30 07:16:10 -08:00
|
|
|
</ActionButton>
|
2019-02-17 19:56:50 -08:00
|
|
|
<ActionButton
|
|
|
|
onClick={this.toggleAdditionalOptions}
|
|
|
|
isActive={showAdditionalOptions}
|
|
|
|
>
|
|
|
|
<ActionIcon
|
|
|
|
isActive={showAdditionalOptions}
|
2019-02-18 09:25:16 -08:00
|
|
|
src={seeMoreIcon}
|
2019-02-17 19:56:50 -08:00
|
|
|
alt='More Options'
|
|
|
|
/>
|
|
|
|
<ActionText value={buttonText} />
|
2019-01-30 07:16:10 -08:00
|
|
|
</ActionButton>
|
2019-01-23 21:08:20 -08:00
|
|
|
</Row>
|
2019-01-31 13:28:06 -08:00
|
|
|
<RevealsMain>
|
|
|
|
<Transition
|
|
|
|
native
|
|
|
|
items={showAdditionalOptions}
|
|
|
|
enter={[{ opacity: 1 }]}
|
|
|
|
leave={{ height: 0, opacity: 0 }}
|
|
|
|
from={{
|
|
|
|
position: 'absolute',
|
|
|
|
overflow: 'hidden',
|
|
|
|
height: 0,
|
|
|
|
opacity: 0,
|
|
|
|
}}
|
|
|
|
>
|
2019-02-06 19:06:48 -08:00
|
|
|
{(show: boolean) => show
|
|
|
|
&& ((props: Object) => (
|
2019-02-04 20:41:45 -08:00
|
|
|
<animated.div
|
|
|
|
style={{
|
|
|
|
...props,
|
|
|
|
width: '100%',
|
|
|
|
height: 'auto',
|
|
|
|
}}
|
|
|
|
>
|
2019-01-31 13:28:06 -08:00
|
|
|
<Label value='Transparent Address (not private)' />
|
|
|
|
{transparentAddresses.map(addr => (
|
2019-02-06 19:06:48 -08:00
|
|
|
<WalletAddress key={addr} address={addr} />
|
2019-01-31 13:28:06 -08:00
|
|
|
))}
|
2019-02-17 19:56:50 -08:00
|
|
|
<ActionButton onClick={() => this.generateNewAddress('transparent')}>
|
2019-02-18 09:25:16 -08:00
|
|
|
<PlusIcon src={plusIcon} alt='New Transparent Address' />
|
2019-02-17 19:56:50 -08:00
|
|
|
<ActionText value='New Transparent Address' />
|
|
|
|
</ActionButton>
|
2019-01-31 13:28:06 -08:00
|
|
|
</animated.div>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</Transition>
|
|
|
|
</RevealsMain>
|
2019-01-23 21:08:20 -08:00
|
|
|
</div>
|
2019-01-21 10:37:04 -08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-02-18 09:25:16 -08:00
|
|
|
|
|
|
|
export const ReceiveView = withTheme(Component);
|