Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ jest.mock(
'../../../../../selectors/multichainAccounts/accountTreeController',
() => ({
selectAccountToGroupMap: () => ({}),
selectAccountToWalletMap: () => ({}),
selectWalletsMap: () => ({}),
selectSelectedAccountGroupWithInternalAccountsAddresses: () => [],
selectAccountTreeControllerState: () => ({}),
selectAccountGroupWithInternalAccounts: () => [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React from 'react';
import { TouchableOpacity, Platform, UIManager } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import I18n, { strings } from '../../../../../../locales/i18n';
Expand Down Expand Up @@ -28,18 +28,13 @@ import {
selectSourceAmount,
selectDestToken,
selectSourceToken,
selectDestAddress,
selectIsSwap,
} from '../../../../../core/redux/slices/bridge';
import { selectAccountToGroupMap } from '../../../../../selectors/multichainAccounts/accountTreeController';
import { selectMultichainAccountsState2Enabled } from '../../../../../selectors/featureFlagController/multichainAccounts';
import { selectInternalAccounts } from '../../../../../selectors/accountsController';
import { getIntlNumberFormatter } from '../../../../../util/intl';
import { useRewards } from '../../hooks/useRewards';
import { areAddressesEqual } from '../../../../../util/address';
import RewardsAnimations, {
RewardAnimationState,
} from '../../../Rewards/components/RewardPointsAnimation';
import QuoteDetailsRecipientKeyValueRow from '../QuoteDetailsRecipientKeyValueRow/QuoteDetailsRecipientKeyValueRow';

if (
Platform.OS === 'android' &&
Expand Down Expand Up @@ -67,13 +62,6 @@ const QuoteDetailsCard: React.FC = () => {
const sourceToken = useSelector(selectSourceToken);
const destToken = useSelector(selectDestToken);
const sourceAmount = useSelector(selectSourceAmount);
const destAddress = useSelector(selectDestAddress);
const isSwap = useSelector(selectIsSwap);
const internalAccounts = useSelector(selectInternalAccounts);
const accountToGroupMap = useSelector(selectAccountToGroupMap);
const isMultichainAccountsState2Enabled = useSelector(
selectMultichainAccountsState2Enabled,
);
const {
estimatedPoints,
isLoading: isRewardsLoading,
Expand All @@ -84,42 +72,12 @@ const QuoteDetailsCard: React.FC = () => {
isQuoteLoading,
});

// Get the display name for the destination account
const destinationDisplayName = useMemo(() => {
if (!destAddress) return undefined;

const internalAccount = internalAccounts.find((account) =>
areAddressesEqual(account.address, destAddress),
);

if (!internalAccount) return undefined;

// Use account group name if available, otherwise use account name
if (isMultichainAccountsState2Enabled) {
const accountGroup = accountToGroupMap[internalAccount.id];
return accountGroup?.metadata.name || internalAccount.metadata.name;
}

return internalAccount.metadata.name;
}, [
destAddress,
internalAccounts,
accountToGroupMap,
isMultichainAccountsState2Enabled,
]);

const handleSlippagePress = () => {
navigation.navigate(Routes.BRIDGE.MODALS.ROOT, {
screen: Routes.BRIDGE.MODALS.SLIPPAGE_MODAL,
});
};

const handleRecipientPress = () => {
navigation.navigate(Routes.BRIDGE.MODALS.ROOT, {
screen: Routes.BRIDGE.MODALS.RECIPIENT_SELECTOR_MODAL,
});
};

// Early return for invalid states
if (
!sourceToken?.chainId ||
Expand Down Expand Up @@ -271,44 +229,6 @@ const QuoteDetailsCard: React.FC = () => {
}}
/>

{!isSwap && (
<KeyValueRow
field={{
label: {
text: strings('bridge.recipient'),
variant: TextVariant.BodyMDMedium,
},
}}
value={{
label: (
<TouchableOpacity
onPress={handleRecipientPress}
activeOpacity={0.6}
testID="recipient-selector-button"
style={styles.slippageButton}
>
<Text
variant={TextVariant.BodyMD}
numberOfLines={1}
ellipsizeMode="tail"
style={styles.recipientText}
>
{destAddress
? destinationDisplayName ||
strings('bridge.external_account')
: strings('bridge.select_recipient')}
</Text>
<Icon
name={IconName.Edit}
size={IconSize.Sm}
color={IconColor.Muted}
/>
</TouchableOpacity>
),
}}
/>
)}

{activeQuote?.minToTokenAmount && (
<KeyValueRow
field={{
Expand All @@ -331,6 +251,8 @@ const QuoteDetailsCard: React.FC = () => {
/>
)}

<QuoteDetailsRecipientKeyValueRow />

{/* Estimated Points */}
{shouldShowRewardsRow && (
<KeyValueRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,125 +922,97 @@ exports[`QuoteDetailsCard renders initial state 1`] = `
"justifyContent": "space-between",
"overflow": "hidden",
},
[
undefined,
],
undefined,
]
}
>
<View
style={
{
"alignItems": "flex-start",
"flex": 1,
}
[
{
"display": "flex",
},
{
"flex": 1,
"minWidth": "auto",
"width": "auto",
},
]
}
>
<View
<Text
accessibilityRole="text"
style={
{
"alignItems": "center",
"flexDirection": "row",
"gap": 8,
"color": "#121314",
"fontFamily": "Geist Medium",
"fontSize": 16,
"letterSpacing": 0,
"lineHeight": 24,
}
}
>
<View
style={
{
"alignItems": "center",
"flexDirection": "row",
}
}
>
<Text
accessibilityRole="text"
style={
{
"color": "#121314",
"fontFamily": "Geist Medium",
"fontSize": 16,
"letterSpacing": 0,
"lineHeight": 24,
}
}
testID="label"
>
Recipient
</Text>
</View>
</View>
Recipient
</Text>
</View>
<View
style={
{
"alignItems": "flex-end",
"flex": 1,
}
[
{
"alignItems": "flex-end",
"display": "flex",
"justifyContent": "flex-end",
},
{
"flex": 1,
},
]
}
>
<View
<TouchableOpacity
activeOpacity={0.6}
onPress={[Function]}
style={
{
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"gap": 8,
"gap": 4,
}
}
testID="recipient-selector-button"
>
<View
<Text
accessibilityRole="text"
ellipsizeMode="tail"
numberOfLines={1}
style={
{
"alignItems": "center",
"flexDirection": "row",
"color": "#121314",
"flexShrink": 1,
"fontFamily": "Geist Regular",
"fontSize": 16,
"letterSpacing": 0,
"lineHeight": 24,
}
}
>
<TouchableOpacity
activeOpacity={0.6}
onPress={[Function]}
style={
{
"alignItems": "center",
"flexDirection": "row",
"gap": 4,
}
Select recipient
</Text>
<SvgMock
color="#b7bbc8"
fill="currentColor"
height={16}
name="Edit"
style={
{
"height": 16,
"width": 16,
}
testID="recipient-selector-button"
>
<Text
accessibilityRole="text"
ellipsizeMode="tail"
numberOfLines={1}
style={
{
"color": "#121314",
"flexShrink": 1,
"fontFamily": "Geist Regular",
"fontSize": 16,
"letterSpacing": 0,
"lineHeight": 24,
}
}
>
Select recipient
</Text>
<SvgMock
color="#b7bbc8"
fill="currentColor"
height={16}
name="Edit"
style={
{
"height": 16,
"width": 16,
}
}
width={16}
/>
</TouchableOpacity>
</View>
</View>
}
width={16}
/>
</TouchableOpacity>
</View>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { StyleSheet } from 'react-native';

const createStyles = () =>
StyleSheet.create({
recipientFieldSection: {
flex: 1,
minWidth: 'auto',
width: 'auto',
},
recipientValueSection: {
flex: 1,
},
recipientButton: {
flexDirection: 'row',
alignItems: 'center',
flex: 1,
gap: 4,
},
accountNameText: {
flexShrink: 0,
minWidth: 0,
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Text Overflow in Single-Line Component

The accountNameText style uses flexShrink: 0, which prevents long wallet and account names from truncating. This can cause text overflow and layout issues, especially when the component expects a single line.

Fix in Cursor Fix in Web

recipientText: {
flexShrink: 1,
},
});

export default createStyles;
Loading
Loading