airbnb / airbnb/native-navigation

Feature request: Expose screen stack events

Open
#61 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
3.1k
Forks
173
PR merge metrics
No merged PRs in 30d

Description

Use case: we intend to use stacked fragments to create a card stack. A card needs to know that it's not on the top of the stack so it can render differently (for example, change its position and size, optimize away elements which won't be rendered, etc)

I'm thinking about a `NavigatorModule.addScreenStackChangedListener` or `NavigatorModule.on('screenStackChanged', (name: string, props: object) => void)` method. Then all the work to keep state of which screens are being show can be done on the JS side.

If you agree with that API, I'll (try to) make the PR.
I think implementation should not be too difficult using [FragmentManager.addOnBackStackChangedListener](https://developer.android.com/reference/android/app/FragmentManager.html#addOnBackStackChangedListener(android.app.FragmentManager.OnBackStackChangedListener)) on android and UINavigationController's delegate `didShowViewController`.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing NavigatorModule and the existing screen-stack handling on Android and iOS. Compare the proposed FragmentManager back-stack listener and UINavigationController delegate callback, then define completion as exposing screen-stack changes to JavaScript for stacked cards.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, ios, javascript, react-native
Domain
api, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.