Skip to content

Commit d9d4de0

Browse files
OGPoyrazjpuri
andauthored
feat: Implement confirm layout (#13331)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> This PR adds flat confirmation layout in re-designed confirmations. ## **Related issues** Fixes: Task is currently in draft ## **Manual testing steps** N/A ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **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 - [X] 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. --------- Co-authored-by: jpuri <[email protected]>
1 parent c7c8ecf commit d9d4de0

File tree

2 files changed

+49
-12
lines changed

2 files changed

+49
-12
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ const styleSheet = (params: { theme: Theme }) => {
77
const { theme } = params;
88

99
return StyleSheet.create({
10+
mainContainer: {
11+
position: 'absolute',
12+
top: 0,
13+
left: 0,
14+
right: 0,
15+
bottom: 0,
16+
zIndex: 9999,
17+
backgroundColor: theme.colors.background.alternative,
18+
justifyContent: 'space-between',
19+
paddingHorizontal: 16,
20+
},
1021
container: {
1122
backgroundColor: theme.colors.background.alternative,
1223
paddingHorizontal: 16,

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

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,63 @@
11
import React from 'react';
2-
import { View } from 'react-native';
2+
import { View, ScrollView } from 'react-native';
3+
import { SafeAreaView } from 'react-native-safe-area-context';
4+
import { TransactionType } from '@metamask/transaction-controller';
35

46
import { useStyles } from '../../../../component-library/hooks';
5-
import BottomModal from '../components/UI/BottomModal';
67
import AccountNetworkInfo from '../components/Confirm/AccountNetworkInfo';
8+
import BottomModal from '../components/UI/BottomModal';
79
import Footer from '../components/Confirm/Footer';
810
import Info from '../components/Confirm/Info';
911
import SignatureBlockaidBanner from '../components/Confirm/SignatureBlockaidBanner';
1012
import Title from '../components/Confirm/Title';
1113
import useApprovalRequest from '../hooks/useApprovalRequest';
1214
import { useConfirmationRedesignEnabled } from '../hooks/useConfirmationRedesignEnabled';
15+
1316
import styleSheet from './Confirm.styles';
1417

18+
// todo: if possible derive way to dynamically check if confirmation should be rendered flat
19+
// todo: unit test coverage to be added once we have flat confirmations in place
20+
const FLAT_CONFIRMATIONS: TransactionType[] = [
21+
// To be filled with flat confirmations
22+
];
23+
24+
const ConfirmWrapped = () => (
25+
<>
26+
<ScrollView>
27+
<Title />
28+
<SignatureBlockaidBanner />
29+
<AccountNetworkInfo />
30+
<Info />
31+
</ScrollView>
32+
<Footer />
33+
</>
34+
);
35+
1536
const Confirm = () => {
16-
const { isRedesignedEnabled } = useConfirmationRedesignEnabled();
1737
const { approvalRequest } = useApprovalRequest();
38+
const { isRedesignedEnabled } = useConfirmationRedesignEnabled();
1839
const { styles } = useStyles(styleSheet, {});
1940

2041
if (!isRedesignedEnabled) {
2142
return null;
2243
}
2344

45+
const isFlatConfirmation = FLAT_CONFIRMATIONS.includes(
46+
approvalRequest?.type as TransactionType,
47+
);
48+
49+
if (isFlatConfirmation) {
50+
return (
51+
<SafeAreaView style={styles.mainContainer}>
52+
<ConfirmWrapped />
53+
</SafeAreaView>
54+
);
55+
}
56+
2457
return (
2558
<BottomModal canCloseOnBackdropClick={false}>
26-
<View style={styles.container} testID={approvalRequest?.type}>
27-
<View>
28-
<Title />
29-
{/* TODO: component SignatureBlockaidBanner to be removed once we implement alert system in mobile */}
30-
<SignatureBlockaidBanner />
31-
<AccountNetworkInfo />
32-
<Info />
33-
</View>
34-
<Footer />
59+
<View style={styles.container}>
60+
<ConfirmWrapped />
3561
</View>
3662
</BottomModal>
3763
);

0 commit comments

Comments
 (0)