Skip to content

refactor(unstake): use HeaderStandard instead of getStakingNavbar#30281

Merged
weitingsun merged 5 commits into
mainfrom
wsun/changing-unstake-screen-to-use-headerstandard
May 19, 2026
Merged

refactor(unstake): use HeaderStandard instead of getStakingNavbar#30281
weitingsun merged 5 commits into
mainfrom
wsun/changing-unstake-screen-to-use-headerstandard

Conversation

@weitingsun

@weitingsun weitingsun commented May 15, 2026

Copy link
Copy Markdown
Contributor

Description

Note to reviewer: please use this link to check the difference to avoid formatting noise: https://github.com/MetaMask/metamask-mobile/pull/30281/changes?w=1

Refactors the Earn withdraw/unstake input header to use reusable, design-system components and consolidates analytics wiring.

Why

  • This PR is needed for stake navigation to change to native stack
  • The screen still used legacy React Navigation header options (getStakingNavbar + navigation.setOptions) while other flows are moving to in-screen HeaderStandard.

What changed

  • Added EarnHeaderSubtitle (app/components/UI/Earn/components/EarnHeaderSubtitle/) — renders formatted receipt-token balance and APR, with optional aprOverride (e.g. Tron).
  • Updated EarnWithdrawInputView to render HeaderStandard with EarnHeaderSubtitle as subtitle instead of getStakingNavbar.
  • Wired handleHeaderBackPress / handleHeaderCancelPress to read event payloads from navBarEventOptions (same events/properties as before).
  • Added unit tests for EarnHeaderSubtitle.
  • No user-facing behavior change — header layout, copy, and analytics events should be identical. This is a refactor for reuse and consistency.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Earn withdraw input header
  Scenario: Stablecoin lending withdrawal header (flag ON)
    Given stablecoin lending is enabled (earnStablecoinLendingEnabled / MM_STABLECOIN_LENDING_UI_ENABLED)
    And the user has a lending position (e.g. aUSDC)
    When the user opens the withdraw input screen from USDC token details
    Then the header shows "Withdraw <token>"
    And a back button is shown (no Cancel)
    And the subtitle shows "<balance> <APR>% APR"
    When the user taps back
    Then EARN_INPUT_BACK_BUTTON_CLICKED is tracked and the screen dismisses

  Scenario: Pooled staking unstake header (flag OFF)
    Given stablecoin lending is disabled
    And the user has a staked ETH position
    When the user opens the unstake input screen from ETH token details
    Then the header shows "Unstake ETH"
    And Cancel is shown (no back button)
    And the subtitle shows staked balance and APR when a receipt token exists
    When the user taps Cancel
    Then UNSTAKE_CANCEL_CLICKED is tracked and the screen dismisses

Screenshots/Recordings

isStablecoinLendingEnabled: true and USDC (withdraw)

Before After
before true USDC true, USDC

isStablecoinLendingEnable: false and USDC (withdraw)

Before After
before false USDC false USDC

isStablecoinLendingEnable: true and ETH (unstake)

Before After
Before true ETH true ETH

isStablecoinLendingENabled: false and ETH (unstake)

Before After
before false ETH false ETH

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Note

Medium Risk
Moderate UI/navigation refactor that replaces the React Navigation header for the withdraw/unstake flow; risk is mainly around incorrect header buttons or analytics events firing on back/cancel across staking, lending, and Tron variants.

Overview
Refactors the Earn withdraw/unstake input header to render an in-screen design-system HeaderStandard instead of using navigation.setOptions(getStakingNavbar(...)). The header now supports a reusable subtitle (EarnHeaderSubtitle) that displays receipt-token balance + APR (with optional Tron APR override), and wires back/cancel presses to emit the same MetaMetrics events before calling navigation.goBack().

Tests were updated to assert header text/buttons via new test IDs and to verify back/cancel tracking + goBack behavior, and the staking stack route for Routes.STAKING.UNSTAKE now sets options={{ headerShown: false }} to avoid the native header. Minor styling was added to accommodate headers with subtitles (headerWithSubtitle).

Reviewed by Cursor Bugbot for commit 247f166. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label May 15, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.71429% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.95%. Comparing base (6375f80) to head (c34ecbf).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
...ws/EarnWithdrawInputView/EarnWithdrawInputView.tsx 65.71% 3 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #30281      +/-   ##
==========================================
+ Coverage   81.92%   81.95%   +0.02%     
==========================================
  Files        5442     5446       +4     
  Lines      145329   145468     +139     
  Branches    33217    33232      +15     
==========================================
+ Hits       119064   119221     +157     
+ Misses      18135    18113      -22     
- Partials     8130     8134       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added size-L and removed size-M labels May 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeStake, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are focused on the Earn/Stake withdrawal input view:

  1. EarnWithdrawInputView.tsx: Significant UI refactor replacing the old getStakingNavbar navigation header with a new HeaderStandard component from the design system. The layout is restructured with a Box wrapper, and a new EarnHeaderSubtitle component is integrated to show balance and APR. Navigation event handling (back/cancel buttons) is now managed inline rather than via the navbar builder.

  2. EarnHeaderSubtitle.tsx: New component for displaying balance + APR in the header subtitle area.

  3. Stake/routes/index.tsx: Adds options={{ headerShown: false }} to the UNSTAKE route - this is critical as it disables the React Navigation default header for this screen since the component now manages its own header internally.

  4. Styles: New headerWithSubtitle style for the taller header variant.

Why SmokeStake: This tag directly covers lending withdrawals (lending-withdrawal-smoke.spec.ts) and stake actions (stake-action-smoke.spec.ts). The EarnWithdrawInputView is the core component for the unstake/withdraw flow. The header refactor and route change (headerShown: false) could break navigation rendering, back button behavior, and the overall withdraw flow.

Why SmokeConfirmations: Per the SmokeStake tag description, "When selecting SmokeStake, also select SmokeConfirmations (transaction confirmations are part of the flow)." The withdrawal flow leads to transaction confirmations.

No other tags are needed as the changes are isolated to the Earn/Stake withdrawal input screen and don't touch shared navigation, browser, accounts, or other wallet features.

Performance Test Selection:
The changes are UI refactoring of the Earn withdraw input view - replacing a navigation header implementation with a design system component. While there are layout changes, these are not in performance-critical paths like account list rendering, app launch, login, or asset loading. The changes don't affect data fetching, state management, or rendering of large lists. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@weitingsun weitingsun marked this pull request as ready for review May 19, 2026 19:58
@weitingsun weitingsun requested a review from a team as a code owner May 19, 2026 19:58
@weitingsun weitingsun enabled auto-merge May 19, 2026 20:00
@weitingsun weitingsun self-assigned this May 19, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue May 19, 2026
@weitingsun weitingsun added this pull request to the merge queue May 19, 2026
@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue May 19, 2026
Merged via the queue into main with commit 87707cb May 19, 2026
284 of 313 checks passed
@weitingsun weitingsun deleted the wsun/changing-unstake-screen-to-use-headerstandard branch May 19, 2026 20:27
@github-project-automation github-project-automation Bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue May 19, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-L team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants