Commit 3fba94e
authored
feat: add swap page trending tokens section (#26620)
## **Description**
This PR implements the mobile Swap zero-state Trending Tokens experience
for Bridge and hardens related Bridge rendering behavior.
Key updates:
- Added `BridgeTrendingTokensSection` to render Trending tokens only in
Swap zero state.
- Added filter controls (Sort by / Network / Time) and list chunking
with a centered "Load more" action while preserving single-screen scroll
behavior.
- Refined `BridgeView` content-mode precedence so
loading/error/quote/zero states render deterministically.
- Preserved quote + confirm visibility during quote refresh (`isLoading
&& activeQuote`) and only show skeleton when loading without an active
quote.
- Updated/expanded Bridge tests and removed brittle snapshot dependency
in `BridgeView` tests.
## **Changelog**
CHANGELOG entry: Added Trending tokens to the mobile Swap zero state
with filter controls and improved Bridge quote/loading state handling.
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4038
## **Manual testing steps**
```gherkin
Feature: Swap zero-state trending list on mobile
Scenario: Trending list visibility follows zero state
Given user is on the Swap screen
When no source amount is entered
Then Trending tokens are visible below the swap form
When user enters a non-zero source amount
Then Trending tokens are hidden
Scenario: Numpad hidden on initial load
Given user opens Swap for the first time
When the screen is rendered
Then numpad is hidden and swap form is visible
Scenario: Quote loading and refresh behavior
Given user has entered a non-zero amount
When quote is loading with no active quote
Then quote skeleton is shown and trending list is hidden
When quote is refreshing with an active quote
Then quote content and confirm button remain visible
Scenario: Single scroll behavior
Given user is in zero state with Trending tokens visible
When user scrolls
Then swap form and trending list scroll together in one vertical scroll area
Scenario: Filters update results
Given user is in zero state with Trending tokens visible
When user changes Sort by, Network, or Time filters
Then list content updates to match selected filters
And default sort is Price change high to low
```
## **Screenshots/Recordings**
### **Before**
N/A
### **After**
https://github.com/user-attachments/assets/e55f04c5-6190-4c26-a15a-2e0c00a8b879
## **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]
> **Medium Risk**
> Changes Bridge/Swap screen rendering precedence
(loading/error/quote/zero) and scroll behavior, which could affect quote
visibility and confirm UX during refreshes. Mostly UI/state-driven with
good test coverage but touches a core transaction entry flow.
>
> **Overview**
> Adds a **Swap zero-state Trending Tokens** section to `BridgeView`,
gated behind the temporary `swapsTrendingTokens` remote feature flag,
with filter bottom sheets and incremental “show more” loading triggered
by button or near-bottom scroll.
>
> Refactors `BridgeView` to render deterministically via a `contentMode`
state machine: shows a `QuoteDetailsCardSkeleton` only when *loading
without an active quote*, preserves quote + confirm UI while refreshing
(`isLoading && activeQuote`), and keeps error banners/zero-state
separate from quote content.
>
> Updates styles to support a single unified scroll area (inputs +
dynamic content), introduces new `testID`s, and rewrites/expands tests
to avoid brittle snapshots and to assert the new
loading/error/quote/zero behaviors (including mocking the trending
section).
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
ab8ffe2. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent ec4fbf2 commit 3fba94e
20 files changed
Lines changed: 841 additions & 3903 deletions
File tree
- app/components/UI
- Bridge
- Views/BridgeView
- __snapshots__
- components
- BridgeTrendingTokensSection
- QuoteDetailsCard
- TokenInputArea
- hooks/useBridgeViewOnFocus
- Trending/components
- FilterBar
- TrendingTokensBottomSheet
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
33 | | - | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
| |||
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
Lines changed: 224 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
284 | 304 | | |
285 | 305 | | |
286 | 306 | | |
| |||
331 | 351 | | |
332 | 352 | | |
333 | 353 | | |
334 | | - | |
335 | | - | |
| 354 | + | |
| 355 | + | |
336 | 356 | | |
337 | 357 | | |
338 | 358 | | |
339 | 359 | | |
340 | 360 | | |
341 | 361 | | |
342 | 362 | | |
343 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
344 | 367 | | |
345 | 368 | | |
346 | 369 | | |
| |||
393 | 416 | | |
394 | 417 | | |
395 | 418 | | |
396 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
397 | 425 | | |
398 | 426 | | |
399 | 427 | | |
| |||
434 | 462 | | |
435 | 463 | | |
436 | 464 | | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
437 | 470 | | |
438 | 471 | | |
439 | 472 | | |
| |||
755 | 788 | | |
756 | 789 | | |
757 | 790 | | |
758 | | - | |
759 | | - | |
| 791 | + | |
| 792 | + | |
760 | 793 | | |
761 | 794 | | |
762 | 795 | | |
763 | 796 | | |
764 | 797 | | |
765 | 798 | | |
766 | 799 | | |
767 | | - | |
768 | | - | |
769 | | - | |
| 800 | + | |
770 | 801 | | |
771 | 802 | | |
772 | | - | |
| 803 | + | |
773 | 804 | | |
774 | 805 | | |
775 | 806 | | |
| |||
778 | 809 | | |
779 | 810 | | |
780 | 811 | | |
781 | | - | |
| 812 | + | |
782 | 813 | | |
783 | 814 | | |
784 | 815 | | |
785 | 816 | | |
786 | 817 | | |
787 | 818 | | |
788 | 819 | | |
789 | | - | |
790 | | - | |
791 | | - | |
| 820 | + | |
792 | 821 | | |
793 | 822 | | |
794 | | - | |
| 823 | + | |
795 | 824 | | |
796 | 825 | | |
797 | 826 | | |
| |||
806 | 835 | | |
807 | 836 | | |
808 | 837 | | |
809 | | - | |
| 838 | + | |
810 | 839 | | |
811 | 840 | | |
812 | 841 | | |
813 | 842 | | |
814 | 843 | | |
815 | 844 | | |
816 | 845 | | |
817 | | - | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
818 | 1022 | | |
819 | 1023 | | |
820 | 1024 | | |
| |||
932 | 1136 | | |
933 | 1137 | | |
934 | 1138 | | |
935 | | - | |
| 1139 | + | |
936 | 1140 | | |
937 | 1141 | | |
938 | 1142 | | |
| |||
943 | 1147 | | |
944 | 1148 | | |
945 | 1149 | | |
946 | | - | |
| 1150 | + | |
947 | 1151 | | |
948 | 1152 | | |
949 | 1153 | | |
| |||
956 | 1160 | | |
957 | 1161 | | |
958 | 1162 | | |
959 | | - | |
960 | | - | |
| 1163 | + | |
961 | 1164 | | |
962 | 1165 | | |
963 | 1166 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
0 commit comments