Skip to content

Commit 3633f95

Browse files
AxelGesamitabh94
andauthored
refactor(ramps): organize folder structure separating Views from components (#25791)
## **Description** Reorganizes the Ramp code domain (`app/components/UI/Ramp/`) to clearly separate Views (screens/modals) from reusable components, and moves `RegionSelector` from the Settings domain into Ramp ownership. **Problem:** 1. `RegionSelector` lived in `app/components/Views/Settings/` which is owned by `@MetaMask/mobile-core-ux` in CODEOWNERS. Any Ramp changes to it triggered cross-team reviews. 2. `app/components/UI/Ramp/components/` mixed navigable Views (screens/modals) with pure reusable components, making the codebase harder to navigate and understand. **Solution:** - Created `app/components/UI/Ramp/Views/` directory for all navigable screens and modals - Moved `RegionSelector` from `app/components/Views/Settings/RegionSelector/` to `app/components/UI/Ramp/Views/Settings/RegionSelector/` - Moved all screen-like components from `components/` to `Views/`: - `BuildQuote` → `Views/BuildQuote/` - `TokenSelection` → `Views/TokenSelection/` - `PaymentSelectionModal` → `Views/Modals/PaymentSelectionModal/` - `SettingsModal` → `Views/Modals/SettingsModal/` - `UnsupportedTokenModal` → `Views/Modals/UnsupportedTokenModal/` - Updated all import paths across the codebase - Regenerated snapshots for moved test files **New structure:** ``` app/components/UI/Ramp/ ├── Views/ # Screens & modals (navigated to) │ ├── BuildQuote/ │ ├── TokenSelection/ │ ├── Settings/ │ │ └── RegionSelector/ # ← moved from Views/Settings/ │ └── Modals/ │ ├── PaymentSelectionModal/ │ ├── SettingsModal/ │ └── UnsupportedTokenModal/ └── components/ # Pure reusable components only ├── PaymentMethodPill/ ├── QuickAmounts/ ├── TokenListItem/ └── ... ``` This follows the same pattern already established by `Aggregator/Views/` and `Deposit/Views/`. ## **Changelog** CHANGELOG entry: null ## **Related issues** Refs: #25615 (the PR that introduced `RegionSelector` usage in Ramp, which highlighted the cross-team ownership issue) ## **Manual testing steps** ```gherkin Feature: Ramp folder reorganization Scenario: User navigates through token selection flow Given the app is running on the BuildQuote screen (post-merge of #25615) When user taps back to go to token selection Then the token list should load and display correctly And user can search for tokens And tapping an unsupported token's info icon shows the modal Scenario: User selects payment method Given user is on the BuildQuote screen with an amount entered When user taps the payment method pill Then the payment selection modal should open And payment methods should display correctly And tapping "change provider" should slide to provider selection And selecting a provider should return to payment methods Scenario: User opens build quote settings Given user is on the BuildQuote screen When user taps the settings gear icon Then the settings modal should open with order history option And contact support option should be visible if provider has support URL Scenario: User changes region in settings Given user navigates to Settings > Region When user opens the region selector Then countries should load and display with flags And user can search for countries And tapping USA should show states view And selecting California should save and navigate back And the back button in states view should return to countries Scenario: Cold start verification Given the app is freshly started When user navigates through the complete Buy flow Then no blank screens or navigation crashes occur And all screens render correctly ``` **Video recording is attached showing all scenarios working correctly.** ## **Screenshots/Recordings** ### **Before** N/A - Internal refactor only, no UI changes ### **After** Video recording demonstrating all manual testing scenarios: https://github.com/user-attachments/assets/b73ae1f3-252f-4210-875e-1a222297574f ## **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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Mostly folder/import re-wiring plus snapshot updates; main risk is a broken import/navigation route if the moved `RegionSelector` path is incorrect. > > **Overview** > Moves the `RegionSelector` screen import used by main navigation from `Views/Settings` into the Ramp-owned `UI/Ramp/Views/Settings/RegionSelector` location. > > Updates Ramp Aggregator/Deposit Jest snapshots to match the new UI rendering for icon buttons (notably smaller icon sizes and reduced `borderRadius`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5af35f1. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Amitabh Aggarwal <aggarwal.amitabh@gmail.com>
1 parent 40a2820 commit 3633f95

40 files changed

+78
-80
lines changed

app/components/Nav/Main/MainNavigator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import BackupAndSyncSettings from '../../Views/Settings/Identity/BackupAndSyncSe
1414
import SecuritySettings from '../../Views/Settings/SecuritySettings';
1515
import ExperimentalSettings from '../../Views/Settings/ExperimentalSettings';
1616
import NotificationsSettings from '../../Views/Settings/NotificationsSettings';
17-
import RegionSelector from '../../Views/Settings/RegionSelector/RegionSelector';
17+
import RegionSelector from '../../UI/Ramp/Views/Settings/RegionSelector/RegionSelector';
1818
import NotificationsView from '../../Views/Notifications';
1919
import NotificationsDetails from '../../Views/Notifications/Details';
2020
import OptIn from '../../Views/Notifications/OptIn';

app/components/UI/Ramp/components/BuildQuote/BuildQuote.styles.ts renamed to app/components/UI/Ramp/Views/BuildQuote/BuildQuote.styles.ts

File renamed without changes.

app/components/UI/Ramp/components/BuildQuote/BuildQuote.test.tsx renamed to app/components/UI/Ramp/Views/BuildQuote/BuildQuote.test.tsx

File renamed without changes.

app/components/UI/Ramp/components/BuildQuote/BuildQuote.tsx renamed to app/components/UI/Ramp/Views/BuildQuote/BuildQuote.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type { CaipChainId } from '@metamask/utils';
55

66
import ScreenLayout from '../../Aggregator/components/ScreenLayout';
77
import Keypad, { type KeypadChangeData } from '../../../../Base/Keypad';
8-
import PaymentMethodPill from '../PaymentMethodPill';
9-
import QuickAmounts from '../QuickAmounts';
8+
import PaymentMethodPill from '../../components/PaymentMethodPill';
9+
import QuickAmounts from '../../components/QuickAmounts';
1010
import Text, {
1111
TextVariant,
1212
} from '../../../../../component-library/components/Texts/Text';
@@ -28,7 +28,7 @@ import { useRampsController } from '../../hooks/useRampsController';
2828
import { createSettingsModalNavDetails } from '../Modals/SettingsModal';
2929
import useRampAccountAddress from '../../hooks/useRampAccountAddress';
3030
import { useDebouncedValue } from '../../../../hooks/useDebouncedValue';
31-
import { createPaymentSelectionModalNavigationDetails } from '../PaymentSelectionModal';
31+
import { createPaymentSelectionModalNavigationDetails } from '../Modals/PaymentSelectionModal';
3232

3333
interface BuildQuoteParams {
3434
assetId?: string;

app/components/UI/Ramp/components/BuildQuote/__snapshots__/BuildQuote.test.tsx.snap renamed to app/components/UI/Ramp/Views/BuildQuote/__snapshots__/BuildQuote.test.tsx.snap

File renamed without changes.
File renamed without changes.

app/components/UI/Ramp/components/PaymentSelectionModal/PaymentMethodListItem.test.tsx renamed to app/components/UI/Ramp/Views/Modals/PaymentSelectionModal/PaymentMethodListItem.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { fireEvent, render } from '@testing-library/react-native';
33
import PaymentMethodListItem from './PaymentMethodListItem';
4-
import { ThemeContext, mockTheme } from '../../../../../util/theme';
4+
import { ThemeContext, mockTheme } from '../../../../../../util/theme';
55
import type { PaymentMethod } from '@metamask/ramps-controller';
66

77
const renderWithTheme = (component: React.ReactElement) =>

app/components/UI/Ramp/components/PaymentSelectionModal/PaymentMethodListItem.tsx renamed to app/components/UI/Ramp/Views/Modals/PaymentSelectionModal/PaymentMethodListItem.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import React from 'react';
22
import { View, StyleSheet } from 'react-native';
3-
import ListItemSelect from '../../../../../component-library/components/List/ListItemSelect';
3+
import ListItemSelect from '../../../../../../component-library/components/List/ListItemSelect';
44
import ListItemColumn, {
55
WidthType,
6-
} from '../../../../../component-library/components/List/ListItemColumn';
6+
} from '../../../../../../component-library/components/List/ListItemColumn';
77
import Text, {
88
TextVariant,
99
TextColor,
10-
} from '../../../../../component-library/components/Texts/Text';
10+
} from '../../../../../../component-library/components/Texts/Text';
1111
import { PaymentType } from '@consensys/on-ramp-sdk';
12-
import PaymentMethodIcon from '../../Aggregator/components/PaymentMethodIcon';
12+
import PaymentMethodIcon from '../../../Aggregator/components/PaymentMethodIcon';
1313
import PaymentMethodQuote from './PaymentMethodQuote';
14-
import { formatDelayFromArray } from '../../Aggregator/utils';
15-
import { useTheme } from '../../../../../util/theme';
16-
import type { Colors } from '../../../../../util/theme/models';
14+
import { formatDelayFromArray } from '../../../Aggregator/utils';
15+
import { useTheme } from '../../../../../../util/theme';
16+
import type { Colors } from '../../../../../../util/theme/models';
1717
import type { PaymentMethod } from '@metamask/ramps-controller';
1818

1919
const ICON_CIRCLE_SIZE = 44;

app/components/UI/Ramp/components/PaymentSelectionModal/PaymentMethodQuote.test.tsx renamed to app/components/UI/Ramp/Views/Modals/PaymentSelectionModal/PaymentMethodQuote.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { render } from '@testing-library/react-native';
33
import PaymentMethodQuote from './PaymentMethodQuote';
4-
import { ThemeContext, mockTheme } from '../../../../../util/theme';
4+
import { ThemeContext, mockTheme } from '../../../../../../util/theme';
55

66
const renderWithTheme = (component: React.ReactElement) =>
77
render(

app/components/UI/Ramp/components/PaymentSelectionModal/PaymentMethodQuote.tsx renamed to app/components/UI/Ramp/Views/Modals/PaymentSelectionModal/PaymentMethodQuote.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Box } from '@metamask/design-system-react-native';
33
import Text, {
44
TextVariant,
55
TextColor,
6-
} from '../../../../../component-library/components/Texts/Text';
6+
} from '../../../../../../component-library/components/Texts/Text';
77

88
interface PaymentMethodQuoteProps {
99
cryptoAmount: string;

0 commit comments

Comments
 (0)