From 9514297b59328660602ac520891626e34fa1f6fb Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Wed, 22 Jan 2025 16:37:50 +0100 Subject: [PATCH 1/7] fix: tokens list to display with hideTokensWithoutBalance setting (#13007) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** PR to fix an issue with the tokenList showing the msg "You don't have any tokens" when popular networks is selected and the setting HideTokensWithoutBalance is enabled ## **Related issues** Fixes: https://github.com/MetaMask/metamask-mobile/issues/13025 ## **Manual testing steps** 1. click on account selector 2. Create a new empty account 3. Go to settings => General and and toggle hide tokens without balance setting 4. go back to home page; and select popular network 5. You should see new message and when you click on the link you will be redirected to general/settings ## **Screenshots/Recordings** ### **Before** ![image](https://github.com/user-attachments/assets/0cf729d9-806b-4840-b503-5a3f53ba2934) ### **After** https://github.com/user-attachments/assets/2a4f3965-8f0d-4731-a13a-2f886f41ad03 ## **Pre-merge author checklist** - [ ] 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). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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. --- app/components/UI/Tokens/TokenList/index.tsx | 28 ++++++++++-- .../Tokens/__snapshots__/index.test.tsx.snap | 45 ++++++++++++++----- app/components/UI/Tokens/styles.ts | 7 +++ locales/languages/en.json | 1 + 4 files changed, 68 insertions(+), 13 deletions(-) diff --git a/app/components/UI/Tokens/TokenList/index.tsx b/app/components/UI/Tokens/TokenList/index.tsx index af16dce0af4..516cf9ca821 100644 --- a/app/components/UI/Tokens/TokenList/index.tsx +++ b/app/components/UI/Tokens/TokenList/index.tsx @@ -4,12 +4,16 @@ import { useSelector } from 'react-redux'; import { useTheme } from '../../../../util/theme'; import { selectPrivacyMode } from '../../../../selectors/preferencesController'; import createStyles from '../styles'; -import Text from '../../../../component-library/components/Texts/Text'; +import Text, { + TextColor, +} from '../../../../component-library/components/Texts/Text'; import { TokenI } from '../types'; import { strings } from '../../../../../locales/i18n'; import { TokenListFooter } from './TokenListFooter'; import { TokenListItem } from './TokenListItem'; import { WalletViewSelectorsIDs } from '../../../../../e2e/selectors/wallet/WalletView.selectors'; +import { useNavigation } from '@react-navigation/native'; +import Routes from '../../../../constants/navigation/Routes'; interface TokenListProps { tokens: TokenI[]; @@ -34,6 +38,13 @@ export const TokenList = ({ const [showScamWarningModal, setShowScamWarningModal] = useState(false); const styles = createStyles(colors); + const navigation = useNavigation(); + + const handleLink = () => { + navigation.navigate(Routes.SETTINGS_VIEW, { + screen: Routes.ONBOARDING.GENERAL_SETTINGS, + }); + }; return tokens?.length ? ( ) : ( - {strings('wallet.no_tokens')} - + + + {strings('wallet.no_tokens')} + + + {strings('wallet.show_tokens_without_balance')} + + + // TO see tokens without balance, Click here. ); }; diff --git a/app/components/UI/Tokens/__snapshots__/index.test.tsx.snap b/app/components/UI/Tokens/__snapshots__/index.test.tsx.snap index 7e4fa06d851..f76cf9bebb8 100644 --- a/app/components/UI/Tokens/__snapshots__/index.test.tsx.snap +++ b/app/components/UI/Tokens/__snapshots__/index.test.tsx.snap @@ -478,21 +478,46 @@ exports[`Tokens Portfolio View should match the snapshot when portfolio view is } } > - - You don't have any tokens! - + + You don't have any tokens! + + + Show tokens without balance + + diff --git a/app/components/UI/Tokens/styles.ts b/app/components/UI/Tokens/styles.ts index fcb3c758960..8839d5806ba 100644 --- a/app/components/UI/Tokens/styles.ts +++ b/app/components/UI/Tokens/styles.ts @@ -26,6 +26,13 @@ const createStyles = (colors: Colors) => alignItems: 'center', marginTop: 50, }, + emptyTokensView: { + alignItems: 'center', + marginTop: 130, + }, + emptyTokensViewText: { + fontFamily: 'EuclidCircularB-Medium', + }, text: { fontSize: 20, color: colors.text.default, diff --git a/locales/languages/en.json b/locales/languages/en.json index b993d227b59..ad363cefa5a 100644 --- a/locales/languages/en.json +++ b/locales/languages/en.json @@ -449,6 +449,7 @@ "next": "Next", "buy_asset": "Buy {{asset}}", "no_tokens": "You don't have any tokens!", + "show_tokens_without_balance": "Show tokens without balance", "no_nfts_yet": "No NFTs yet", "nfts_autodetection_title": "NFT detection", "nfts_autodetection_desc": "Let MetaMask automatically detect and display NFTs in your wallet.", From 8dacf7b54e58e8715babfc6b7e3840b7f8d6e87c Mon Sep 17 00:00:00 2001 From: Matthew Grainger <46547583+Matt561@users.noreply.github.com> Date: Wed, 22 Jan 2025 13:44:36 -0500 Subject: [PATCH 2/7] feat: STAKE-927 build upsell banner component (#13108) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR adds the `` component with two variants: - `` - `` Snapshot tests are also included. ## **Related issues** Fixes: [STAKE-927: [FE] Build UpsellBanner Component](https://consensyssoftware.atlassian.net/browse/STAKE-927) ## **Manual testing steps** N/A ## **Screenshots/Recordings** ### **Before** N/A ### **After** #### UpsellBannerBody image #### UpsellBannerHeader image ## **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 - [ ] 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. --- .../UpsellBanner/UpsellBanner.styles.tsx | 20 ++ .../UpsellBanner/UpsellBanner.test.tsx | 52 ++++ .../UpsellBanner/UpsellBanner.types.ts | 23 ++ .../UpsellBannerBody.styles.tsx | 32 +++ .../UpsellBanner/UpsellBannerBody/index.tsx | 52 ++++ .../UpsellBannerHeader.styles.tsx | 20 ++ .../UpsellBanner/UpsellBannerHeader/index.tsx | 31 +++ .../__snapshots__/UpsellBanner.test.tsx.snap | 242 ++++++++++++++++++ .../Stake/components/UpsellBanner/index.tsx | 24 ++ 9 files changed, 496 insertions(+) create mode 100644 app/components/UI/Stake/components/UpsellBanner/UpsellBanner.styles.tsx create mode 100644 app/components/UI/Stake/components/UpsellBanner/UpsellBanner.test.tsx create mode 100644 app/components/UI/Stake/components/UpsellBanner/UpsellBanner.types.ts create mode 100644 app/components/UI/Stake/components/UpsellBanner/UpsellBannerBody/UpsellBannerBody.styles.tsx create mode 100644 app/components/UI/Stake/components/UpsellBanner/UpsellBannerBody/index.tsx create mode 100644 app/components/UI/Stake/components/UpsellBanner/UpsellBannerHeader/UpsellBannerHeader.styles.tsx create mode 100644 app/components/UI/Stake/components/UpsellBanner/UpsellBannerHeader/index.tsx create mode 100644 app/components/UI/Stake/components/UpsellBanner/__snapshots__/UpsellBanner.test.tsx.snap create mode 100644 app/components/UI/Stake/components/UpsellBanner/index.tsx diff --git a/app/components/UI/Stake/components/UpsellBanner/UpsellBanner.styles.tsx b/app/components/UI/Stake/components/UpsellBanner/UpsellBanner.styles.tsx new file mode 100644 index 00000000000..901c2cb636c --- /dev/null +++ b/app/components/UI/Stake/components/UpsellBanner/UpsellBanner.styles.tsx @@ -0,0 +1,20 @@ +import { StyleSheet } from 'react-native'; +import { Theme } from '../../../../../util/theme/models'; + +const upsellBannerStylesheet = (params: { theme: Theme }) => { + const { theme } = params; + const { colors } = theme; + + return StyleSheet.create({ + container: { + backgroundColor: colors.background.alternative, + borderRadius: 8, + gap: 8, + alignItems: 'center', + paddingVertical: 24, + paddingHorizontal: 16, + }, + }); +}; + +export default upsellBannerStylesheet; diff --git a/app/components/UI/Stake/components/UpsellBanner/UpsellBanner.test.tsx b/app/components/UI/Stake/components/UpsellBanner/UpsellBanner.test.tsx new file mode 100644 index 00000000000..294b08b0d8a --- /dev/null +++ b/app/components/UI/Stake/components/UpsellBanner/UpsellBanner.test.tsx @@ -0,0 +1,52 @@ +import React from 'react'; +import UpsellBanner from '.'; +import { + UPSELL_BANNER_VARIANTS, + UpsellBannerProps, +} from './UpsellBanner.types'; +import renderWithProvider from '../../../../../util/test/renderWithProvider'; +import Button, { + ButtonVariants, +} from '../../../../../component-library/components/Buttons/Button'; + +describe('UpsellBanner', () => { + const baseProps = { + primaryText: 'you could earn', + secondaryText: '$454', + tertiaryText: 'per year on your tokens', + endAccessory: ( +