-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathAddressCopy.tsx
More file actions
74 lines (66 loc) · 2.27 KB
/
AddressCopy.tsx
File metadata and controls
74 lines (66 loc) · 2.27 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
// Third parties dependencies
import React, { useCallback } from 'react';
import { useSelector } from 'react-redux';
import { View } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import { AccountGroupId } from '@metamask/account-api';
// External dependencies
import {
ButtonIcon,
ButtonIconSize,
IconName,
} from '@metamask/design-system-react-native';
import { strings } from '../../../../locales/i18n';
import { useStyles } from '../../../component-library/hooks';
import { WalletViewSelectorsIDs } from '../../Views/Wallet/WalletView.testIds';
import { selectSelectedAccountGroupId } from '../../../selectors/multichainAccounts/accountTreeController';
import { createAddressListNavigationDetails } from '../../Views/MultichainAccounts/AddressList';
// Internal dependencies
import styleSheet from './AddressCopy.styles';
import type { AddressCopyProps } from './AddressCopy.types';
import {
endTrace,
trace,
TraceName,
TraceOperation,
} from '../../../util/trace';
const AddressCopy = ({ iconColor, hitSlop }: AddressCopyProps) => {
const { styles } = useStyles(styleSheet, {});
const { navigate } = useNavigation();
const selectedAccountGroupId = useSelector(selectSelectedAccountGroupId);
const handleOnPress = useCallback(() => {
// Start the trace before navigating to the address list to include the
// navigation and render times in the trace.
trace({
name: TraceName.ShowAccountAddressList,
op: TraceOperation.AccountUi,
tags: {
screen: 'navbar.copy_address',
},
});
navigate(
...createAddressListNavigationDetails({
groupId: selectedAccountGroupId as AccountGroupId,
title: `${strings(
'multichain_accounts.address_list.receiving_address',
)}`,
onLoad: () => {
endTrace({ name: TraceName.ShowAccountAddressList });
},
}),
);
}, [navigate, selectedAccountGroupId]);
return (
<View style={styles.address}>
<ButtonIcon
iconName={IconName.Copy}
size={ButtonIconSize.Lg}
iconProps={iconColor && { color: iconColor }}
onPress={handleOnPress}
testID={WalletViewSelectorsIDs.ACCOUNT_COPY_BUTTON}
hitSlop={hitSlop}
/>
</View>
);
};
export default AddressCopy;