mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 06:29:40 +08:00
Merge pull request #25787 from henrikra/master
Add missing functions and classes (react-native-navigation)
This commit is contained in:
8
types/react-native-navigation/index.d.ts
vendored
8
types/react-native-navigation/index.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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: [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user