native-navigation icon indicating copy to clipboard operation
native-navigation copied to clipboard

Feature request: Expose screen stack events

Open gusbicalho opened this issue 7 years ago • 2 comments

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 on android and UINavigationController's delegate didShowViewController.

gusbicalho avatar Mar 24 '17 17:03 gusbicalho

Or we can just emit the relevant events on the present/push/pop/dismiss native methods instead of using the FragmentManager/UINavigationController events

gusbicalho avatar Mar 24 '17 17:03 gusbicalho

cc @gpeal

I like this idea and have been wanting something similar on iOS as well.

I think we should expose an event emitter interface through the NavigationCoordinator equivalents on both iOS and Android, as well as exposing a Navigator.on(event, callback) on the JS side.

lelandrichardson avatar Apr 17 '17 23:04 lelandrichardson