Skip to content

Commit 19ada6b

Browse files
Odyssey98slient-coder
authored andcommitted
fix: alianName display
1 parent ee12616 commit 19ada6b

File tree

3 files changed

+65
-22
lines changed

3 files changed

+65
-22
lines changed

src/ui/pages/Account/SwitchKeyringScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export function MyItem({ keyring, autoNav }: MyItemProps, ref) {
8686
{selected ? <Icon icon="circle-check" color="gold" /> : <Icon icon="circle-check" color="white_muted2" />}
8787
</Column>
8888

89-
<Column justifyCenter>
90-
<Text text={`${keyring.alianName}`} />
89+
<Column justifyCenter style={{ height: 40 }}>
90+
<Text text={`${keyring.alianName}`} style={{ overflow: 'hidden', maxWidth: 180 }} />
9191
<Text text={`${displayAddress}`} preset="sub" />
9292
</Column>
9393
</Row>

src/ui/pages/Main/WalletTabScreen/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export default function WalletTabScreen() {
188188
onClick={() => {
189189
navigate('SwitchKeyringScreen');
190190
}}>
191-
<Text text={currentKeyring.alianName} size="xxs" />
191+
<Text text={currentKeyring.alianName} size="xxs" ellipsis style={{ maxWidth: 100 }} />
192192
</Card>
193193
}
194194
RightComponent={

src/ui/pages/Settings/EditWalletNameScreen.tsx

Lines changed: 62 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import { useMemo, useState } from 'react';
22
import { useLocation } from 'react-router-dom';
33

44
import { WalletKeyring } from '@/shared/types';
5-
import { Button, Column, Content, Header, Input, Layout } from '@/ui/components';
5+
import { Button, Column, Content, Header, Layout } from '@/ui/components';
66
import { useAppDispatch } from '@/ui/state/hooks';
77
import { keyringsActions } from '@/ui/state/keyrings/reducer';
8+
import { colors } from '@/ui/theme/colors';
89
import { useWallet } from '@/ui/utils';
910

1011
export default function EditWalletNameScreen() {
@@ -14,16 +15,16 @@ export default function EditWalletNameScreen() {
1415
};
1516

1617
const wallet = useWallet();
17-
const [alianName, setAlianName] = useState('');
18+
const [alianName, setAlianName] = useState(keyring.alianName || '');
1819
const dispatch = useAppDispatch();
1920
const handleOnClick = async () => {
2021
const newKeyring = await wallet.setKeyringAlianName(keyring, alianName || keyring.alianName);
2122
dispatch(keyringsActions.updateKeyringName(newKeyring));
2223
window.history.go(-1);
2324
};
2425

25-
const handleOnKeyUp = (e: React.KeyboardEvent<HTMLInputElement>) => {
26-
if ('Enter' == e.key) {
26+
const handleOnKeyUp = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
27+
if ('Enter' == e.key && e.ctrlKey) {
2728
handleOnClick();
2829
}
2930
};
@@ -35,25 +36,67 @@ export default function EditWalletNameScreen() {
3536
return true;
3637
}, [alianName]);
3738

39+
const calculateRows = useMemo(() => {
40+
return Math.min(5, Math.max(1, Math.ceil(alianName.length / 40)));
41+
}, [alianName]);
42+
43+
const truncatedTitle = useMemo(() => {
44+
if (keyring.alianName.length > 20) {
45+
return keyring.alianName.slice(0, 20) + '...';
46+
}
47+
return keyring.alianName;
48+
}, [keyring.alianName]);
49+
3850
return (
3951
<Layout>
40-
<Header
41-
onBack={() => {
42-
window.history.go(-1);
43-
}}
44-
title={keyring.alianName}
45-
/>
52+
<div style={{ position: 'relative' }}>
53+
<Header
54+
onBack={() => {
55+
window.history.go(-1);
56+
}}
57+
title={truncatedTitle}
58+
/>
59+
</div>
4660
<Content>
4761
<Column gap="lg">
48-
<Input
49-
placeholder={keyring.alianName}
50-
onChange={(e) => {
51-
setAlianName(e.target.value);
52-
}}
53-
defaultValue={keyring.alianName}
54-
onKeyUp={(e) => handleOnKeyUp(e)}
55-
autoFocus={true}
56-
/>
62+
<div
63+
style={{
64+
display: 'flex',
65+
flexDirection: 'row',
66+
alignItems: 'center',
67+
backgroundColor: colors.black,
68+
paddingLeft: 15.2,
69+
paddingRight: 15.2,
70+
borderRadius: 10,
71+
borderWidth: 1,
72+
borderColor: colors.line2
73+
}}>
74+
<textarea
75+
placeholder={keyring.alianName}
76+
onChange={(e) => {
77+
setAlianName(e.target.value);
78+
}}
79+
value={alianName}
80+
onKeyUp={handleOnKeyUp}
81+
autoFocus={true}
82+
rows={calculateRows}
83+
style={{
84+
display: 'flex',
85+
flex: 1,
86+
borderWidth: 0,
87+
outlineWidth: 0,
88+
backgroundColor: 'rgba(0,0,0,0)',
89+
alignSelf: 'stretch',
90+
padding: '11px 0',
91+
overflowWrap: 'break-word',
92+
wordWrap: 'break-word',
93+
wordBreak: 'break-all',
94+
whiteSpace: 'pre-wrap',
95+
resize: 'none',
96+
lineHeight: '22px'
97+
}}
98+
/>
99+
</div>
57100
<Button
58101
disabled={!isValidName}
59102
text="Change Wallet Name"

0 commit comments

Comments
 (0)