Skip to content

Commit 8d58abc

Browse files
committed
feat(neuron-ui): adjust the layout of receive view to vertical aglinment.
1 parent c6b57f9 commit 8d58abc

4 files changed

Lines changed: 44 additions & 27 deletions

File tree

packages/neuron-ui/src/components/Receive/index.tsx

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useCallback, useMemo } from 'react'
22
import { RouteComponentProps } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
4-
import { Stack, Text, TextField, TooltipHost, Modal, FontSizes, IconButton } from 'office-ui-fabric-react'
4+
import { Stack, Text, TextField, TooltipHost, Modal, IconButton } from 'office-ui-fabric-react'
55

66
import { StateWithDispatch } from 'states/stateProvider/reducer'
77
import QRCode from 'widgets/QRCode'
@@ -28,35 +28,43 @@ const Receive = ({
2828
addPopup('addr-copied')(dispatch)
2929
}, [accountAddress, dispatch])
3030

31+
const Address = useMemo(
32+
() => (
33+
<Stack styles={{ root: { flex: 1, minWidth: 500 } }}>
34+
<TooltipHost content={t('receive.click-to-copy')} calloutProps={{ gapSpace: 0 }}>
35+
<Stack horizontal horizontalAlign="stretch" tokens={{ childrenGap: 15 }}>
36+
<TextField
37+
styles={{
38+
root: {
39+
flex: 1,
40+
color: '#888',
41+
},
42+
fieldGroup: {
43+
borderColor: '#eee!important',
44+
},
45+
}}
46+
readOnly
47+
placeholder={accountAddress}
48+
onClick={copyAddress}
49+
/>
50+
<IconButton iconProps={{ iconName: 'Copy' }} onClick={copyAddress} />
51+
</Stack>
52+
</TooltipHost>
53+
</Stack>
54+
),
55+
[copyAddress, accountAddress, t]
56+
)
57+
3158
if (!accountAddress) {
3259
return <div>{t('receive.address-not-found')}</div>
3360
}
3461

3562
return (
3663
<>
37-
<Stack horizontal tokens={{ childrenGap: 40, padding: '20px 0 0 0' }} horizontalAlign="space-between">
38-
<Stack styles={{ root: { flex: 1 } }}>
39-
<TooltipHost content={t('receive.click-to-copy')} calloutProps={{ gapSpace: 0 }}>
40-
<Stack horizontal horizontalAlign="stretch" tokens={{ childrenGap: 15 }}>
41-
<TextField
42-
styles={{
43-
root: {
44-
flex: 1,
45-
},
46-
description: {
47-
fontSize: FontSizes.medium,
48-
},
49-
}}
50-
readOnly
51-
placeholder={accountAddress}
52-
onClick={copyAddress}
53-
description={t('receive.prompt')}
54-
/>
55-
<IconButton iconProps={{ iconName: 'Copy' }} onClick={copyAddress} />
56-
</Stack>
57-
</TooltipHost>
58-
</Stack>
59-
64+
<Stack tokens={{ childrenGap: 10 }} horizontalAlign="center">
65+
<Text as="p" variant="medium">
66+
{`${t('receive.address', { network: accountAddress.startsWith('ckb') ? 'CKB Mainnet' : 'CKB Testnet' })}`}
67+
</Text>
6068
<Stack style={{ alignSelf: 'center' }}>
6169
<QRCode
6270
value={accountAddress}
@@ -65,8 +73,12 @@ const Receive = ({
6573
exportable
6674
includeMargin
6775
dispatch={dispatch}
76+
remark={Address}
6877
/>
6978
</Stack>
79+
<Text as="p" variant="medium">
80+
{t('receive.prompt')}
81+
</Text>
7082
</Stack>
7183

7284
<Modal isOpen={showLargeQRCode} onDismiss={() => setShowLargeQRCode(false)}>

packages/neuron-ui/src/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
"click-to-copy": "Click to copy the address",
107107
"address-not-found": "Address not found",
108108
"prompt": "Neuron picks a new receiving address for better privacy. Please go to the Address Book if you want to use a previously used receiving address.",
109-
"address-qrcode": "Address QR Code"
109+
"address-qrcode": "Address QR Code",
110+
"address": "{{network}} Address"
110111
},
111112
"history": {
112113
"meta": "Meta",

packages/neuron-ui/src/locales/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@
106106
"click-to-copy": "点击复制地址",
107107
"address-not-found": "未找到地址",
108108
"prompt": "为了保护隐私,Neuron 会自动选择一个新收款地址。如果您想使用旧的收款地址,请访问地址管理页面。",
109-
"address-qrcode": "地址二维码"
109+
"address-qrcode": "地址二维码",
110+
"address": "{{network}} 地址"
110111
},
111112
"history": {
112113
"meta": "元信息",

packages/neuron-ui/src/widgets/QRCode/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ const QRCode = ({
8282
includeMargin = false,
8383
exportable = false,
8484
dispatch,
85+
remark,
8586
}: {
8687
value: string
8788
size: number
@@ -93,6 +94,7 @@ const QRCode = ({
9394
includeMargin?: boolean
9495
exportable?: boolean
9596
dispatch: StateDispatch
97+
remark?: JSX.Element
9698
}) => {
9799
const [t] = useTranslation()
98100
const qrcode = new QRCodeImpl(-1, level)
@@ -156,8 +158,9 @@ const QRCode = ({
156158
<Stack.Item>
157159
<canvas ref={canvasRef} width={size} height={size} onClick={onQRCodeClick} />
158160
</Stack.Item>
161+
{remark || null}
159162
{exportable ? (
160-
<Stack horizontal horizontalAlign="space-between">
163+
<Stack horizontal horizontalAlign="space-between" styles={{ root: { minWidth: 500 } }}>
161164
<DefaultButton onClick={onCopy}>{t('qrcode.copy')}</DefaultButton>
162165
<DefaultButton onClick={onDownload}>{t('qrcode.save')}</DefaultButton>
163166
</Stack>

0 commit comments

Comments
 (0)