Skip to content

refactor(stake): use native stack navigators for Stake routes#30220

Merged
weitingsun merged 5 commits into
mainfrom
wsun/stake-native-stack-update
May 20, 2026
Merged

refactor(stake): use native stack navigators for Stake routes#30220
weitingsun merged 5 commits into
mainfrom
wsun/stake-native-stack-update

Conversation

@weitingsun

@weitingsun weitingsun commented May 14, 2026

Copy link
Copy Markdown
Contributor

Description

note to reviewer: please view the diff with the link to reduce noise: https://github.com/MetaMask/metamask-mobile/pull/30220/changes?w=1

Migrates the Stake screen and modal navigators from @react-navigation/stack to @react-navigation/native-stack(POC), and replaces getStakingNavbar + useEffect(setOptions(...)) with an in-screen HeaderStandard on three Stake flows.

Why: Setting headers via useEffect + setOptions on native stack causes a visible flicker on first paint (the default native header renders, then is replaced); for these screens we now configure headerShown: false at the route level and render the header in-screen with HeaderStandard, which eliminates the flicker.

What changed

  1. Stake/routes/index.tsx:
  • createStackNavigator → createNativeStackNavigator for both StakeScreenStack and StakeModalStack.
  • Modal stack switched to clearNativeStackNavigatorOptions + transparentModalScreenOptions (native-stack equivalents of the prior preset).
  • screenOptions.headerShadowVisible: false.
  • headerShown: false on STAKE, STAKE_CONFIRMATION, UNSTAKE_CONFIRMATION, EARNINGS_HISTORY.
  1. StakeConfirmationView, UnstakeConfirmationView, StakeEarningsHistoryView: replaced legacy header setup with HeaderStandard; back button preserves the existing analytics events (STAKE_CONFIRMATION_BACK_CLICKED, UNSTAKE_CONFIRMATION_BACK_CLICKED) via useAnalytics.
    Note I am leaving migration EarnWithDrawInputView.tsx out on purpose because this navbar has more logic so it's better for the team to do the migration

  2. UnstakeConfirmationView.styles.ts: mainContainer height: '100%' → flex: 1 so the footer (Cancel / Continue) lays out correctly under the new flex parent + HeaderStandard.

  3. EarnInputView: removed the now-redundant useEffect(() => navigation.setOptions({ headerShown: false })) (the route owns it).

  4. Tests: navigation mocks now include goBack; StakeEarningsHistoryView.test.tsx was rewritten to assert on the rendered header title instead of setOptions / getStakingNavbar (which the screen no longer calls).

Android test build: https://github.com/MetaMask/metamask-mobile/actions/runs/25891826048

Changelog

CHANGELOG entry:null

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Please note that some of these flows are not representing what app is behaving right now. I hardcoded some of the screens to see the navigation behaviours

Before

Stake before 1 stake after 2 stake confirmation before

After

stake after 1 stake after 2 stake confirmation after

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
Refactors Stake navigation and header rendering, which can impact screen transitions/back behavior and modal presentation; mitigated by updated tests covering back actions and header titles.

Overview
Stake navigation is migrated to native-stack. Stake/routes switches from @react-navigation/stack to @react-navigation/native-stack, applies native-stack modal presets (clearNativeStackNavigatorOptions + transparentModalScreenOptions), and sets headerShown: false on Stake-related screens to avoid native header flicker.

Stake headers are now rendered in-screen. StakeConfirmationView, UnstakeConfirmationView, and StakeEarningsHistoryView replace setOptions(getStakingNavbar(...)) with HeaderStandard, including explicit back handlers that preserve existing MetaMetrics back-click events; UnstakeConfirmationView layout is adjusted (height: '100%'flex: 1) to fit the new wrapper.

Tests are updated accordingly. View tests now assert rendered header titles and verify goBack + analytics tracking via HeaderStandard back button test IDs, and EarnInputView removes a redundant navigation.setOptions({ headerShown: false }) now handled at the route level.

Reviewed by Cursor Bugbot for commit 0c8c21d. 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 14, 2026
@weitingsun weitingsun marked this pull request as ready for review May 14, 2026 23:30
@weitingsun weitingsun requested a review from a team as a code owner May 14, 2026 23:30
Comment thread app/components/UI/Stake/routes/index.tsx

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a2c1345. Configure here.

@weitingsun weitingsun self-assigned this May 15, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue May 15, 2026

@Matt561 Matt561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@weitingsun When testing, the withdrawal screen (staking and lending) renders with iOS' "glass" buttons in the header.

Image

@weitingsun

weitingsun commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

@weitingsun When testing, the withdrawal screen (staking and lending) renders with iOS' "glass" buttons in the header.

this is a great find @Matt561 it only happens on 17 pro max. Should be resolved now that another PR is merged in to change the nav header to HeaderStandard: #30281

Simulator Screenshot - iPhone 17 Pro Max - 2026-05-19 at 14 03 45

@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 Stake/Earn/Unstake UI and navigation stack:

  1. Navigation stack migration (routes/index.tsx): Migrated from createStackNavigator to createNativeStackNavigator. This is a meaningful change that could affect screen transitions, header rendering, and modal presentation behavior in the staking flow. The transparentModalScreenOptions replaces the old presentation: 'transparentModal' pattern.

  2. Header refactor (StakeConfirmationView, UnstakeConfirmationView, StakeEarningsHistoryView): Replaced the getStakingNavbar + useEffect(navigation.setOptions) pattern with the HeaderStandard component from @metamask/design-system-react-native. This changes how headers are rendered and how back button analytics are tracked.

  3. EarnInputView: Removed redundant useEffect for headerShown: false since it's now set at the navigator level via options={{ headerShown: false }}.

  4. Style fix: height: '100%'flex: 1 in UnstakeConfirmationView, which could affect layout on different screen sizes.

These changes directly affect the staking and lending flows tested by SmokeStake. Per the tag description, SmokeConfirmations must also be selected since transaction confirmations are part of the stake/unstake flow. The changes are UI/navigation refactors that could introduce visual regressions or navigation issues in the staking confirmation screens.

Performance Test Selection:
The changes are UI/navigation refactors for staking views (header component replacement, navigator type migration, style fix). While these affect rendering, they don't impact performance-sensitive areas like account list rendering, app launch, login, or asset loading. No performance test tags are warranted.

View GitHub Actions results

@weitingsun weitingsun requested a review from Matt561 May 19, 2026 21:09
@sonarqubecloud

Copy link
Copy Markdown

@weitingsun weitingsun enabled auto-merge May 19, 2026 21:53

@Matt561 Matt561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not seeing the glass header icons anymore on the Unstake/Withdrawal screen 👍

@weitingsun weitingsun added this pull request to the merge queue May 20, 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 20, 2026
Merged via the queue into main with commit 6806af2 May 20, 2026
140 of 144 checks passed
@weitingsun weitingsun deleted the wsun/stake-native-stack-update branch May 20, 2026 22:21
@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 20, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 20, 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 20, 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-M team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants