meriadec
7 years ago
7 changed files with 158 additions and 56 deletions
@ -0,0 +1,75 @@ |
|||
// @flow
|
|||
|
|||
import React from 'react' |
|||
import styled from 'styled-components' |
|||
|
|||
import Box from 'components/base/Box' |
|||
import QRCode from 'components/base/QRCode' |
|||
import Icon from 'components/base/Icon' |
|||
import CopyToClipboard from 'components/base/CopyToClipboard' |
|||
import Text from 'components/base/Text' |
|||
|
|||
type Props = { |
|||
address: string, |
|||
} |
|||
|
|||
const AddressBox = styled(Box).attrs({ |
|||
borderWidth: 1, |
|||
borderColor: 'mouse', |
|||
bg: 'cream', |
|||
p: 2, |
|||
})` |
|||
text-align: center; |
|||
word-break: break-all; |
|||
border-radius: 3px; |
|||
user-select: text; |
|||
` |
|||
|
|||
const Action = styled(Box).attrs({ |
|||
flow: 1, |
|||
flex: 1, |
|||
color: 'mouse', |
|||
fontSize: 0, |
|||
})` |
|||
font-weight: bold; |
|||
text-align: center; |
|||
cursor: pointer; |
|||
text-transform: uppercase; |
|||
|
|||
&:hover { |
|||
color: ${p => p.theme.colors.grey}; |
|||
} |
|||
` |
|||
|
|||
const ReceiveBox = ({ address }: Props) => ( |
|||
<Box flow={3}> |
|||
<Box align="center"> |
|||
<QRCode size={150} data={address} /> |
|||
</Box> |
|||
<Box align="center" flow={2}> |
|||
<Text fontSize={1}>{'Current address'}</Text> |
|||
<AddressBox>{address}</AddressBox> |
|||
</Box> |
|||
<Box horizontal> |
|||
<CopyToClipboard |
|||
data={address} |
|||
render={copy => ( |
|||
<Action onClick={copy}> |
|||
<Icon name="clone" /> |
|||
<span>{'Copy'}</span> |
|||
</Action> |
|||
)} |
|||
/> |
|||
<Action> |
|||
<Icon name="print" /> |
|||
<span>{'Print'}</span> |
|||
</Action> |
|||
<Action> |
|||
<Icon name="share-square-o" /> |
|||
<span>{'Share'}</span> |
|||
</Action> |
|||
</Box> |
|||
</Box> |
|||
) |
|||
|
|||
export default ReceiveBox |
@ -0,0 +1,41 @@ |
|||
// @flow
|
|||
|
|||
import React from 'react' |
|||
import { connect } from 'react-redux' |
|||
import values from 'lodash/values' |
|||
|
|||
import type { MapStateToProps } from 'react-redux' |
|||
|
|||
import { getAccounts } from 'reducers/accounts' |
|||
import Select from 'components/base/Select' |
|||
import Text from 'components/base/Text' |
|||
|
|||
import type { Account } from 'types/common' |
|||
|
|||
const mapStateToProps: MapStateToProps<*, *, *> = state => ({ |
|||
accounts: values(getAccounts(state)), |
|||
}) |
|||
|
|||
type Props = { |
|||
accounts: Array<Account>, |
|||
onChange: () => Account | void, |
|||
value: Account | null, |
|||
} |
|||
|
|||
const SelectAccount = ({ accounts, value, onChange }: Props) => ( |
|||
<Select |
|||
value={value} |
|||
placeholder="Choose an account" |
|||
items={accounts} |
|||
keyProp="id" |
|||
onChange={onChange} |
|||
itemToString={item => (item ? item.name : '')} |
|||
renderHighlight={(text, key) => ( |
|||
<Text key={key} fontWeight="bold"> |
|||
{text} |
|||
</Text> |
|||
)} |
|||
/> |
|||
) |
|||
|
|||
export default connect(mapStateToProps)(SelectAccount) |
@ -1,20 +1,48 @@ |
|||
// @flow
|
|||
|
|||
import React, { PureComponent } from 'react' |
|||
import { translate } from 'react-i18next' |
|||
|
|||
import Modal, { ModalBody } from 'components/base/Modal' |
|||
import Text from 'components/base/Text' |
|||
import SelectAccount from 'components/SelectAccount' |
|||
|
|||
type Props = {} |
|||
import type { Account as AccountType, T } from 'types/common' |
|||
|
|||
type Props = { |
|||
t: T, |
|||
} |
|||
|
|||
type State = { |
|||
account: AccountType | null, |
|||
} |
|||
|
|||
class ReceiveModal extends PureComponent<Props, State> { |
|||
state = { |
|||
account: null, |
|||
} |
|||
|
|||
handleChangeAccount = account => { |
|||
this.setState({ account }) |
|||
} |
|||
|
|||
class ReceiveModal extends PureComponent<Props> { |
|||
render() { |
|||
const { account } = this.state |
|||
const { t } = this.props |
|||
return ( |
|||
<Modal |
|||
name="receive" |
|||
render={({ onClose }) => <ModalBody onClose={onClose}>receive modal</ModalBody>} |
|||
render={({ onClose }) => ( |
|||
<ModalBody onClose={onClose} flow={3}> |
|||
<Text fontSize={4} color="steel"> |
|||
{t('receive.modalTitle')} |
|||
</Text> |
|||
<SelectAccount value={account} onChange={this.handleChangeAccount} /> |
|||
</ModalBody> |
|||
)} |
|||
/> |
|||
) |
|||
} |
|||
} |
|||
|
|||
export default ReceiveModal |
|||
export default translate()(ReceiveModal) |
|||
|
Loading…
Reference in new issue