Skip to content

Commit 584dde0

Browse files
committed
feat: adjusted the entry UI display for Keystone.
1 parent 60c6ff6 commit 584dde0

File tree

7 files changed

+131
-18
lines changed

7 files changed

+131
-18
lines changed
6.42 KB
Loading
2.35 KB
Loading
11.2 KB
Loading

src/shared/constant/index.ts

+21
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,24 @@ export const PAYMENT_CHANNELS = {
318318
img: './images/artifacts/transak.png'
319319
}
320320
};
321+
322+
export enum HardwareWalletType {
323+
Keystone = 'keystone',
324+
Ledger = 'ledger',
325+
Trezor = 'trezor'
326+
}
327+
328+
export const HARDWARE_WALLETS = {
329+
[HardwareWalletType.Keystone]: {
330+
name: 'Keystone',
331+
img: './images/artifacts/keystone.png'
332+
},
333+
[HardwareWalletType.Ledger]: {
334+
name: 'Ledger',
335+
img: './images/artifacts/ledger.png'
336+
},
337+
[HardwareWalletType.Trezor]: {
338+
name: 'Trezor',
339+
img: './images/artifacts/trezor.png'
340+
}
341+
};

src/ui/pages/Account/AddKeyringScreen.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Card, Column, Content, Header, Layout, Text } from '@/ui/components';
2-
32
import { useExtensionIsInTab } from '@/ui/features/browser/tabs';
3+
44
import { useNavigate } from '../MainRoute';
55

66
export default function AddKeyringScreen() {
@@ -51,7 +51,7 @@ export default function AddKeyringScreen() {
5151
</Column>
5252
</Card>
5353

54-
<Text text="Conncet Hardware Wallet" preset="regular-bold" mt="lg" />
54+
<Text text="Connect to Hardware Wallet" preset="regular-bold" mt="lg" />
5555

5656
<Card
5757
justifyCenter
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { HARDWARE_WALLETS, HardwareWalletType } from '@/shared/constant';
2+
import { Card, Column, Image, Row, Text } from '@/ui/components';
3+
import { useTools } from '@/ui/components/ActionComponent';
4+
import { BottomModal } from '@/ui/components/BottomModal';
5+
import { useExtensionIsInTab } from '@/ui/features/browser/tabs';
6+
import { colors } from '@/ui/theme/colors';
7+
import { useWallet } from '@/ui/utils';
8+
import { CloseOutlined } from '@ant-design/icons';
9+
10+
import { useNavigate } from '../MainRoute';
11+
12+
function WalletItem(props: { walletType: HardwareWalletType; onClick?: () => void; disabled?: boolean }) {
13+
const walletInfo = HARDWARE_WALLETS[props.walletType];
14+
const tools = useTools();
15+
16+
return (
17+
<Card
18+
style={{ backgroundColor: 'rgba(255,255,255,0.1)', borderRadius: 10, opacity: props.disabled ? 0.4 : 1 }}
19+
mt="lg"
20+
onClick={() => {
21+
if (props.disabled) {
22+
tools.toast('Coming soon');
23+
} else {
24+
props.onClick && props.onClick();
25+
}
26+
}}>
27+
<Row fullX>
28+
<Row itemsCenter>
29+
<Image src={walletInfo.img} size={30} />
30+
<Text text={walletInfo.name} />
31+
</Row>
32+
</Row>
33+
</Card>
34+
);
35+
}
36+
37+
export const ConnectHardwareModal = ({ onClose }: { onClose: () => void }) => {
38+
const wallet = useWallet();
39+
40+
const isInTab = useExtensionIsInTab();
41+
const navigate = useNavigate();
42+
43+
return (
44+
<BottomModal onClose={onClose}>
45+
<Column justifyCenter itemsCenter>
46+
<Row justifyBetween itemsCenter style={{ height: 20 }} fullX>
47+
<Row />
48+
<Text text="Connect to Hardware Wallet" textCenter size="md" />
49+
<Row
50+
onClick={() => {
51+
onClose();
52+
}}>
53+
<CloseOutlined />
54+
</Row>
55+
</Row>
56+
57+
<Row fullX style={{ borderTopWidth: 1, borderColor: colors.border }} my="md" />
58+
59+
<Column gap="zero" mt="sm" mb="lg">
60+
<Text
61+
size="sm"
62+
color="textDim"
63+
text={`The hardware wallet feature is experimental. Use it with caution as potential issues may arise`}
64+
/>
65+
66+
<WalletItem
67+
walletType={HardwareWalletType.Keystone}
68+
onClick={async () => {
69+
const isBooted = await wallet.isBooted();
70+
if (!isInTab) {
71+
if (isBooted) {
72+
window.open('#/account/create-keystone-wallet');
73+
} else {
74+
window.open('#/account/create-password?isKeystone=true');
75+
}
76+
return;
77+
}
78+
if (isBooted) {
79+
navigate('CreateKeystoneWalletScreen');
80+
} else {
81+
navigate('CreatePasswordScreen', { isKeystone: true });
82+
}
83+
}}
84+
/>
85+
86+
<WalletItem walletType={HardwareWalletType.Ledger} disabled />
87+
<WalletItem walletType={HardwareWalletType.Trezor} disabled />
88+
</Column>
89+
</Column>
90+
</BottomModal>
91+
);
92+
};

src/ui/pages/Main/WelcomeScreen.tsx

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
/* eslint-disable quotes */
2+
import { useState } from 'react';
3+
24
import { Button, Column, Content, Layout, Logo, Row, Text } from '@/ui/components';
5+
import { useExtensionIsInTab } from '@/ui/features/browser/tabs';
36
import { useWallet } from '@/ui/utils';
47

5-
import { useExtensionIsInTab } from '@/ui/features/browser/tabs';
68
import { useNavigate } from '../MainRoute';
9+
import { ConnectHardwareModal } from './ConnectHardwareModal';
710

811
export default function WelcomeScreen() {
912
const navigate = useNavigate();
1013
const wallet = useWallet();
1114
const isInTab = useExtensionIsInTab();
1215

16+
const [connectHardwareModalVisible, setConnectHardwareModalVisible] = useState(false);
17+
1318
return (
1419
<Layout>
1520
<Content preset="middle">
@@ -49,25 +54,20 @@ export default function WelcomeScreen() {
4954
}}
5055
/>
5156
<Button
52-
text="Connect Keystone"
57+
text="Connect to Hardware Wallet"
5358
preset="default"
5459
onClick={async () => {
55-
const isBooted = await wallet.isBooted();
56-
if (!isInTab) {
57-
if (isBooted) {
58-
window.open('#/account/create-keystone-wallet');
59-
} else {
60-
window.open('#/account/create-password?isKeystone=true');
61-
}
62-
return
63-
}
64-
if (isBooted) {
65-
navigate('CreateKeystoneWalletScreen');
66-
} else {
67-
navigate('CreatePasswordScreen', { isKeystone: true });
68-
}
60+
setConnectHardwareModalVisible(true);
6961
}}
7062
/>
63+
64+
{connectHardwareModalVisible && (
65+
<ConnectHardwareModal
66+
onClose={() => {
67+
setConnectHardwareModalVisible(false);
68+
}}
69+
/>
70+
)}
7171
</Column>
7272
</Column>
7373
</Content>

0 commit comments

Comments
 (0)