Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding title to confirmation page #11478

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/components/Views/confirmations/Confirm/Confirm.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import { Text, View } from 'react-native';
import { View } from 'react-native';

import BottomModal from '../../../../components/UI/BottomModal';
import { useTheme } from '../../../../util/theme';
import Footer from '../components/Confirm/Footer';
import Title from '../components/Confirm/Title';
import useConfirmationRedesignEnabled from '../hooks/useConfirmationRedesignEnabled';
import createStyles from './style';

Expand All @@ -20,7 +21,7 @@ const Confirm = () => {
return (
<BottomModal>
<View style={styles.container}>
<Text>TODO</Text>
<Title />
<Footer />
</View>
</BottomModal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ exports[`Confirm should match snapshot for personal sign 1`] = `
style={
{
"alignItems": "center",
"backgroundColor": "#ffffff",
"backgroundColor": "#f2f4f6",
"borderTopLeftRadius": 20,
"borderTopRightRadius": 20,
"minHeight": "90%",
Expand All @@ -127,9 +127,26 @@ exports[`Confirm should match snapshot for personal sign 1`] = `
}
}
>
<Text>
TODO
</Text>
<View
style={
{
"marginBottom": 10,
}
}
>
<Text
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Bold",
"fontSize": 18,
"fontWeight": "700",
}
}
>
Signature request
</Text>
</View>
<View
style={
{
Expand Down Expand Up @@ -157,6 +174,7 @@ exports[`Confirm should match snapshot for personal sign 1`] = `
"borderWidth": 1,
},
{
"backgroundColor": "#f2f4f6",
"flex": 1,
},
],
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/confirmations/Confirm/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Colors } from '../../../../util/theme/models';
const createStyles = (colors: Colors) =>
StyleSheet.create({
container: {
backgroundColor: colors.background.default,
backgroundColor: colors.background.alternative,
paddingTop: 24,
minHeight: '90%',
borderTopLeftRadius: 20,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const Footer = () => {
<View style={styles.buttonsContainer}>
<StyledButton
onPress={onReject}
containerStyle={styles.fill}
containerStyle={styles.rejectButton}
type={'normal'}
>
{strings('confirm.reject')}
</StyledButton>
<View style={styles.buttonDivider} />
<StyledButton
onPress={onConfirm}
containerStyle={styles.fill}
containerStyle={styles.confirmButton}
type={'confirm'}
>
{strings('confirm.confirm')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ exports[`Footer should match snapshot for personal sign 1`] = `
"borderWidth": 1,
},
{
"backgroundColor": "#f2f4f6",
"flex": 1,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { Colors } from '../../../../../../util/theme/models';

const createStyles = (colors: Colors) =>
StyleSheet.create({
fill: {
confirmButton: {
flex: 1,
},
rejectButton: {
flex: 1,
backgroundColor: colors.background.alternative,
},
divider: {
height: 1,
backgroundColor: colors.border.muted,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

import renderWithProvider from '../../../../../../util/test/renderWithProvider';
import { personalSignatureConfirmationState } from '../../../../../../util/test/confirm-data-helpers';
import Title from './index';

describe('Title', () => {
it('should match snapshot for personal sign', async () => {
const container = renderWithProvider(<Title />, {
state: personalSignatureConfirmationState,
});
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React, { useMemo } from 'react';
import { Text, View } from 'react-native';
import { TransactionType } from '@metamask/transaction-controller';

import { strings } from '../../../../../../../locales/i18n';
import { useTheme } from '../../../../../../util/theme';
import useApprovalRequest from '../../../hooks/useApprovalRequest';
import createStyles from './style';

const getTitle = (confirmationType?: string) => {
switch (confirmationType) {
case TransactionType.personalSign:
return strings('confirm.title.signature');
default:
return '';
}
};

const Title = () => {
jpuri marked this conversation as resolved.
Show resolved Hide resolved
const { approvalRequest } = useApprovalRequest();
const { colors } = useTheme();

const styles = createStyles(colors);
const title = useMemo(
jpuri marked this conversation as resolved.
Show resolved Hide resolved
() => getTitle(approvalRequest?.type),
[approvalRequest?.type],
);

return (
<View style={styles.titleContainer}>
<Text style={styles.title}>{title}</Text>
</View>
);
};

export default Title;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Title should match snapshot for personal sign 1`] = `
<View
style={
{
"marginBottom": 10,
}
}
>
<Text
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Bold",
"fontSize": 18,
"fontWeight": "700",
}
}
>
Signature request
</Text>
</View>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Title';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { StyleSheet } from 'react-native';

import { Colors } from '../../../../../../util/theme/models';
import { fontStyles } from '../../../../../../styles/common';

const createStyles = (colors: Colors) =>
StyleSheet.create({
titleContainer: {
marginBottom: 10,
},
title: {
color: colors.text.default,
...fontStyles.bold,
fontSize: 18,
fontWeight: '700'
}
});

export default createStyles;
5 changes: 4 additions & 1 deletion locales/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3401,6 +3401,9 @@
},
"confirm": {
"reject": "Reject",
"confirm": "Confirm"
"confirm": "Confirm",
"title": {
"signature": "Signature request"
}
}
}
Loading