Merge pull request #25787 from henrikra/master

Add missing functions and classes (react-native-navigation)
This commit is contained in:
Ron Buckton
2018-05-15 12:46:43 -07:00
committed by GitHub
2 changed files with 26 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ export namespace Navigation {
function handleDeepLink(params?: { link: string; payload?: string; }): void;
function registerScreen(screenId: string, generator: () => React.ComponentType<any>): void;
function getCurrentlyVisibleScreenId(): Promise<string>;
function isAppLaunched(): Promise<boolean>;
}
export interface TabBasedApp {
@@ -118,7 +119,7 @@ export interface LightBox {
}
export interface NavigatorEvent {
id: 'willAppear' | 'didAppear' | 'willDisappear' | 'didDisappear' | 'willCommitPreview';
id: 'willAppear' | 'didAppear' | 'willDisappear' | 'didDisappear' | 'willCommitPreview' | 'backPress';
}
export class Navigator {
@@ -155,6 +156,11 @@ export class ScreenVisibilityListener {
unregister(): void;
}
export class NativeEventsReceiver {
constructor();
appLaunched(callback: () => void): void;
}
export interface ScreenVisibilityListenerParams {
willAppear?: (params: ListenerParams) => void;
didAppear?: (params: ListenerParams) => void;

View File

@@ -1,6 +1,13 @@
import * as React from 'react';
import { Text, View } from 'react-native';
import { Navigation, NavigationComponentProps, NavigatorStyle, NavigatorButtons, NavigatorEvent } from 'react-native-navigation';
import {
Navigation,
NavigationComponentProps,
NavigatorStyle,
NavigatorButtons,
NavigatorEvent,
NativeEventsReceiver,
} from 'react-native-navigation';
type Props = NavigationComponentProps & { height: number };
@@ -83,6 +90,17 @@ Navigation.registerComponent('example.Screen1', () => Screen1, {}, TestProvider,
Navigation.registerComponent('example.Screen2', () => Screen2);
Navigation.registerComponent('example.Drawer', () => Drawer);
Navigation.isAppLaunched().then(appLaunched => {
if (appLaunched) {
startApp(); // App is launched -> show UI
}
new NativeEventsReceiver().appLaunched(startApp); // App hasn't been launched yet -> show the UI only when needed.
});
function startApp() {
// do something here
}
Navigation.startTabBasedApp({
tabs: [
{