Skip to content

Commit 305f930

Browse files
authored
feat: add account_network section to re-designed confirmation page (#11698)
## **Description** Add account and network section to re-designed confirmation pages. ## **Related issues** Fixes: #11680 ## **Manual testing steps** 1. Enable re-designs locally 2. Go to test dapp 3. Submit personal sign and check page ## **Screenshots/Recordings** https://github.com/user-attachments/assets/a47c1f1b-4f69-472c-a35c-5804d46ed6ec ## **Pre-merge author checklist** - [X] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [X] I've completed the PR template to the best of my ability - [X] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [X] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent 9e3d268 commit 305f930

29 files changed

+1356
-224
lines changed

app/components/Views/confirmations/Confirm/Confirm.styles.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const styleSheet = (params: { theme: Theme }) => {
1515
borderTopLeftRadius: 20,
1616
borderTopRightRadius: 20,
1717
paddingBottom: Device.isIphoneX() ? 20 : 0,
18-
alignItems: 'center',
19-
justifyContent: 'space-between'
18+
justifyContent: 'space-between',
2019
},
2120
});
2221
};

app/components/Views/confirmations/Confirm/Confirm.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { View } from 'react-native';
33

44
import { useStyles } from '../../../../component-library/hooks';
55
import BottomModal from '../components/UI/BottomModal';
6+
import AccountNetworkInfo from '../components/Confirm/AccountNetworkInfo';
67
import Footer from '../components/Confirm/Footer';
78
import Info from '../components/Confirm/Info';
89
import Title from '../components/Confirm/Title';
@@ -22,6 +23,7 @@ const Confirm = () => {
2223
<View style={styles.container}>
2324
<View>
2425
<Title />
26+
<AccountNetworkInfo />
2527
<Info />
2628
</View>
2729
<Footer />

app/components/Views/confirmations/Confirm/__snapshots__/Confirm.test.tsx.snap

Lines changed: 327 additions & 128 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
3+
import renderWithProvider from '../../../../../../util/test/renderWithProvider';
4+
import { personalSignatureConfirmationState } from '../../../../../../util/test/confirm-data-helpers';
5+
import AccountNetworkInfo from './AccountNetworkInfo';
6+
7+
describe('AccountNetworkInfo', () => {
8+
it('should match snapshot for personal sign', async () => {
9+
const container = renderWithProvider(<AccountNetworkInfo />, {
10+
state: personalSignatureConfirmationState,
11+
});
12+
expect(container).toMatchSnapshot();
13+
});
14+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
3+
import { strings } from '../../../../../../../locales/i18n';
4+
import useApprovalRequest from '../../../hooks/useApprovalRequest';
5+
import ExpandableSection from '../../UI/ExpandableSection';
6+
import AccountNetworkInfoCollapsed from './AccountNetworkInfoCollapsed';
7+
import AccountNetworkInfoExpanded from './AccountNetworkInfoExpanded';
8+
9+
const AccountNetworkInfo = () => {
10+
const { approvalRequest } = useApprovalRequest();
11+
12+
if (!approvalRequest) {
13+
return null;
14+
}
15+
16+
return (
17+
<ExpandableSection
18+
collapsedContent={<AccountNetworkInfoCollapsed />}
19+
expandedContent={<AccountNetworkInfoExpanded />}
20+
modalTitle={strings('confirm.details')}
21+
/>
22+
);
23+
};
24+
25+
export default AccountNetworkInfo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { StyleSheet } from 'react-native';
2+
3+
import { Theme } from '../../../../../../../util/theme/models';
4+
import { fontStyles } from '../../../../../../../styles/common';
5+
6+
const styleSheet = (params: { theme: Theme }) => {
7+
const { theme } = params;
8+
9+
return StyleSheet.create({
10+
container: {
11+
display: 'flex',
12+
flexDirection: 'row',
13+
},
14+
badgeWrapper: {
15+
marginRight: 16,
16+
alignSelf: 'center',
17+
},
18+
accountName: {
19+
color: theme.colors.text.default,
20+
...fontStyles.normal,
21+
fontSize: 14,
22+
fontWeight: '500',
23+
},
24+
networkName: {
25+
color: theme.colors.text.default,
26+
...fontStyles.normal,
27+
fontSize: 14,
28+
fontWeight: '400',
29+
},
30+
});
31+
};
32+
33+
export default styleSheet;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
3+
import renderWithProvider from '../../../../../../../util/test/renderWithProvider';
4+
import { personalSignatureConfirmationState } from '../../../../../../../util/test/confirm-data-helpers';
5+
import AccountNetworkInfoCollapsed from './AccountNetworkInfoCollapsed';
6+
7+
describe('AccountNetworkInfoCollapsed', () => {
8+
it('should match snapshot for personal sign', async () => {
9+
const container = renderWithProvider(<AccountNetworkInfoCollapsed />, {
10+
state: personalSignatureConfirmationState,
11+
});
12+
expect(container).toMatchSnapshot();
13+
});
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import React from 'react';
2+
import { Text, View } from 'react-native';
3+
import { useSelector } from 'react-redux';
4+
5+
import Avatar, {
6+
AvatarAccountType,
7+
AvatarVariant,
8+
} from '../../../../../../../component-library/components/Avatars/Avatar';
9+
import Badge, {
10+
BadgeVariant,
11+
} from '../../../../../../../component-library/components/Badges/Badge';
12+
import BadgeWrapper from '../../../../../../../component-library/components/Badges/BadgeWrapper';
13+
import { RootState } from '../../../../../../UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.test';
14+
import { useStyles } from '../../../../../../../component-library/hooks';
15+
import {
16+
selectNetworkImageSource,
17+
selectNetworkName,
18+
} from '../../../../../../../selectors/networkInfos';
19+
import useAccountInfo from '../../../../hooks/useAccountInfo';
20+
import useApprovalRequest from '../../../../hooks/useApprovalRequest';
21+
import styleSheet from './AccountNetworkInfoCollapsed.styles';
22+
23+
const AccountNetworkInfoCollapsed = () => {
24+
const { approvalRequest } = useApprovalRequest();
25+
const networkName = useSelector(selectNetworkName);
26+
const networkImage = useSelector(selectNetworkImageSource);
27+
const useBlockieIcon = useSelector(
28+
(state: RootState) => state.settings.useBlockieIcon,
29+
);
30+
const fromAddress = approvalRequest?.requestData?.from;
31+
const { accountName } = useAccountInfo(fromAddress);
32+
const { styles } = useStyles(styleSheet, {});
33+
34+
return (
35+
<View style={styles.container}>
36+
<BadgeWrapper
37+
badgeElement={
38+
<Badge
39+
variant={BadgeVariant.Network}
40+
name={networkName}
41+
imageSource={networkImage}
42+
/>
43+
}
44+
style={styles.badgeWrapper}
45+
>
46+
<Avatar
47+
variant={AvatarVariant.Account}
48+
type={
49+
useBlockieIcon
50+
? AvatarAccountType.Blockies
51+
: AvatarAccountType.JazzIcon
52+
}
53+
accountAddress={fromAddress}
54+
/>
55+
</BadgeWrapper>
56+
<View>
57+
<Text style={styles.accountName}>{accountName}</Text>
58+
<Text style={styles.networkName}>{networkName}</Text>
59+
</View>
60+
</View>
61+
);
62+
};
63+
64+
export default AccountNetworkInfoCollapsed;

app/components/Views/confirmations/components/Confirm/AccountNetworkInfo/AccountNetworkInfoCollapsed/__snapshots__/AccountNetworkInfoCollapsed.test.tsx.snap

Lines changed: 161 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './AccountNetworkInfoCollapsed';

0 commit comments

Comments
 (0)