hybrid-navigation 2.13.1 → 2.13.4
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/README.md +4 -4
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +10 -11
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigatorRegistry.java +0 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +32 -64
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +8 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFrameLayout.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +1 -2
- package/ios/HybridNavigation/HBDUtils.m +3 -3
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +2 -2
- package/ios/HybridNavigation/Navigator/HBDStackNavigator.m +5 -5
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +8 -8
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +22 -15
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.h +2 -3
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.m +35 -29
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +2 -2
- package/ios/HybridNavigation/ViewController/HBDViewController.m +1 -1
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +1 -1
- package/lib/Event.d.ts +0 -2
- package/lib/Event.js +0 -9
- package/lib/GardenModule.d.ts +4 -0
- package/lib/GardenModule.js +19 -1
- package/lib/Navigation.d.ts +1 -1
- package/lib/NavigationModule.d.ts +1 -1
- package/lib/NavigationModule.js +6 -2
- package/lib/Navigator.js +10 -8
- package/lib/handler/LayoutCommandHandler.d.ts +1 -3
- package/lib/handler/LayoutCommandHandler.js +2 -19
- package/lib/index.d.ts +2 -5
- package/lib/index.js +3 -22
- package/package.json +1 -1
- package/src/Event.ts +0 -11
- package/src/GardenModule.ts +27 -1
- package/src/NavigationComponentWrap.tsx +0 -2
- package/src/NavigationModule.ts +7 -3
- package/src/Navigator.ts +10 -8
- package/src/handler/LayoutCommandHandler.ts +2 -22
- package/src/hooks.ts +0 -1
- package/src/index.ts +3 -31
- package/src/router/index.ts +0 -2
package/src/NavigationModule.ts
CHANGED
|
@@ -13,7 +13,7 @@ interface NavigationModule {
|
|
|
13
13
|
endRegisterReactComponent: () => void
|
|
14
14
|
registerReactComponent: (appKey: string, options: object) => void
|
|
15
15
|
signalFirstRenderComplete: (sceneId: string) => void
|
|
16
|
-
setRoot: (layout: object, sticky: boolean,
|
|
16
|
+
setRoot: (layout: object, sticky: boolean, callback: Callback) => void
|
|
17
17
|
setResult: (sceneId: string, resultCode: number, data: object | null) => void
|
|
18
18
|
dispatch: (sceneId: string, action: string, params: object, callback: Callback) => void
|
|
19
19
|
currentTab: (sceneId: string, callback: Callback) => void
|
|
@@ -49,8 +49,12 @@ function setResult(sceneId: string, resultCode: number, data: object | null) {
|
|
|
49
49
|
NavigationModule.setResult(sceneId, resultCode, data)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function setRoot(layout: object, sticky: boolean
|
|
53
|
-
|
|
52
|
+
function setRoot(layout: object, sticky: boolean) {
|
|
53
|
+
return new Promise<boolean>(resolve => {
|
|
54
|
+
NavigationModule.setRoot(layout, sticky, (_, success) => {
|
|
55
|
+
resolve(success)
|
|
56
|
+
})
|
|
57
|
+
})
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
function dispatch(sceneId: string, action: string, params: object) {
|
package/src/Navigator.ts
CHANGED
|
@@ -179,12 +179,12 @@ export class Navigator implements Navigator {
|
|
|
179
179
|
return await Navigation.result<T>(this.sceneId, 0)
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
pop = () => Navigation.dispatch(this.sceneId, 'pop')
|
|
182
|
+
pop = () => Navigation.dispatch(this.sceneId, 'pop', { from: this.moduleName })
|
|
183
183
|
|
|
184
184
|
popTo = (moduleName: string, inclusive: boolean = false) =>
|
|
185
|
-
Navigation.dispatch(this.sceneId, 'popTo', { moduleName, inclusive })
|
|
185
|
+
Navigation.dispatch(this.sceneId, 'popTo', { moduleName, inclusive, from: this.moduleName })
|
|
186
186
|
|
|
187
|
-
popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot')
|
|
187
|
+
popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot', { from: this.moduleName })
|
|
188
188
|
|
|
189
189
|
redirectTo = <P extends PropsType>(
|
|
190
190
|
moduleName: string,
|
|
@@ -193,6 +193,8 @@ export class Navigator implements Navigator {
|
|
|
193
193
|
) =>
|
|
194
194
|
Navigation.dispatch(this.sceneId, 'redirectTo', {
|
|
195
195
|
moduleName,
|
|
196
|
+
from: this.moduleName,
|
|
197
|
+
to: moduleName,
|
|
196
198
|
props,
|
|
197
199
|
options,
|
|
198
200
|
})
|
|
@@ -230,7 +232,7 @@ export class Navigator implements Navigator {
|
|
|
230
232
|
return await Navigation.result<T>(this.sceneId, requestCode)
|
|
231
233
|
}
|
|
232
234
|
|
|
233
|
-
dismiss = () => Navigation.dispatch(this.sceneId, 'dismiss')
|
|
235
|
+
dismiss = () => Navigation.dispatch(this.sceneId, 'dismiss', { from: this.moduleName })
|
|
234
236
|
|
|
235
237
|
showModal = async <T extends ResultType, P extends PropsType = {}>(
|
|
236
238
|
moduleName: string,
|
|
@@ -265,7 +267,7 @@ export class Navigator implements Navigator {
|
|
|
265
267
|
return await Navigation.result<T>(this.sceneId, requestCode)
|
|
266
268
|
}
|
|
267
269
|
|
|
268
|
-
hideModal = () => Navigation.dispatch(this.sceneId, 'hideModal')
|
|
270
|
+
hideModal = () => Navigation.dispatch(this.sceneId, 'hideModal', { from: this.moduleName })
|
|
269
271
|
|
|
270
272
|
setResult = <T extends ResultType>(resultCode: number, data: T = null as any): void =>
|
|
271
273
|
Navigation.setResult(this.sceneId, resultCode, data)
|
|
@@ -275,11 +277,11 @@ export class Navigator implements Navigator {
|
|
|
275
277
|
return Navigation.dispatch(this.sceneId, 'switchTab', { from, to: index, popToRoot })
|
|
276
278
|
}
|
|
277
279
|
|
|
278
|
-
toggleMenu = () => Navigation.dispatch(this.sceneId, 'toggleMenu')
|
|
280
|
+
toggleMenu = () => Navigation.dispatch(this.sceneId, 'toggleMenu', { from: this.moduleName })
|
|
279
281
|
|
|
280
|
-
openMenu = () => Navigation.dispatch(this.sceneId, 'openMenu')
|
|
282
|
+
openMenu = () => Navigation.dispatch(this.sceneId, 'openMenu', { from: this.moduleName })
|
|
281
283
|
|
|
282
|
-
closeMenu = () => Navigation.dispatch(this.sceneId, 'closeMenu')
|
|
284
|
+
closeMenu = () => Navigation.dispatch(this.sceneId, 'closeMenu', { from: this.moduleName })
|
|
283
285
|
|
|
284
286
|
isStackRoot = () => Navigation.isStackRoot(this.sceneId)
|
|
285
287
|
|
|
@@ -6,40 +6,20 @@ export default class LayoutCommandHandler {
|
|
|
6
6
|
private willSetRoot = () => {}
|
|
7
7
|
private didSetRoot = () => {}
|
|
8
8
|
|
|
9
|
-
private canInvokeWillSetRoot = true
|
|
10
|
-
private tagGenerator = 0
|
|
11
|
-
|
|
12
9
|
constructor() {}
|
|
13
10
|
|
|
14
11
|
handleRootLayoutChange() {
|
|
15
12
|
Event.listenWillSetRoot(() => {
|
|
16
|
-
|
|
17
|
-
this.willSetRoot()
|
|
18
|
-
}
|
|
13
|
+
this.willSetRoot()
|
|
19
14
|
})
|
|
20
15
|
|
|
21
16
|
Event.listenDidSetRoot(() => {
|
|
22
17
|
this.didSetRoot()
|
|
23
|
-
this.canInvokeWillSetRoot = true
|
|
24
18
|
})
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
setRoot(layout: BuildInLayout | Layout, sticky = false) {
|
|
28
|
-
|
|
29
|
-
this.canInvokeWillSetRoot = false
|
|
30
|
-
|
|
31
|
-
const flag = this.tagGenerator++
|
|
32
|
-
NavigationModule.setRoot(layout, sticky, flag)
|
|
33
|
-
|
|
34
|
-
return new Promise<void>(resolve => {
|
|
35
|
-
const subscription = Event.listenDidSetRoot((tag: number) => {
|
|
36
|
-
// FIXME: 此处恐有内存泄漏
|
|
37
|
-
if (tag === flag) {
|
|
38
|
-
subscription.remove()
|
|
39
|
-
resolve()
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
})
|
|
22
|
+
return NavigationModule.setRoot(layout, sticky)
|
|
43
23
|
}
|
|
44
24
|
|
|
45
25
|
setRootLayoutUpdateListener(willSetRoot = () => {}, didSetRoot = () => {}) {
|
package/src/hooks.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,40 +1,12 @@
|
|
|
1
|
-
import { Platform } from 'react-native'
|
|
2
|
-
import Navigation from './Navigation'
|
|
3
|
-
import Event from './Event'
|
|
4
|
-
import GardenModule from './GardenModule'
|
|
5
1
|
import { withNavigation } from './NavigationComponentWrap'
|
|
2
|
+
import Navigation from './Navigation'
|
|
6
3
|
|
|
7
4
|
Navigation.setNavigationComponentWrap(withNavigation)
|
|
8
5
|
|
|
9
|
-
const { STATUSBAR_HEIGHT, TOOLBAR_HEIGHT } = GardenModule.getConstants()
|
|
10
|
-
let _statusBarHeight = STATUSBAR_HEIGHT
|
|
11
|
-
if (Platform.OS === 'ios') {
|
|
12
|
-
Event.listenStatusBarHeightChange(height => {
|
|
13
|
-
_statusBarHeight = height
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function statusBarHeight() {
|
|
18
|
-
return _statusBarHeight
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function toolbarHeight() {
|
|
22
|
-
return TOOLBAR_HEIGHT
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function topBarHeight() {
|
|
26
|
-
return statusBarHeight() + toolbarHeight()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
6
|
export default Navigation
|
|
30
|
-
export { statusBarHeight, toolbarHeight, topBarHeight }
|
|
31
7
|
export { RESULT_OK, RESULT_CANCEL } from './Navigation'
|
|
32
|
-
export {
|
|
33
|
-
|
|
34
|
-
withNavigationItem,
|
|
35
|
-
NavigationProps,
|
|
36
|
-
InjectedProps,
|
|
37
|
-
} from './NavigationComponentWrap'
|
|
8
|
+
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule'
|
|
9
|
+
export { withNavigationItem, NavigationProps, InjectedProps } from './NavigationComponentWrap'
|
|
38
10
|
|
|
39
11
|
export * from './Navigator'
|
|
40
12
|
export * from './Garden'
|
package/src/router/index.ts
CHANGED
|
@@ -152,7 +152,6 @@ class Router {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
const route = this.pathToRoute(path, props, options)
|
|
155
|
-
|
|
156
155
|
if (!route) {
|
|
157
156
|
return
|
|
158
157
|
}
|
|
@@ -175,7 +174,6 @@ class Router {
|
|
|
175
174
|
const routeGraph = graphArray[0]
|
|
176
175
|
|
|
177
176
|
const consumed = await this.processRoute(route, routeGraph)
|
|
178
|
-
|
|
179
177
|
if (consumed) {
|
|
180
178
|
return
|
|
181
179
|
}
|