Skip to content

feat: Add advanced details row into transfer confirmations #15004

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ const styleSheet = (params: { theme: Theme, vars: { isCompact: boolean | undefin
width: '90%',
textAlign: 'center',
},
expandIcon: {
position: 'absolute',
right: 16,
},
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { fireEvent, render } from '@testing-library/react-native';

import InfoSection from '../info-row/info-section';
import InfoRow from '../info-row/info-row';
import ExpandableSection from './expandable-section';
import Expandable from './expandable';

describe('ExpandableSection', () => {
it('should render correctly for simple ExpandableSection', async () => {
describe('Expandable', () => {
it('should render correctly for simple Expandable', async () => {
const { getByText } = render(
<ExpandableSection
<Expandable
collapsedContent={
<View>
<Text>Open</Text>
Expand All @@ -28,7 +28,7 @@ describe('ExpandableSection', () => {

it('should display default content', async () => {
const { getByText } = render(
<ExpandableSection
<Expandable
collapsedContent={
<View>
<Text>Open</Text>
Expand All @@ -47,7 +47,7 @@ describe('ExpandableSection', () => {

it('should open modal when right icon is pressed', async () => {
const { getByTestId, getByText } = render(
<ExpandableSection
<Expandable
collapsedContent={
<View>
<Text>Open</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@ import { TouchableOpacity, View } from 'react-native';
import ButtonIcon, {
ButtonIconSizes,
} from '../../../../../../component-library/components/Buttons/ButtonIcon';
import Icon, {
import {
IconColor,
IconName,
IconSize,
} from '../../../../../../component-library/components/Icons/Icon';
import Text from '../../../../../../component-library/components/Texts/Text';
import { useStyles } from '../../../../../../component-library/hooks';
import BottomModal from '../bottom-modal';
import styleSheet from './expandable-section.styles';
import styleSheet from './expandable.styles';

interface ExpandableSectionProps {
interface ExpandableProps {
collapsedContent: ReactNode;
expandedContent: ReactNode;
expandedContentTitle: string;
iconVerticalPosition?: IconVerticalPosition;
collapseButtonTestID?: string;
testID?: string;
isCompact?: boolean;
Expand All @@ -28,21 +26,17 @@ export enum IconVerticalPosition {
Top = 'top',
}

const ExpandableSection = ({
const Expandable = ({
collapsedContent,
expandedContent,
expandedContentTitle,
iconVerticalPosition,
collapseButtonTestID,
testID,
isCompact,
}: ExpandableSectionProps) => {
}: ExpandableProps) => {
const { styles } = useStyles(styleSheet, { isCompact });
const [expanded, setExpanded] = useState(false);

const iconStyle =
iconVerticalPosition === IconVerticalPosition.Top ? { top: 20 } : {};

return (
<>
<TouchableOpacity
Expand All @@ -53,18 +47,7 @@ const ExpandableSection = ({
activeOpacity={1}
testID={testID ?? 'expandableSection'}
>
<View style={styles.container}>
{collapsedContent}
<Icon
color={IconColor.Muted}
size={IconSize.Sm}
name={IconName.ArrowRight}
style={{
...styles.expandIcon,
...iconStyle,
}}
/>
</View>
{collapsedContent}
</TouchableOpacity>
{expanded && (
<BottomModal onClose={() => setExpanded(false)}>
Expand All @@ -89,4 +72,4 @@ const ExpandableSection = ({
);
};

export default ExpandableSection;
export default Expandable;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './expandable';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { StyleSheet } from 'react-native';

const styleSheet = () => StyleSheet.create({
infoRowOverride: {
paddingBottom: 4,
paddingHorizontal: 8,
},
});

export default styleSheet;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { useAlerts } from '../../../../context/alert-system-context';
import { useConfirmationAlertMetrics } from '../../../../hooks/metrics/useConfirmationAlertMetrics';
import { Severity } from '../../../../types/alerts';
import { TextColor } from '../../../../../../../component-library/components/Texts/Text';
import { useStyles } from '../../../../../../../component-library/hooks';
import InfoRow, { InfoRowProps } from '../info-row';
import styleSheet from './alert-row.styles';

function getAlertTextColors(
severity?: Severity,
Expand All @@ -29,6 +31,7 @@ const AlertRow = ({ alertField, isShownWithAlertsOnly, ...props }: AlertRowProps
const { fieldAlerts, showAlertModal, setAlertKey } = useAlerts();
const { trackInlineAlertClicked } = useConfirmationAlertMetrics();
const alertSelected = fieldAlerts.find((a) => a.field === alertField);
const { styles } = useStyles(styleSheet, {});

const handleInlineAlertClick = () => {
if(!alertSelected) return;
Expand All @@ -53,7 +56,13 @@ const AlertRow = ({ alertField, isShownWithAlertsOnly, ...props }: AlertRowProps
/>
) : null;

return <InfoRow {...alertRowProps} labelChildren={inlineAlert} />;
return (
<InfoRow
{...alertRowProps}
style={styles.infoRowOverride}
labelChildren={inlineAlert}
/>
);
};

export default AlertRow;
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React, { ReactNode } from 'react';
import { View } from 'react-native';
import { IconColor } from '../../../../../../component-library/components/Icons/Icon';
import Icon, {
IconColor,
IconName,
IconSize,
} from '../../../../../../component-library/components/Icons/Icon';
import Text, {
TextColor,
TextVariant
TextVariant,
} from '../../../../../../component-library/components/Texts/Text';
import { useStyles } from '../../../../../../component-library/hooks';
import Tooltip from '../Tooltip/Tooltip';
Expand All @@ -21,6 +25,11 @@ export interface InfoRowProps {
variant?: TextColor;
copyText?: string;
valueOnNewLine?: boolean;
withIcon?: {
color: IconColor;
size: IconSize;
name: IconName;
};
}

const InfoRow = ({
Expand All @@ -34,6 +43,7 @@ const InfoRow = ({
variant = TextColor.Default,
copyText,
valueOnNewLine = false,
withIcon,
}: InfoRowProps) => {
const { styles } = useStyles(styleSheet, {});

Expand Down Expand Up @@ -65,6 +75,13 @@ const InfoRow = ({
color={IconColor.Muted}
/>
)}
{withIcon && (
<Icon
color={withIcon.color}
size={withIcon.size}
name={withIcon.name}
/>
)}
</View>
{valueOnNewLine ? (
<View style={styles.valueOnNewLineContainer}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ jest.mock('../../../../../../core/Engine', () => ({
TokenListController: {
fetchTokenList: jest.fn(),
},
TransactionController: {
updateTransaction: jest.fn(),
getNonceLock: jest
.fn()
.mockResolvedValue({ nextNonce: 2, releaseLock: jest.fn() }),
},
},
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useTransactionMetadataRequest } from '../../../hooks/transactions/useTr
import useNavbar from '../../../hooks/ui/useNavbar';
import FromTo from '../../rows/transactions/from-to';
import GasFeesDetails from '../../rows/transactions/gas-fee-details';
import AdvancedDetailsRow from '../../rows/transactions/advanced-details-row/advanced-details-row';
import TokenHero from '../../rows/transactions/token-hero';
import styleSheet from './transfer.styles';

Expand All @@ -33,6 +34,7 @@ const Transfer = () => {
/>
</View>
<GasFeesDetails />
<AdvancedDetailsRow />
</View>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ const styleSheet = (params: {
} = params;

return StyleSheet.create({
container: {
display: 'flex',
container:{
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 8,
paddingBottom: 4,
},
accountContainer: {
flex: 1,
flexDirection: 'row',
},
badgeWrapper: {
marginRight: 16,
alignSelf: 'center',
},
accountInfo: {
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
width: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ import TagBase, {
import { getLabelTextByAddress } from '../../../../../../../util/address';
import { useStyles } from '../../../../../../../component-library/hooks';
import { RootState } from '../../../../../../UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.test';
import InfoSection from '../../../UI/info-row/info-section';
import Icon, {
IconColor,
IconName,
IconSize,
} from '../../../../../../../component-library/components/Icons/Icon';
import useAccountInfo from '../../../../hooks/useAccountInfo';
import useNetworkInfo from '../../../../hooks/useNetworkInfo';
import { useSignatureRequest } from '../../../../hooks/signatures/useSignatureRequest';
Expand Down Expand Up @@ -53,50 +59,59 @@ const AccountNetworkInfoCollapsed = () => {
const { networkName, networkImage } = useNetworkInfo(chainId);

return (
<View style={styles.container}>
<BadgeWrapper
badgePosition={BadgePosition.BottomRight}
badgeElement={
<Badge
variant={BadgeVariant.Network}
name={networkName}
imageSource={networkImage}
/>
}
style={styles.badgeWrapper}
>
<Avatar
variant={AvatarVariant.Account}
type={
useBlockieIcon
? AvatarAccountType.Blockies
: AvatarAccountType.JazzIcon
}
accountAddress={fromAddress}
/>
</BadgeWrapper>
<View>
<View style={styles.accountInfo}>
<Text
ellipsizeMode="tail"
numberOfLines={1}
style={styles.accountName}
<InfoSection>
<View style={styles.container}>
<View style={styles.accountContainer}>
<BadgeWrapper
badgePosition={BadgePosition.BottomRight}
badgeElement={
<Badge
variant={BadgeVariant.Network}
name={networkName}
imageSource={networkImage}
/>
}
style={styles.badgeWrapper}
>
{accountName}
</Text>
{accountLabel && (
<TagBase
style={styles.accountLabel}
severity={TagSeverity.Neutral}
shape={TagShape.Rectangle}
>
{accountLabel}
</TagBase>
)}
<Avatar
variant={AvatarVariant.Account}
type={
useBlockieIcon
? AvatarAccountType.Blockies
: AvatarAccountType.JazzIcon
}
accountAddress={fromAddress}
/>
</BadgeWrapper>
<View>
<View style={styles.accountInfo}>
<Text
ellipsizeMode="tail"
numberOfLines={1}
style={styles.accountName}
>
{accountName}
</Text>
{accountLabel && (
<TagBase
style={styles.accountLabel}
severity={TagSeverity.Neutral}
shape={TagShape.Rectangle}
>
{accountLabel}
</TagBase>
)}
</View>
<Text style={styles.networkName}>{networkName}</Text>
</View>
</View>
<Text style={styles.networkName}>{networkName}</Text>
<Icon
color={IconColor.Muted}
size={IconSize.Sm}
name={IconName.ArrowRight}
/>
</View>
</View>
</InfoSection>
);
};

Expand Down
Loading
Loading