hybrid-navigation 2.13.0-beta.2 → 2.13.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/HybridNavigation/HBDUtils.h +3 -6
- package/ios/HybridNavigation/HBDUtils.m +10 -0
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +7 -2
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +1 -1
- package/ios/HybridNavigation/View/HBDRootView.m +9 -3
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +0 -30
- package/ios/HybridNavigation/ViewController/HBDViewController.m +7 -3
- package/ios/HybridNavigation/ViewController/UINavigationController+HBD.m +0 -3
- package/lib/Event.d.ts +22 -0
- package/lib/Event.js +117 -0
- package/lib/Garden.d.ts +2 -64
- package/lib/Garden.js +9 -47
- package/lib/GardenModule.d.ts +20 -0
- package/lib/GardenModule.js +3 -0
- package/lib/NavigationModule.d.ts +33 -22
- package/lib/NavigationModule.js +79 -22
- package/lib/Navigator.d.ts +33 -17
- package/lib/Navigator.js +106 -170
- package/lib/{typing.d.ts → Options.d.ts} +46 -50
- package/lib/{typing.js → Options.js} +0 -0
- package/lib/ReactRegistry.d.ts +2 -3
- package/lib/ReactRegistry.js +8 -28
- package/lib/Route.d.ts +74 -0
- package/lib/{router/typing.js → Route.js} +0 -0
- package/lib/hooks.d.ts +0 -1
- package/lib/hooks.js +18 -24
- package/lib/index.d.ts +3 -2
- package/lib/index.js +4 -2
- package/lib/router/drawer.d.ts +1 -1
- package/lib/router/index.d.ts +4 -7
- package/lib/router/index.js +1 -6
- package/lib/router/screen.d.ts +1 -1
- package/lib/router/stack.d.ts +1 -1
- package/lib/router/tabs.d.ts +1 -1
- package/lib/store.d.ts +0 -9
- package/lib/store.js +0 -22
- package/package.json +1 -1
- package/src/Event.ts +188 -0
- package/src/Garden.ts +18 -122
- package/src/GardenModule.ts +24 -0
- package/src/NavigationModule.ts +118 -29
- package/src/Navigator.ts +164 -209
- package/src/{typing.ts → Options.ts} +51 -57
- package/src/ReactRegistry.tsx +17 -40
- package/src/Route.ts +88 -0
- package/src/hooks.ts +23 -32
- package/src/index.ts +5 -2
- package/src/router/drawer.ts +1 -1
- package/src/router/index.ts +21 -12
- package/src/router/screen.ts +1 -1
- package/src/router/stack.ts +1 -1
- package/src/router/tabs.ts +1 -1
- package/src/store.ts +0 -28
- package/lib/router/typing.d.ts +0 -37
- package/lib/utils.d.ts +0 -9
- package/lib/utils.js +0 -50
- package/src/router/typing.ts +0 -45
- package/src/utils.ts +0 -83
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
import { Insets } from 'react-native';
|
|
2
|
-
import { Navigator } from './Navigator';
|
|
3
|
-
export interface IndexType {
|
|
4
|
-
[index: string]: any;
|
|
5
|
-
}
|
|
6
|
-
export interface PropsType {
|
|
7
|
-
[index: string]: any;
|
|
8
|
-
}
|
|
9
|
-
export declare type ResultType = IndexType | null;
|
|
10
|
-
interface Extras {
|
|
11
|
-
sceneId: string;
|
|
12
|
-
from?: number | string;
|
|
13
|
-
to?: number | string;
|
|
14
|
-
}
|
|
15
|
-
export interface NavigationInterceptor {
|
|
16
|
-
(action: string, extras: Extras): boolean | Promise<boolean>;
|
|
17
|
-
}
|
|
1
|
+
import type { Insets } from 'react-native';
|
|
2
|
+
import type { Navigator } from './Navigator';
|
|
18
3
|
export declare type Color = string;
|
|
19
4
|
export declare type ImageSource = {
|
|
20
5
|
uri: string;
|
|
@@ -93,41 +78,52 @@ export interface TabItem {
|
|
|
93
78
|
unselectedIcon?: ImageSource;
|
|
94
79
|
hideTabBarWhenPush?: boolean;
|
|
95
80
|
}
|
|
96
|
-
export interface
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
props?: IndexType;
|
|
100
|
-
options?: NavigationItem;
|
|
101
|
-
};
|
|
81
|
+
export interface ShadowImage {
|
|
82
|
+
image?: ImageSource;
|
|
83
|
+
color?: Color;
|
|
102
84
|
}
|
|
103
|
-
export interface
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
85
|
+
export interface DefaultOptions {
|
|
86
|
+
screenBackgroundColor?: Color;
|
|
87
|
+
topBarStyle?: BarStyle;
|
|
88
|
+
topBarColor?: Color;
|
|
89
|
+
topBarColorDarkContent?: Color;
|
|
90
|
+
topBarColorLightContent?: Color;
|
|
91
|
+
statusBarColorAndroid?: Color;
|
|
92
|
+
navigationBarColorAndroid?: Color;
|
|
93
|
+
hideBackTitleIOS?: boolean;
|
|
94
|
+
elevationAndroid?: number;
|
|
95
|
+
shadowImage?: ShadowImage;
|
|
96
|
+
backIcon?: ImageSource;
|
|
97
|
+
topBarTintColor?: Color;
|
|
98
|
+
topBarTintColorDarkContent?: Color;
|
|
99
|
+
topBarTintColorLightContent?: Color;
|
|
100
|
+
titleTextColor?: Color;
|
|
101
|
+
titleTextColorDarkContent?: Color;
|
|
102
|
+
titleTextColorLightContent?: Color;
|
|
103
|
+
titleTextSize?: number;
|
|
104
|
+
titleAlignmentAndroid?: TitleAlignment;
|
|
105
|
+
barButtonItemTextSize?: number;
|
|
106
|
+
swipeBackEnabledAndroid?: boolean;
|
|
107
|
+
splitTopBarTransitionIOS?: boolean;
|
|
108
|
+
scrimAlphaAndroid?: number;
|
|
109
|
+
displayCutoutWhenLandscapeAndroid?: boolean;
|
|
110
|
+
tabBarColor?: Color;
|
|
111
|
+
tabBarShadowImage?: ShadowImage;
|
|
112
|
+
tabBarItemColor?: Color;
|
|
113
|
+
tabBarUnselectedItemColor?: Color;
|
|
114
|
+
tabBarBadgeColor?: Color;
|
|
108
115
|
}
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
export declare type TabBarStyle = Pick<DefaultOptions, 'tabBarColor' | 'tabBarShadowImage' | 'tabBarItemColor' | 'tabBarUnselectedItemColor'>;
|
|
117
|
+
export interface TabItemInfo {
|
|
118
|
+
index: number;
|
|
119
|
+
title?: string;
|
|
120
|
+
badge?: {
|
|
121
|
+
text?: string;
|
|
122
|
+
hidden: boolean;
|
|
123
|
+
dot?: boolean;
|
|
117
124
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
children: [BuildInLayout | Layout, BuildInLayout | Layout];
|
|
122
|
-
options?: {
|
|
123
|
-
maxDrawerWidth?: number;
|
|
124
|
-
minDrawerMargin?: number;
|
|
125
|
-
menuInteractive?: boolean;
|
|
126
|
-
};
|
|
125
|
+
icon?: {
|
|
126
|
+
selected: ImageSource;
|
|
127
|
+
unselected?: ImageSource;
|
|
127
128
|
};
|
|
128
129
|
}
|
|
129
|
-
export declare type BuildInLayout = Screen | Stack | Tabs | Drawer;
|
|
130
|
-
export interface Layout {
|
|
131
|
-
[index: string]: {};
|
|
132
|
-
}
|
|
133
|
-
export {};
|
|
File without changes
|
package/lib/ReactRegistry.d.ts
CHANGED
|
@@ -2,14 +2,13 @@ import { ComponentProvider } from 'react-native';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Navigator } from './Navigator';
|
|
4
4
|
import { Garden } from './Garden';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { NavigationItem } from './Options';
|
|
6
|
+
import { RouteConfig } from './Route';
|
|
7
7
|
export interface InjectedProps {
|
|
8
8
|
navigator: Navigator;
|
|
9
9
|
garden: Garden;
|
|
10
10
|
sceneId: string;
|
|
11
11
|
}
|
|
12
|
-
export declare const NavigationContext: React.Context<any>;
|
|
13
12
|
export declare type HOC = (WrappedComponent: React.ComponentType<any>) => React.ComponentType<any>;
|
|
14
13
|
export declare class ReactRegistry {
|
|
15
14
|
static registerEnded: boolean;
|
package/lib/ReactRegistry.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { AppRegistry } from 'react-native';
|
|
2
|
-
import React, { useEffect
|
|
3
|
-
import { Navigator } from './Navigator';
|
|
4
|
-
import { NavigationModule, EventEmitter, EVENT_NAVIGATION, KEY_SCENE_ID, KEY_ON, ON_COMPONENT_APPEAR, ON_COMPONENT_DISAPPEAR, } from './NavigationModule';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
|
+
import { Navigator, NavigationContext } from './Navigator';
|
|
5
4
|
import { router } from './router';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import NavigationModule from './NavigationModule';
|
|
6
|
+
import Event from './Event';
|
|
8
7
|
function getDisplayName(WrappedComponent) {
|
|
9
8
|
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
function withNavigator(moduleName) {
|
|
10
|
+
function withNavigation(moduleName) {
|
|
13
11
|
return function (WrappedComponent) {
|
|
14
12
|
const FC = React.forwardRef((props, ref) => {
|
|
15
13
|
const { sceneId } = props;
|
|
@@ -21,26 +19,9 @@ function withNavigator(moduleName) {
|
|
|
21
19
|
useEffect(() => {
|
|
22
20
|
navigator.signalFirstRenderComplete();
|
|
23
21
|
return () => {
|
|
24
|
-
removeBarButtonItemClickEvent(navigator.sceneId);
|
|
25
|
-
store.removeNavigator(navigator.sceneId);
|
|
26
22
|
navigator.unmount();
|
|
27
23
|
};
|
|
28
24
|
}, [navigator]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const subscription = EventEmitter.addListener(EVENT_NAVIGATION, data => {
|
|
31
|
-
if (navigator.sceneId === data[KEY_SCENE_ID]) {
|
|
32
|
-
if (data[KEY_ON] === ON_COMPONENT_APPEAR) {
|
|
33
|
-
navigator.visibility = 'visible';
|
|
34
|
-
}
|
|
35
|
-
else if (data[KEY_ON] === ON_COMPONENT_DISAPPEAR) {
|
|
36
|
-
navigator.visibility = 'invisible';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return () => {
|
|
41
|
-
subscription.remove();
|
|
42
|
-
};
|
|
43
|
-
}, [navigator]);
|
|
44
25
|
const injected = {
|
|
45
26
|
garden,
|
|
46
27
|
navigator,
|
|
@@ -49,7 +30,7 @@ function withNavigator(moduleName) {
|
|
|
49
30
|
<WrappedComponent ref={ref} {...props} {...injected}/>
|
|
50
31
|
</NavigationContext.Provider>);
|
|
51
32
|
});
|
|
52
|
-
FC.displayName = `
|
|
33
|
+
FC.displayName = `withNavigation(${getDisplayName(WrappedComponent)})`;
|
|
53
34
|
return FC;
|
|
54
35
|
};
|
|
55
36
|
}
|
|
@@ -57,7 +38,6 @@ let wrap;
|
|
|
57
38
|
export class ReactRegistry {
|
|
58
39
|
static registerEnded;
|
|
59
40
|
static startRegisterComponent(hoc) {
|
|
60
|
-
store.clear();
|
|
61
41
|
wrap = hoc;
|
|
62
42
|
ReactRegistry.registerEnded = false;
|
|
63
43
|
NavigationModule.startRegisterReactComponent();
|
|
@@ -79,9 +59,9 @@ export class ReactRegistry {
|
|
|
79
59
|
WrappedComponent = wrap(WrappedComponent);
|
|
80
60
|
}
|
|
81
61
|
// build static options
|
|
82
|
-
let options =
|
|
62
|
+
let options = Event.bindBarButtonClickEvent('permanent', WrappedComponent.navigationItem) || {};
|
|
83
63
|
NavigationModule.registerReactComponent(appKey, options);
|
|
84
|
-
let RootComponent =
|
|
64
|
+
let RootComponent = withNavigation(appKey)(WrappedComponent);
|
|
85
65
|
AppRegistry.registerComponent(appKey, () => RootComponent);
|
|
86
66
|
}
|
|
87
67
|
}
|
package/lib/Route.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare type Visibility = 'visible' | 'invisible' | 'pending';
|
|
2
|
+
export interface Screen extends Layout {
|
|
3
|
+
screen: {
|
|
4
|
+
moduleName: string;
|
|
5
|
+
props?: object;
|
|
6
|
+
options?: {};
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface Stack extends Layout {
|
|
10
|
+
stack: {
|
|
11
|
+
children: Array<BuildInLayout | Layout>;
|
|
12
|
+
options?: {};
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface Tabs extends Layout {
|
|
16
|
+
tabs: {
|
|
17
|
+
children: Array<BuildInLayout | Layout>;
|
|
18
|
+
options?: {
|
|
19
|
+
selectedIndex?: number;
|
|
20
|
+
tabBarModuleName?: string;
|
|
21
|
+
sizeIndeterminate?: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface Drawer extends Layout {
|
|
26
|
+
drawer: {
|
|
27
|
+
children: [BuildInLayout | Layout, BuildInLayout | Layout];
|
|
28
|
+
options?: {
|
|
29
|
+
maxDrawerWidth?: number;
|
|
30
|
+
minDrawerMargin?: number;
|
|
31
|
+
menuInteractive?: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare type BuildInLayout = Screen | Stack | Tabs | Drawer;
|
|
36
|
+
export interface Layout {
|
|
37
|
+
[index: string]: {};
|
|
38
|
+
}
|
|
39
|
+
export declare type RouteMode = 'modal' | 'present' | 'push';
|
|
40
|
+
export declare type LayoutMode = 'modal' | 'present' | 'normal';
|
|
41
|
+
export interface Route {
|
|
42
|
+
sceneId: string;
|
|
43
|
+
moduleName: string;
|
|
44
|
+
mode: LayoutMode;
|
|
45
|
+
}
|
|
46
|
+
export interface RouteGraph {
|
|
47
|
+
layout: string;
|
|
48
|
+
sceneId: string;
|
|
49
|
+
mode: LayoutMode;
|
|
50
|
+
children?: RouteGraph[];
|
|
51
|
+
}
|
|
52
|
+
export interface RouteConfig {
|
|
53
|
+
path?: string;
|
|
54
|
+
dependency?: string;
|
|
55
|
+
mode?: RouteMode;
|
|
56
|
+
}
|
|
57
|
+
export interface RouteInfo {
|
|
58
|
+
moduleName: string;
|
|
59
|
+
dependencies: string[];
|
|
60
|
+
mode: RouteMode;
|
|
61
|
+
props: object;
|
|
62
|
+
options: object;
|
|
63
|
+
}
|
|
64
|
+
export interface RouteData {
|
|
65
|
+
moduleName: string;
|
|
66
|
+
regexp?: RegExp;
|
|
67
|
+
path?: string;
|
|
68
|
+
dependency?: string;
|
|
69
|
+
mode: RouteMode;
|
|
70
|
+
}
|
|
71
|
+
export interface RouteHandler {
|
|
72
|
+
(graph: RouteGraph, route: RouteInfo, next: RouteHandler): Promise<boolean>;
|
|
73
|
+
}
|
|
74
|
+
export declare type RouteInterceptor = (path: string) => boolean | Promise<boolean>;
|
|
File without changes
|
package/lib/hooks.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Navigator } from './Navigator';
|
|
3
|
-
export declare type Visibility = 'visible' | 'invisible' | 'pending';
|
|
4
3
|
export declare function useVisible(): boolean;
|
|
5
4
|
export declare function useVisibility(): "visible" | "invisible" | "pending";
|
|
6
5
|
export declare function useVisibleEffect(effect: React.EffectCallback): void;
|
package/lib/hooks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import { NavigationContext } from './
|
|
2
|
+
import Event from './Event';
|
|
3
|
+
import { NavigationContext } from './Navigator';
|
|
4
4
|
export function useVisible() {
|
|
5
5
|
const visibility = useVisibility();
|
|
6
6
|
return visibility === 'visible';
|
|
@@ -9,19 +9,16 @@ export function useVisibility() {
|
|
|
9
9
|
const navigator = useNavigator();
|
|
10
10
|
const [visibility, setVisibility] = useState(navigator.visibility);
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
const subscription =
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
12
|
+
const subscription = Event.listenComponentVisibility((sceneId) => {
|
|
13
|
+
if (sceneId === navigator.sceneId) {
|
|
14
|
+
setVisibility('visible');
|
|
15
|
+
}
|
|
16
|
+
}, (sceneId) => {
|
|
17
|
+
if (sceneId === navigator.sceneId) {
|
|
18
|
+
setVisibility('invisible');
|
|
20
19
|
}
|
|
21
20
|
});
|
|
22
|
-
return () =>
|
|
23
|
-
subscription.remove();
|
|
24
|
-
};
|
|
21
|
+
return () => subscription.remove();
|
|
25
22
|
}, [navigator]);
|
|
26
23
|
return visibility;
|
|
27
24
|
}
|
|
@@ -32,17 +29,14 @@ export function useVisibleEffect(effect) {
|
|
|
32
29
|
if (navigator.visibility === 'visible') {
|
|
33
30
|
destructor.current = effect();
|
|
34
31
|
}
|
|
35
|
-
const subscription =
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
destructor.current = undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
32
|
+
const subscription = Event.listenComponentVisibility((sceneId) => {
|
|
33
|
+
if (sceneId === navigator.sceneId) {
|
|
34
|
+
destructor.current = effect();
|
|
35
|
+
}
|
|
36
|
+
}, (sceneId) => {
|
|
37
|
+
if (sceneId === navigator.sceneId && destructor.current) {
|
|
38
|
+
destructor.current();
|
|
39
|
+
destructor.current = undefined;
|
|
46
40
|
}
|
|
47
41
|
});
|
|
48
42
|
return () => {
|
package/lib/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export * from './ReactRegistry';
|
|
|
4
4
|
export * from './hooks';
|
|
5
5
|
export * from './router';
|
|
6
6
|
export * from './DeepLink';
|
|
7
|
-
export * from './
|
|
8
|
-
export
|
|
7
|
+
export * from './Route';
|
|
8
|
+
export * from './Options';
|
|
9
|
+
export declare const RESULT_OK: number, RESULT_CANCEL: number;
|
package/lib/index.js
CHANGED
|
@@ -4,5 +4,7 @@ export * from './ReactRegistry';
|
|
|
4
4
|
export * from './hooks';
|
|
5
5
|
export * from './router';
|
|
6
6
|
export * from './DeepLink';
|
|
7
|
-
export * from './
|
|
8
|
-
export
|
|
7
|
+
export * from './Route';
|
|
8
|
+
export * from './Options';
|
|
9
|
+
import NavigationModule from './NavigationModule';
|
|
10
|
+
export const { RESULT_OK, RESULT_CANCEL } = NavigationModule.getConstants();
|
package/lib/router/drawer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RouteGraph, LayoutMode, RouteInfo, RouteHandler } from './typing';
|
|
2
1
|
import { ScreenGraph } from './screen';
|
|
2
|
+
import { LayoutMode, RouteGraph, RouteHandler, RouteInfo } from '../Route';
|
|
3
3
|
export interface DrawerGraph extends RouteGraph {
|
|
4
4
|
layout: 'drawer';
|
|
5
5
|
sceneId: string;
|
package/lib/router/index.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
import { RouteConfig, RouteInfo, RouteInterceptor
|
|
2
|
-
import {
|
|
1
|
+
import { RouteConfig, RouteHandler, RouteInfo, RouteInterceptor } from '../Route';
|
|
2
|
+
import { NavigationItem } from '../Options';
|
|
3
3
|
declare function addInterceptor(func: RouteInterceptor): void;
|
|
4
4
|
declare function removeInterceptor(func: RouteInterceptor): void;
|
|
5
|
-
declare function addRouteHandler(handler: RouteHandler): void;
|
|
6
5
|
declare function use(handler: RouteHandler): void;
|
|
7
6
|
declare function registerRoute(moduleName: string, route: RouteConfig): void;
|
|
8
|
-
declare function open(path: string, props?:
|
|
9
|
-
declare function pathToRoute(path: string, props:
|
|
7
|
+
declare function open(path: string, props?: object, options?: NavigationItem): Promise<void>;
|
|
8
|
+
declare function pathToRoute(path: string, props: object, options: NavigationItem): RouteInfo | undefined;
|
|
10
9
|
export declare const router: {
|
|
11
10
|
addInterceptor: typeof addInterceptor;
|
|
12
11
|
removeInterceptor: typeof removeInterceptor;
|
|
13
|
-
addRouteHandler: typeof addRouteHandler;
|
|
14
12
|
registerRoute: typeof registerRoute;
|
|
15
13
|
use: typeof use;
|
|
16
14
|
open: typeof open;
|
|
17
15
|
pathToRoute: typeof pathToRoute;
|
|
18
16
|
};
|
|
19
|
-
export * from './typing';
|
|
20
17
|
export * from './drawer';
|
|
21
18
|
export * from './screen';
|
|
22
19
|
export * from './stack';
|
package/lib/router/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Navigator } from '../Navigator';
|
|
2
1
|
import { pathToRegexp, match } from 'path-to-regexp';
|
|
3
2
|
import { stackRouteHandler } from './stack';
|
|
4
3
|
import { tabsRouteHandler } from './tabs';
|
|
5
4
|
import { drawerRouteHandler } from './drawer';
|
|
5
|
+
import { Navigator } from '../Navigator';
|
|
6
6
|
let routeDatas = new Map();
|
|
7
7
|
let interceptors = new Set();
|
|
8
8
|
let handlers = new Set([drawerRouteHandler, tabsRouteHandler, stackRouteHandler]);
|
|
@@ -20,9 +20,6 @@ function addInterceptor(func) {
|
|
|
20
20
|
function removeInterceptor(func) {
|
|
21
21
|
interceptors.delete(func);
|
|
22
22
|
}
|
|
23
|
-
function addRouteHandler(handler) {
|
|
24
|
-
handlers.add(handler);
|
|
25
|
-
}
|
|
26
23
|
function use(handler) {
|
|
27
24
|
handlers.add(handler);
|
|
28
25
|
}
|
|
@@ -135,13 +132,11 @@ function routeDependencies(routeData) {
|
|
|
135
132
|
export const router = {
|
|
136
133
|
addInterceptor,
|
|
137
134
|
removeInterceptor,
|
|
138
|
-
addRouteHandler,
|
|
139
135
|
registerRoute,
|
|
140
136
|
use,
|
|
141
137
|
open,
|
|
142
138
|
pathToRoute,
|
|
143
139
|
};
|
|
144
|
-
export * from './typing';
|
|
145
140
|
export * from './drawer';
|
|
146
141
|
export * from './screen';
|
|
147
142
|
export * from './stack';
|
package/lib/router/screen.d.ts
CHANGED
package/lib/router/stack.d.ts
CHANGED
package/lib/router/tabs.d.ts
CHANGED
package/lib/store.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import { Navigator } from './Navigator';
|
|
2
|
-
import { EmitterSubscription } from 'react-native';
|
|
3
2
|
declare function addNavigator(sceneId: string, navigator: Navigator): void;
|
|
4
3
|
declare function removeNavigator(sceneId: string): void;
|
|
5
4
|
declare function getNavigator(sceneId: string): Navigator | undefined;
|
|
6
|
-
declare function addBarButtonItemClickEvent(event: EmitterSubscription): void;
|
|
7
|
-
declare function removeBarButtonItemClickEvent(event: EmitterSubscription): void;
|
|
8
|
-
declare function filterBarButtonItemClickEvent(callback: (event: EmitterSubscription) => boolean): EmitterSubscription[];
|
|
9
|
-
declare function clear(): void;
|
|
10
5
|
declare const _default: {
|
|
11
6
|
addNavigator: typeof addNavigator;
|
|
12
7
|
removeNavigator: typeof removeNavigator;
|
|
13
8
|
getNavigator: typeof getNavigator;
|
|
14
|
-
addBarButtonItemClickEvent: typeof addBarButtonItemClickEvent;
|
|
15
|
-
removeBarButtonItemClickEvent: typeof removeBarButtonItemClickEvent;
|
|
16
|
-
filterBarButtonItemClickEvent: typeof filterBarButtonItemClickEvent;
|
|
17
|
-
clear: typeof clear;
|
|
18
9
|
};
|
|
19
10
|
export default _default;
|
package/lib/store.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const navigators = new Map();
|
|
2
|
-
let events = [];
|
|
3
2
|
function addNavigator(sceneId, navigator) {
|
|
4
3
|
navigators.set(sceneId, navigator);
|
|
5
4
|
}
|
|
@@ -9,29 +8,8 @@ function removeNavigator(sceneId) {
|
|
|
9
8
|
function getNavigator(sceneId) {
|
|
10
9
|
return navigators.get(sceneId);
|
|
11
10
|
}
|
|
12
|
-
function addBarButtonItemClickEvent(event) {
|
|
13
|
-
events.push(event);
|
|
14
|
-
}
|
|
15
|
-
function removeBarButtonItemClickEvent(event) {
|
|
16
|
-
event.remove();
|
|
17
|
-
events = events.filter(e => e !== event);
|
|
18
|
-
}
|
|
19
|
-
function filterBarButtonItemClickEvent(callback) {
|
|
20
|
-
return events.filter(callback);
|
|
21
|
-
}
|
|
22
|
-
function clear() {
|
|
23
|
-
navigators.clear();
|
|
24
|
-
events.forEach(event => {
|
|
25
|
-
event.remove();
|
|
26
|
-
});
|
|
27
|
-
events = [];
|
|
28
|
-
}
|
|
29
11
|
export default {
|
|
30
12
|
addNavigator,
|
|
31
13
|
removeNavigator,
|
|
32
14
|
getNavigator,
|
|
33
|
-
addBarButtonItemClickEvent,
|
|
34
|
-
removeBarButtonItemClickEvent,
|
|
35
|
-
filterBarButtonItemClickEvent,
|
|
36
|
-
clear,
|
|
37
15
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hybrid-navigation",
|
|
3
3
|
"description": "React Native Navigation that supports seamless navigation between Native and React.",
|
|
4
|
-
"version": "2.13.0-beta.
|
|
4
|
+
"version": "2.13.0-beta.3",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
7
7
|
"react-native": "src/index",
|