From 08bce4cb0618c59843a2149a00b7fbd7436228c1 Mon Sep 17 00:00:00 2001 From: Henrik Raitasola Date: Tue, 15 May 2018 11:08:24 +0300 Subject: [PATCH 1/4] Add missing backPress navigator event --- types/react-native-navigation/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-navigation/index.d.ts b/types/react-native-navigation/index.d.ts index 86b94bff44..c380b4ae7e 100644 --- a/types/react-native-navigation/index.d.ts +++ b/types/react-native-navigation/index.d.ts @@ -118,7 +118,7 @@ export interface LightBox { } export interface NavigatorEvent { - id: 'willAppear' | 'didAppear' | 'willDisappear' | 'didDisappear' | 'willCommitPreview'; + id: 'willAppear' | 'didAppear' | 'willDisappear' | 'didDisappear' | 'willCommitPreview' | 'backPress'; } export class Navigator { From 8bd493155842e447bf3be1640b419cd752a84587 Mon Sep 17 00:00:00 2001 From: Henrik Raitasola Date: Tue, 15 May 2018 11:16:15 +0300 Subject: [PATCH 2/4] Add one missing function and one missing class --- types/react-native-navigation/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/react-native-navigation/index.d.ts b/types/react-native-navigation/index.d.ts index c380b4ae7e..c1d096fe5f 100644 --- a/types/react-native-navigation/index.d.ts +++ b/types/react-native-navigation/index.d.ts @@ -18,6 +18,7 @@ export namespace Navigation { function handleDeepLink(params?: { link: string; payload?: string; }): void; function registerScreen(screenId: string, generator: () => React.ComponentType): void; function getCurrentlyVisibleScreenId(): Promise; + function isAppLaunched(): Promise; } export interface TabBasedApp { @@ -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; From 9c7095b7b499f9b37fbf504502a5b66948a19017 Mon Sep 17 00:00:00 2001 From: Henrik Raitasola Date: Tue, 15 May 2018 11:21:34 +0300 Subject: [PATCH 3/4] Add tests --- .../react-native-navigation-tests.tsx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/types/react-native-navigation/react-native-navigation-tests.tsx b/types/react-native-navigation/react-native-navigation-tests.tsx index 004673e10a..6adc4f5111 100644 --- a/types/react-native-navigation/react-native-navigation-tests.tsx +++ b/types/react-native-navigation/react-native-navigation-tests.tsx @@ -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 }; @@ -67,6 +74,17 @@ Navigation.registerComponent('example.Screen1', () => Screen1); 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: [ { From d443147e896c0569cf6acb7f296ebca1a2cba1fb Mon Sep 17 00:00:00 2001 From: Henrik Raitasola Date: Tue, 15 May 2018 11:25:11 +0300 Subject: [PATCH 4/4] Remove trailing whitespace --- types/react-native-navigation/react-native-navigation-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-navigation/react-native-navigation-tests.tsx b/types/react-native-navigation/react-native-navigation-tests.tsx index 6adc4f5111..e2ecc8bccb 100644 --- a/types/react-native-navigation/react-native-navigation-tests.tsx +++ b/types/react-native-navigation/react-native-navigation-tests.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { Text, View } from 'react-native'; -import { +import { Navigation, NavigationComponentProps, NavigatorStyle,