[Android] Add ability to start app with deep stack (#2761)
For example, the following code will start a single screen app with two
screens pushed into the stack.
```js
Navigation.startSingleScreenApp({
components: [
{
screen: 'example.Types',
title: 'Navigation Types',
overrideBackPress: true
},
{
screen: 'example.Types.CustomButtonScreen',
title: 'Custom Buttons'
}
]
});
```
This commit continues the work done in #2057.
When hardware back button is pressed, we handle it accordingly:
1. If screen was pushed with `overrideBackPress: true`, we emit `backPress` event
2. Let `BackHandler` handle the event
3. If the event wasn't handled by `BackHandler`, pop the stack
4. let the system handle the event
* added method for getting the currently visible screen ID. Can be useful to decide if logic should be applied according to screen visibility, for example: set buttons/title dynamically, or even determine that you don’t need to show the same screen again if it’s the current one that’s showing
* Implement getCurrentlyVisibleScreenId on Android
Can be used statically:
Navigation.getCurrentlyVisibleScreenId() - returns the unique screen
instance id
With a navigator instance:
await this.props.navigator.screenIsCurrentlyVisible() - resolves a
promise that checks if the current screen is visible
* Add screen visibility listener which can be registered globally
API
new ScreenVisibilityListener({
willAppear: ({screen, timestamp}) => console.log(`Displaying screen ${screen}`),
didAppear: ({screen, timestamp}) => console.log(`Screen ${screen} displayed in ${Date.now() - timestamp} millis`)
}).register();
todo
* Add timestamp to modal, resetTo
* implement unregister
* implement iOS
* Add global screen visibility listener to example app
* Think I better assign a value to emitter
* Send timestamp in resetTo
* Moved listener to library, it can be deleted from the app
* Add push and resetTo buttons to pushed screens
* Send appear/disappear events after animation ends
* Pass pop timestamp from js
* Send timestamp in popToRoot
* Add popToRoot button in push screen
* Add few navigation buttons to modal screen
* Pass timestamp to tabs
relevant only to first/initial tab
* Update timestamp when navigating between BottomTabs
* Send screen visible events after modal dismiss
* log willDisappear and didDisappear
* Report both start and end timestamps
* Implement unregister
* Send NavigationType parameter in visibilityEvent
This indicates the type of the navigation command that triggered the visibility change
* Rename pushInitialScreen to more explicit name
* Fix duplicate initialScreen visibility events
* Update screen visibility log statement
* Show popToRoot in modal screen only if screens were pushed
* implement global screen event for iOS
* fix lint issues
Since fab set dynamically wasn’t saved in screen params, when returning
to that screen the fab wasn't displayed.
This commit also enables setting fab dynamically in modals
dismissInAppNotification support on android. (#687)
* Add .hideInAppNotification on android.
- Separate hide and show animations.
- Implement a little bit of throttling around successive calls to .showInAppNotification
* Update example to demo dismiss.
* Don’t create SideMenu button automatically on Android
* Remove left button and add it dynamically
* Fix resetTo animation on Android
Up until now resetTo would destroy the current stack and create a new
one. This was an easy implementation but resulted in jurky
(none existent) animations.
This commit changes resetTo behavior. Instead of recreating the stack,
the we reset to is pushed to the stack, and the other elements are
removed when show animation ends.
Sends a nav event whenever the sideMenu button is clicked. (Android) (#617)
* Dispatch a navigation event whenever the side menu button is clicked (BottomTabsLayout)
* Dispatch a navigation event whenever the side menu button is clicked (SingleScreenLayout)
* Changed the way the navigatorEventId is retrieved in SingleScreenLayout.
When ivoking navigation actions such as push, pop etc, instead of
checking modal visibility, check if modal actually contains the given
navigator. This fix alows to change navigation state in screens while
modal is displayed.
TopTabParams are a subset of ScreenParams, moved the properties that
are shared by both classes to BaseScreenParams.
This change was needed to report screen changes properly in ViewPagerScreen