-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathMultichainAddressRow.tsx
More file actions
100 lines (89 loc) · 3.05 KB
/
MultichainAddressRow.tsx
File metadata and controls
100 lines (89 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import React, { useCallback } from 'react';
import { View } from 'react-native';
import Avatar, {
AvatarSize,
AvatarVariant,
} from '../../../components/Avatars/Avatar';
import ButtonIcon, {
ButtonIconSizes,
} from '../../../components/Buttons/ButtonIcon';
import Text, { TextVariant, TextColor } from '../../../components/Texts/Text';
import { IconName, IconColor } from '../../../components/Icons/Icon';
import { useStyles } from '../../../hooks';
import { formatAddress } from '../../../../util/address';
import { getNetworkImageSource } from '../../../../util/networks';
import styleSheet from './MultichainAddressRow.styles';
import { MultichainAddressRowProps } from './MultichainAddressRow.types';
import {
MULTICHAIN_ADDRESS_ROW_TEST_ID,
MULTICHAIN_ADDRESS_ROW_NETWORK_ICON_TEST_ID,
MULTICHAIN_ADDRESS_ROW_NETWORK_NAME_TEST_ID,
MULTICHAIN_ADDRESS_ROW_ADDRESS_TEST_ID,
MULTICHAIN_ADDRESS_ROW_COPY_BUTTON_TEST_ID,
MULTICHAIN_ADDRESS_ROW_QR_BUTTON_TEST_ID,
} from './MultichainAddressRow.constants';
import useCopyClipboard from '../../../../components/Views/Notifications/Details/hooks/useCopyClipboard';
const MultichainAddressRow = ({
chainId,
networkName,
address,
style,
testID = MULTICHAIN_ADDRESS_ROW_TEST_ID,
...props
}: MultichainAddressRowProps) => {
const { styles } = useStyles(styleSheet, { style });
const copyToClipboard = useCopyClipboard();
const networkImageSource = getNetworkImageSource({ chainId });
const truncatedAddress = formatAddress(address, 'short');
const handleCopyClick = useCallback(() => {
copyToClipboard(address);
}, [copyToClipboard, address]);
const handleQrClick = useCallback(() => {
// TODO: Implement QR code functionality
// QR code clicked for address: address
}, []);
return (
<View style={styles.base} testID={testID} {...props}>
<Avatar
variant={AvatarVariant.Network}
size={AvatarSize.Md}
name={networkName}
imageSource={networkImageSource}
testID={MULTICHAIN_ADDRESS_ROW_NETWORK_ICON_TEST_ID}
/>
<View style={styles.content}>
<Text
variant={TextVariant.BodyMDMedium}
color={TextColor.Default}
testID={MULTICHAIN_ADDRESS_ROW_NETWORK_NAME_TEST_ID}
>
{networkName}
</Text>
<Text
variant={TextVariant.BodySM}
color={TextColor.Alternative}
testID={MULTICHAIN_ADDRESS_ROW_ADDRESS_TEST_ID}
>
{truncatedAddress}
</Text>
</View>
<View style={styles.actions}>
<ButtonIcon
iconName={IconName.Copy}
size={ButtonIconSizes.Md}
onPress={handleCopyClick}
iconColor={IconColor.Default}
testID={MULTICHAIN_ADDRESS_ROW_COPY_BUTTON_TEST_ID}
/>
<ButtonIcon
iconName={IconName.QrCode}
size={ButtonIconSizes.Md}
onPress={handleQrClick}
iconColor={IconColor.Default}
testID={MULTICHAIN_ADDRESS_ROW_QR_BUTTON_TEST_ID}
/>
</View>
</View>
);
};
export default MultichainAddressRow;