hybrid-navigation 2.13.0 → 2.13.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/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/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/Garden.d.ts +3 -0
- package/lib/Garden.js +3 -0
- package/lib/GardenModule.d.ts +4 -0
- package/lib/GardenModule.js +19 -1
- package/lib/Navigation.d.ts +4 -10
- package/lib/Navigation.js +8 -28
- package/lib/NavigationComponentWrap.d.ts +1 -1
- package/lib/NavigationModule.d.ts +1 -1
- package/lib/NavigationModule.js +6 -2
- package/lib/Navigator.d.ts +5 -2
- package/lib/Navigator.js +35 -15
- package/lib/ReactRegistry.d.ts +3 -0
- package/lib/ReactRegistry.js +3 -0
- package/lib/Route.d.ts +13 -8
- package/lib/handler/DispatchCommandHandler.d.ts +2 -0
- package/lib/handler/LayoutCommandHandler.d.ts +1 -3
- package/lib/handler/LayoutCommandHandler.js +2 -19
- package/lib/hooks.d.ts +4 -0
- package/lib/hooks.js +4 -0
- package/lib/index.d.ts +2 -5
- package/lib/index.js +3 -11
- package/lib/router/drawer.d.ts +3 -1
- package/lib/router/drawer.js +17 -17
- package/lib/router/index.d.ts +19 -15
- package/lib/router/index.js +137 -125
- package/lib/router/screen.d.ts +5 -1
- package/lib/router/screen.js +29 -0
- package/lib/router/stack.d.ts +5 -1
- package/lib/router/stack.js +59 -46
- package/lib/router/tabs.d.ts +3 -1
- package/lib/router/tabs.js +18 -28
- package/package.json +1 -1
- package/src/Event.ts +0 -11
- package/src/Garden.ts +4 -0
- package/src/GardenModule.ts +27 -1
- package/src/Navigation.ts +12 -37
- package/src/NavigationComponentWrap.tsx +1 -3
- package/src/NavigationModule.ts +7 -3
- package/src/Navigator.ts +36 -16
- package/src/ReactRegistry.tsx +3 -0
- package/src/Route.ts +14 -9
- package/src/handler/DispatchCommandHandler.ts +2 -0
- package/src/handler/LayoutCommandHandler.ts +2 -22
- package/src/hooks.ts +4 -1
- package/src/index.ts +3 -29
- package/src/router/drawer.ts +20 -17
- package/src/router/index.ts +145 -131
- package/src/router/screen.ts +34 -1
- package/src/router/stack.ts +61 -48
- package/src/router/tabs.ts +19 -29
|
@@ -53,7 +53,7 @@ const NSInteger ResultCancel = 0;
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
- (void)invalidate {
|
|
56
|
-
RCTLogInfo(@"[
|
|
56
|
+
RCTLogInfo(@"[Navigation] HBDReactBridgeManager#invalidate");
|
|
57
57
|
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
58
58
|
|
|
59
59
|
NSArray<id <HBDNavigator>> *navigators = [self.navigatorRegistry allNavigators];
|
|
@@ -63,6 +63,7 @@ const NSInteger ResultCancel = 0;
|
|
|
63
63
|
|
|
64
64
|
self.viewHierarchyReady = NO;
|
|
65
65
|
self.reactModuleRegisterCompleted = NO;
|
|
66
|
+
self.didSetRoot = NULL;
|
|
66
67
|
|
|
67
68
|
UIWindow *mainWindow = [self mainWindow];
|
|
68
69
|
UIViewController *presentedViewController = mainWindow.rootViewController.presentedViewController;
|
|
@@ -155,7 +156,7 @@ const NSInteger ResultCancel = 0;
|
|
|
155
156
|
UIViewController *vc = [self createViewControllerWithLayout:layout];
|
|
156
157
|
|
|
157
158
|
if (!vc) {
|
|
158
|
-
RCTLogError(@"[
|
|
159
|
+
RCTLogError(@"[Navigation] Can't find a navigator that can handle layout '%@'. Did you forget to register?", layout);
|
|
159
160
|
return nil;
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -186,13 +187,13 @@ const NSInteger ResultCancel = 0;
|
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
|
|
189
|
-
- (UIViewController *)
|
|
190
|
-
if (
|
|
191
|
-
|
|
190
|
+
- (UIViewController *)viewControllerBySceneId:(NSString *)sceneId {
|
|
191
|
+
if (self.viewHierarchyReady) {
|
|
192
|
+
UIWindow *window = [self mainWindow];
|
|
193
|
+
return [self viewControllerWithSceneId:sceneId viewController:window.rootViewController];
|
|
192
194
|
}
|
|
193
195
|
|
|
194
|
-
|
|
195
|
-
return [self viewControllerWithSceneId:sceneId viewController:window.rootViewController];
|
|
196
|
+
return nil;
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
- (UIViewController *)viewControllerWithSceneId:(NSString *)sceneId viewController:(UIViewController *)vc {
|
|
@@ -224,24 +225,19 @@ const NSInteger ResultCancel = 0;
|
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
- (void)setRootViewController:(UIViewController *)rootViewController {
|
|
227
|
-
[self setRootViewController:rootViewController withTag:@(0)];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
- (void)setRootViewController:(UIViewController *)rootViewController withTag:(NSNumber *)tag {
|
|
231
|
-
[HBDEventEmitter sendEvent:EVENT_WILL_SET_ROOT data:@{}];
|
|
232
|
-
|
|
233
228
|
UIWindow *mainWindow = [self mainWindow];
|
|
234
229
|
UIViewController *presentedViewController = mainWindow.rootViewController.presentedViewController;
|
|
235
230
|
if (presentedViewController && !presentedViewController.isBeingDismissed) {
|
|
236
231
|
[mainWindow.rootViewController dismissViewControllerAnimated:NO completion:^{
|
|
237
|
-
[self performSetRootViewController:rootViewController
|
|
232
|
+
[self performSetRootViewController:rootViewController animated:NO];
|
|
238
233
|
}];
|
|
239
234
|
} else {
|
|
240
|
-
[self performSetRootViewController:rootViewController
|
|
235
|
+
[self performSetRootViewController:rootViewController animated:YES];
|
|
241
236
|
}
|
|
242
237
|
}
|
|
243
238
|
|
|
244
|
-
- (void)performSetRootViewController:(UIViewController *)rootViewController
|
|
239
|
+
- (void)performSetRootViewController:(UIViewController *)rootViewController animated:(BOOL)animated {
|
|
240
|
+
[HBDEventEmitter sendEvent:EVENT_WILL_SET_ROOT data:@{}];
|
|
245
241
|
UIWindow *mainWindow = [self mainWindow];
|
|
246
242
|
if (animated) {
|
|
247
243
|
[UIView transitionWithView:mainWindow duration:0.15f options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
|
|
@@ -253,9 +249,13 @@ const NSInteger ResultCancel = 0;
|
|
|
253
249
|
[mainWindow makeKeyAndVisible];
|
|
254
250
|
}
|
|
255
251
|
[UIView setAnimationsEnabled:oldState];
|
|
252
|
+
} completion:^(BOOL finished) {
|
|
256
253
|
self.viewHierarchyReady = YES;
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
if (self.didSetRoot) {
|
|
255
|
+
self.didSetRoot(@[NSNull.null, @YES]);
|
|
256
|
+
self.didSetRoot = NULL;
|
|
257
|
+
}
|
|
258
|
+
[HBDEventEmitter sendEvent:EVENT_DID_SET_ROOT data:@{}];
|
|
259
259
|
}];
|
|
260
260
|
} else {
|
|
261
261
|
mainWindow.rootViewController = rootViewController;
|
|
@@ -263,8 +263,13 @@ const NSInteger ResultCancel = 0;
|
|
|
263
263
|
if (!mainWindow.isKeyWindow) {
|
|
264
264
|
[mainWindow makeKeyAndVisible];
|
|
265
265
|
}
|
|
266
|
+
|
|
266
267
|
self.viewHierarchyReady = YES;
|
|
267
|
-
|
|
268
|
+
if (self.didSetRoot) {
|
|
269
|
+
self.didSetRoot(@[NSNull.null, @YES]);
|
|
270
|
+
self.didSetRoot = NULL;
|
|
271
|
+
}
|
|
272
|
+
[HBDEventEmitter sendEvent:EVENT_DID_SET_ROOT data:@{}];
|
|
268
273
|
}
|
|
269
274
|
}
|
|
270
275
|
|
|
@@ -281,11 +286,12 @@ const NSInteger ResultCancel = 0;
|
|
|
281
286
|
}
|
|
282
287
|
|
|
283
288
|
NSString *layout = [self.navigatorRegistry layoutForViewController:vc];
|
|
284
|
-
if (
|
|
285
|
-
|
|
289
|
+
if (layout) {
|
|
290
|
+
id <HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:layout];
|
|
291
|
+
return [navigator primaryViewControllerWithViewController:vc];
|
|
286
292
|
}
|
|
287
|
-
|
|
288
|
-
return
|
|
293
|
+
|
|
294
|
+
return nil;
|
|
289
295
|
}
|
|
290
296
|
|
|
291
297
|
- (NSArray *)routeGraph {
|
|
@@ -295,13 +301,13 @@ const NSInteger ResultCancel = 0;
|
|
|
295
301
|
NSMutableArray *root = [[NSMutableArray alloc] init];
|
|
296
302
|
[root addObject:graph];
|
|
297
303
|
[root addObjectsFromArray:[self presentedGraphsWithRootViewController:vc]];
|
|
298
|
-
|
|
299
304
|
return root;
|
|
300
305
|
}
|
|
301
306
|
|
|
302
307
|
- (NSArray *)presentedGraphsWithRootViewController:(UIViewController *)vc {
|
|
303
308
|
NSMutableArray *graphs = [[NSMutableArray alloc] init];
|
|
304
309
|
UIViewController *presented = vc.presentedViewController;
|
|
310
|
+
|
|
305
311
|
while (presented && !presented.beingDismissed && ![presented isKindOfClass:[UIAlertController class]]) {
|
|
306
312
|
NSDictionary *graph = [self routeGraphWithViewController:presented];
|
|
307
313
|
if (graph) {
|
|
@@ -315,17 +321,17 @@ const NSInteger ResultCancel = 0;
|
|
|
315
321
|
|
|
316
322
|
- (NSDictionary *)routeGraphWithViewController:(UIViewController *)vc {
|
|
317
323
|
NSString *layout = [self.navigatorRegistry layoutForViewController:vc];
|
|
318
|
-
if (
|
|
319
|
-
|
|
324
|
+
if (layout) {
|
|
325
|
+
id <HBDNavigator> navigator = [self.navigatorRegistry navigatorForLayout:layout];
|
|
326
|
+
return [navigator routeGraphWithViewController:vc];
|
|
320
327
|
}
|
|
321
|
-
|
|
322
|
-
return [navigator routeGraphWithViewController:vc];
|
|
328
|
+
return nil;
|
|
323
329
|
}
|
|
324
330
|
|
|
325
331
|
- (void)handleNavigationWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback {
|
|
326
332
|
id <HBDNavigator> navigator = [self.navigatorRegistry navigatorForAction:action];
|
|
327
333
|
if (!navigator) {
|
|
328
|
-
RCTLogWarn(@"[
|
|
334
|
+
RCTLogWarn(@"[Navigation] Can't find a navigator that can handle action '%@'", action);
|
|
329
335
|
callback(@[NSNull.null, @NO]);
|
|
330
336
|
return;
|
|
331
337
|
}
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
@dynamic navigationBar;
|
|
328
328
|
|
|
329
329
|
- (void)dealloc {
|
|
330
|
-
RCTLogInfo(@"[
|
|
330
|
+
RCTLogInfo(@"[Navigation] %s", __FUNCTION__);
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController {
|
|
@@ -415,7 +415,7 @@
|
|
|
415
415
|
UIEdgeInsets safeAreaInsets = self.view.safeAreaInsets;
|
|
416
416
|
UIEdgeInsets additionalInsets = self.additionalSafeAreaInsets;
|
|
417
417
|
|
|
418
|
-
// RCTLogInfo(@"[
|
|
418
|
+
// RCTLogInfo(@"[Navigation] safeAreaInsets:%@, additionalInsets:%@", NSStringFromUIEdgeInsets(safeAreaInsets), NSStringFromUIEdgeInsets(additionalInsets));
|
|
419
419
|
|
|
420
420
|
BOOL statusBarHidden = [UIApplication sharedApplication].keyWindow.windowScene.statusBarManager.statusBarHidden;
|
|
421
421
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
@implementation HBDViewController
|
|
19
19
|
|
|
20
20
|
- (void)dealloc {
|
|
21
|
-
RCTLogInfo(@"[
|
|
21
|
+
RCTLogInfo(@"[Navigation] %s", __FUNCTION__);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
- (BOOL)canPresentViewController {
|
|
51
51
|
UIViewController *presented = self.presentedViewController;
|
|
52
52
|
if (presented && !presented.isBeingDismissed) {
|
|
53
|
-
RCTLogWarn(@"[
|
|
53
|
+
RCTLogWarn(@"[Navigation] Can't present since the scene had present another scene already.");
|
|
54
54
|
return NO;
|
|
55
55
|
}
|
|
56
56
|
return YES;
|
package/lib/Event.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Visibility } from './Route';
|
|
2
|
-
declare function listenStatusBarHeightChange(listener: (statusBarHeight: number) => void): import("react-native").EmitterSubscription;
|
|
3
2
|
declare function listenComponentResult(listener: (sceneId: string, requestCode: number, resultCode: number, resultData: object) => void): import("react-native").EmitterSubscription;
|
|
4
3
|
declare function listenComponentVisibility(listener: (sceneId: string, visibility: Visibility) => void): import("react-native").EmitterSubscription;
|
|
5
4
|
declare function listenBarButtonItemClick(listener: (sceneId: string, action: string) => void): import("react-native").EmitterSubscription;
|
|
@@ -7,7 +6,6 @@ declare function listenTabSwitch(listener: (sceneId: string, from: number, to: n
|
|
|
7
6
|
declare function listenWillSetRoot(willSetRoot: () => void): import("react-native").EmitterSubscription;
|
|
8
7
|
declare function listenDidSetRoot(didSetRoot: (tag: number) => void): import("react-native").EmitterSubscription;
|
|
9
8
|
declare const _default: {
|
|
10
|
-
listenStatusBarHeightChange: typeof listenStatusBarHeightChange;
|
|
11
9
|
listenBarButtonItemClick: typeof listenBarButtonItemClick;
|
|
12
10
|
listenComponentResult: typeof listenComponentResult;
|
|
13
11
|
listenComponentVisibility: typeof listenComponentVisibility;
|
package/lib/Event.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import { NativeModules, NativeEventEmitter } from 'react-native';
|
|
2
|
-
import GardenModule from './GardenModule';
|
|
3
|
-
function listenStatusBarHeightChange(listener) {
|
|
4
|
-
const GardenEventReceiver = new NativeEventEmitter(GardenModule);
|
|
5
|
-
const { EVENT_STATUSBAR_FRAME_CHANGE } = GardenModule.getConstants();
|
|
6
|
-
return GardenEventReceiver.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight }) => {
|
|
7
|
-
listener(statusBarHeight);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
2
|
const HBDEventEmitter = NativeModules.HBDEventEmitter;
|
|
11
3
|
const HBDEventReceiver = new NativeEventEmitter(HBDEventEmitter);
|
|
12
4
|
function listenComponentResult(listener) {
|
|
@@ -61,7 +53,6 @@ function listenDidSetRoot(didSetRoot) {
|
|
|
61
53
|
});
|
|
62
54
|
}
|
|
63
55
|
export default {
|
|
64
|
-
listenStatusBarHeightChange,
|
|
65
56
|
listenBarButtonItemClick,
|
|
66
57
|
listenComponentResult,
|
|
67
58
|
listenComponentVisibility,
|
package/lib/Garden.d.ts
CHANGED
package/lib/Garden.js
CHANGED
package/lib/GardenModule.d.ts
CHANGED
|
@@ -17,4 +17,8 @@ interface GardenModule extends NativeModule {
|
|
|
17
17
|
setMenuInteractive: (sceneId: string, enabled: boolean) => void;
|
|
18
18
|
}
|
|
19
19
|
declare const GardenModule: GardenModule;
|
|
20
|
+
declare function statusBarHeight(): number;
|
|
21
|
+
declare function toolbarHeight(): number;
|
|
22
|
+
declare function topBarHeight(): number;
|
|
23
|
+
export { statusBarHeight, toolbarHeight, topBarHeight };
|
|
20
24
|
export default GardenModule;
|
package/lib/GardenModule.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import { NativeModules } from 'react-native';
|
|
1
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
2
|
const GardenModule = NativeModules.GardenModule;
|
|
3
|
+
const { STATUSBAR_HEIGHT, TOOLBAR_HEIGHT, EVENT_STATUSBAR_FRAME_CHANGE } = GardenModule.getConstants();
|
|
4
|
+
let _statusBarHeight = STATUSBAR_HEIGHT;
|
|
5
|
+
if (Platform.OS === 'ios') {
|
|
6
|
+
const GardenEventReceiver = new NativeEventEmitter(GardenModule);
|
|
7
|
+
GardenEventReceiver.addListener(EVENT_STATUSBAR_FRAME_CHANGE, ({ statusBarHeight: height }) => {
|
|
8
|
+
_statusBarHeight = height;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function statusBarHeight() {
|
|
12
|
+
return _statusBarHeight;
|
|
13
|
+
}
|
|
14
|
+
function toolbarHeight() {
|
|
15
|
+
return TOOLBAR_HEIGHT;
|
|
16
|
+
}
|
|
17
|
+
function topBarHeight() {
|
|
18
|
+
return statusBarHeight() + toolbarHeight();
|
|
19
|
+
}
|
|
20
|
+
export { statusBarHeight, toolbarHeight, topBarHeight };
|
|
3
21
|
export default GardenModule;
|
package/lib/Navigation.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ export declare class Navigation implements Navigation {
|
|
|
31
31
|
startRegisterComponent(hoc?: HOC): void;
|
|
32
32
|
endRegisterComponent(): void;
|
|
33
33
|
registerComponent(appKey: string, getComponentFunc: ComponentProvider, routeConfig?: RouteConfig): void;
|
|
34
|
+
private _routeConfigs;
|
|
35
|
+
private registerRoute;
|
|
36
|
+
routeConfigs(): Map<string, RouteConfig>;
|
|
34
37
|
setNavigationComponentWrap(wrap: (moduleName: string) => HOC): void;
|
|
35
38
|
addGlobalVisibilityEventListener(listener: GlobalVisibilityEventListener): NavigationSubscription;
|
|
36
39
|
addVisibilityEventListener(sceneId: string, listener: VisibilityEventListener): NavigationSubscription;
|
|
@@ -40,7 +43,7 @@ export declare class Navigation implements Navigation {
|
|
|
40
43
|
setResult: <T extends ResultType>(sceneId: string, resultCode: number, data?: T) => void;
|
|
41
44
|
result<T>(sceneId: string, resultCode: number): Promise<[number, T]>;
|
|
42
45
|
unmount(sceneId: string): void;
|
|
43
|
-
setRoot(layout: BuildInLayout | Layout, sticky?: boolean): Promise<
|
|
46
|
+
setRoot(layout: BuildInLayout | Layout, sticky?: boolean): Promise<boolean>;
|
|
44
47
|
setRootLayoutUpdateListener(willSetRoot?: () => void, didSetRoot?: () => void): void;
|
|
45
48
|
currentTab(sceneId: string): Promise<number>;
|
|
46
49
|
findSceneIdByModuleName(moduleName: string): Promise<string | null>;
|
|
@@ -48,9 +51,6 @@ export declare class Navigation implements Navigation {
|
|
|
48
51
|
signalFirstRenderComplete(sceneId: string): void;
|
|
49
52
|
currentRoute(): Promise<Route>;
|
|
50
53
|
routeGraph(): Promise<RouteGraph[]>;
|
|
51
|
-
private _routeConfigs;
|
|
52
|
-
private registerRoute;
|
|
53
|
-
routeConfigs(): Map<string, RouteConfig>;
|
|
54
54
|
setDefaultOptions(options: DefaultOptions): void;
|
|
55
55
|
setLeftBarButtonItem(sceneId: string, buttonItem: Nullable<BarButtonItem> | null): void;
|
|
56
56
|
setRightBarButtonItem(sceneId: string, buttonItem: Nullable<BarButtonItem> | null): void;
|
|
@@ -61,12 +61,6 @@ export declare class Navigation implements Navigation {
|
|
|
61
61
|
updateTabBar(sceneId: string, options: TabBarStyle): void;
|
|
62
62
|
setTabItem(sceneId: string, item: TabItemInfo | TabItemInfo[]): void;
|
|
63
63
|
setMenuInteractive(sceneId: string, enabled: boolean): void;
|
|
64
|
-
private _statusBarHeight;
|
|
65
|
-
private _toolbarHeight;
|
|
66
|
-
private handleStatusBarHeightChange;
|
|
67
|
-
statusBarHeight(): number;
|
|
68
|
-
toolbarHeight(): number;
|
|
69
|
-
topBarHeight(): number;
|
|
70
64
|
setBarButtonClickEventListener(listener: BarButtonClickEventListener): void;
|
|
71
65
|
private bindBarButtonClickEvent;
|
|
72
66
|
}
|
package/lib/Navigation.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppRegistry
|
|
1
|
+
import { AppRegistry } from 'react-native';
|
|
2
2
|
import BarButtonEventHandler from './handler/BarButtonEventHandler';
|
|
3
3
|
import LayoutCommandHandler from './handler/LayoutCommandHandler';
|
|
4
4
|
import DispatchCommandHandler from './handler/DispatchCommandHandler';
|
|
@@ -7,7 +7,6 @@ import VisibilityEventHandler from './handler/VisibilityEventHandler';
|
|
|
7
7
|
import Event from './Event';
|
|
8
8
|
import GardenModule from './GardenModule';
|
|
9
9
|
import NavigationModule from './NavigationModule';
|
|
10
|
-
const { STATUSBAR_HEIGHT, TOOLBAR_HEIGHT } = GardenModule.getConstants();
|
|
11
10
|
export const { RESULT_CANCEL, RESULT_OK } = NavigationModule.getConstants();
|
|
12
11
|
export class Navigation {
|
|
13
12
|
dispatchHandler = new DispatchCommandHandler();
|
|
@@ -16,7 +15,6 @@ export class Navigation {
|
|
|
16
15
|
layoutHandler = new LayoutCommandHandler();
|
|
17
16
|
visibilityHandler = new VisibilityEventHandler();
|
|
18
17
|
constructor() {
|
|
19
|
-
this.handleStatusBarHeightChange();
|
|
20
18
|
this.handleTabSwitch();
|
|
21
19
|
this.layoutHandler.handleRootLayoutChange();
|
|
22
20
|
this.visibilityHandler.handleComponentVisibility();
|
|
@@ -52,6 +50,13 @@ export class Navigation {
|
|
|
52
50
|
let RootComponent = this.wrap(appKey)(WrappedComponent);
|
|
53
51
|
AppRegistry.registerComponent(appKey, () => RootComponent);
|
|
54
52
|
}
|
|
53
|
+
_routeConfigs = new Map();
|
|
54
|
+
registerRoute(moduleName, route) {
|
|
55
|
+
this._routeConfigs.set(moduleName, route);
|
|
56
|
+
}
|
|
57
|
+
routeConfigs() {
|
|
58
|
+
return this._routeConfigs;
|
|
59
|
+
}
|
|
55
60
|
setNavigationComponentWrap(wrap) {
|
|
56
61
|
this.wrap = wrap;
|
|
57
62
|
}
|
|
@@ -110,13 +115,6 @@ export class Navigation {
|
|
|
110
115
|
routeGraph() {
|
|
111
116
|
return NavigationModule.routeGraph();
|
|
112
117
|
}
|
|
113
|
-
_routeConfigs = new Map();
|
|
114
|
-
registerRoute(moduleName, route) {
|
|
115
|
-
this._routeConfigs.set(moduleName, route);
|
|
116
|
-
}
|
|
117
|
-
routeConfigs() {
|
|
118
|
-
return this._routeConfigs;
|
|
119
|
-
}
|
|
120
118
|
setDefaultOptions(options) {
|
|
121
119
|
GardenModule.setStyle(options);
|
|
122
120
|
}
|
|
@@ -154,24 +152,6 @@ export class Navigation {
|
|
|
154
152
|
setMenuInteractive(sceneId, enabled) {
|
|
155
153
|
GardenModule.setMenuInteractive(sceneId, enabled);
|
|
156
154
|
}
|
|
157
|
-
_statusBarHeight = STATUSBAR_HEIGHT;
|
|
158
|
-
_toolbarHeight = TOOLBAR_HEIGHT;
|
|
159
|
-
handleStatusBarHeightChange() {
|
|
160
|
-
if (Platform.OS === 'ios') {
|
|
161
|
-
Event.listenStatusBarHeightChange(statusBarHeight => {
|
|
162
|
-
this._statusBarHeight = statusBarHeight;
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
statusBarHeight() {
|
|
167
|
-
return this._statusBarHeight;
|
|
168
|
-
}
|
|
169
|
-
toolbarHeight() {
|
|
170
|
-
return this._toolbarHeight;
|
|
171
|
-
}
|
|
172
|
-
topBarHeight() {
|
|
173
|
-
return this.statusBarHeight() + this.toolbarHeight();
|
|
174
|
-
}
|
|
175
155
|
setBarButtonClickEventListener(listener) {
|
|
176
156
|
this.buttonHandler.setBarButtonClickEventListener(listener);
|
|
177
157
|
}
|
|
@@ -8,7 +8,7 @@ declare function endRegisterReactComponent(): void;
|
|
|
8
8
|
declare function registerReactComponent(appKey: string, options: object): void;
|
|
9
9
|
declare function signalFirstRenderComplete(sceneId: string): void;
|
|
10
10
|
declare function setResult(sceneId: string, resultCode: number, data: object | null): void;
|
|
11
|
-
declare function setRoot(layout: object, sticky: boolean
|
|
11
|
+
declare function setRoot(layout: object, sticky: boolean): Promise<boolean>;
|
|
12
12
|
declare function dispatch(sceneId: string, action: string, params: object): Promise<boolean>;
|
|
13
13
|
declare function currentTab(sceneId: string): Promise<number>;
|
|
14
14
|
declare function isStackRoot(sceneId: string): Promise<boolean>;
|
package/lib/NavigationModule.js
CHANGED
|
@@ -18,8 +18,12 @@ function signalFirstRenderComplete(sceneId) {
|
|
|
18
18
|
function setResult(sceneId, resultCode, data) {
|
|
19
19
|
NavigationModule.setResult(sceneId, resultCode, data);
|
|
20
20
|
}
|
|
21
|
-
function setRoot(layout, sticky
|
|
22
|
-
|
|
21
|
+
function setRoot(layout, sticky) {
|
|
22
|
+
return new Promise(resolve => {
|
|
23
|
+
NavigationModule.setRoot(layout, sticky, (_, success) => {
|
|
24
|
+
resolve(success);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
function dispatch(sceneId, action, params) {
|
|
25
29
|
return new Promise(resolve => {
|
package/lib/Navigator.d.ts
CHANGED
|
@@ -18,13 +18,13 @@ export declare class Navigator implements Navigator {
|
|
|
18
18
|
sceneId: string;
|
|
19
19
|
moduleName?: string | undefined;
|
|
20
20
|
static of(sceneId: string): Navigator;
|
|
21
|
+
static current(): Promise<Navigator>;
|
|
21
22
|
/**
|
|
22
|
-
* @deprecated
|
|
23
|
+
* @deprecated Garden is deprecated, use Navigation.findSceneIdByModuleName() instead.
|
|
23
24
|
* @param moduleName
|
|
24
25
|
* @returns
|
|
25
26
|
*/
|
|
26
27
|
static find(moduleName: string): Promise<Navigator | undefined>;
|
|
27
|
-
static current(): Promise<Navigator>;
|
|
28
28
|
/**
|
|
29
29
|
* @deprecated Use Navigation.currentRoute() instead
|
|
30
30
|
* @returns
|
|
@@ -62,6 +62,9 @@ export declare class Navigator implements Navigator {
|
|
|
62
62
|
static setInterceptor(interceptor: NavigationInterceptor): void;
|
|
63
63
|
constructor(sceneId: string, moduleName?: string | undefined);
|
|
64
64
|
private _garden?;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Garden is deprecated, Use Navigation related methods instead.
|
|
67
|
+
*/
|
|
65
68
|
get garden(): Garden;
|
|
66
69
|
visibility: Visibility;
|
|
67
70
|
readonly state: NavigationState;
|
package/lib/Navigator.js
CHANGED
|
@@ -25,8 +25,12 @@ export class Navigator {
|
|
|
25
25
|
}
|
|
26
26
|
return navigator;
|
|
27
27
|
}
|
|
28
|
+
static async current() {
|
|
29
|
+
const route = await Navigation.currentRoute();
|
|
30
|
+
return Navigator.of(route.sceneId);
|
|
31
|
+
}
|
|
28
32
|
/**
|
|
29
|
-
* @deprecated
|
|
33
|
+
* @deprecated Garden is deprecated, use Navigation.findSceneIdByModuleName() instead.
|
|
30
34
|
* @param moduleName
|
|
31
35
|
* @returns
|
|
32
36
|
*/
|
|
@@ -36,10 +40,6 @@ export class Navigator {
|
|
|
36
40
|
return Navigator.of(sceneId);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
|
-
static async current() {
|
|
40
|
-
const route = await Navigator.currentRoute();
|
|
41
|
-
return Navigator.of(route.sceneId);
|
|
42
|
-
}
|
|
43
43
|
/**
|
|
44
44
|
* @deprecated Use Navigation.currentRoute() instead
|
|
45
45
|
* @returns
|
|
@@ -92,6 +92,9 @@ export class Navigator {
|
|
|
92
92
|
this.moduleName = moduleName;
|
|
93
93
|
}
|
|
94
94
|
_garden;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated Garden is deprecated, Use Navigation related methods instead.
|
|
97
|
+
*/
|
|
95
98
|
get garden() {
|
|
96
99
|
if (!this._garden) {
|
|
97
100
|
this._garden = new Garden(this.sceneId);
|
|
@@ -110,24 +113,35 @@ export class Navigator {
|
|
|
110
113
|
Navigation.unmount(this.sceneId);
|
|
111
114
|
};
|
|
112
115
|
push = async (moduleName, props = {}, options = {}) => {
|
|
113
|
-
const success = await Navigation.dispatch(this.sceneId, 'push', {
|
|
116
|
+
const success = await Navigation.dispatch(this.sceneId, 'push', {
|
|
117
|
+
moduleName,
|
|
118
|
+
from: this.moduleName,
|
|
119
|
+
to: moduleName,
|
|
120
|
+
props,
|
|
121
|
+
options,
|
|
122
|
+
});
|
|
114
123
|
if (!success) {
|
|
115
124
|
return [RESULT_CANCEL, null];
|
|
116
125
|
}
|
|
117
126
|
return await Navigation.result(this.sceneId, 0);
|
|
118
127
|
};
|
|
119
128
|
pushLayout = async (layout) => {
|
|
120
|
-
const success = await Navigation.dispatch(this.sceneId, 'pushLayout', {
|
|
129
|
+
const success = await Navigation.dispatch(this.sceneId, 'pushLayout', {
|
|
130
|
+
from: this.moduleName,
|
|
131
|
+
layout,
|
|
132
|
+
});
|
|
121
133
|
if (!success) {
|
|
122
134
|
return [RESULT_CANCEL, null];
|
|
123
135
|
}
|
|
124
136
|
return await Navigation.result(this.sceneId, 0);
|
|
125
137
|
};
|
|
126
|
-
pop = () => Navigation.dispatch(this.sceneId, 'pop');
|
|
127
|
-
popTo = (moduleName, inclusive = false) => Navigation.dispatch(this.sceneId, 'popTo', { moduleName, inclusive });
|
|
128
|
-
popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot');
|
|
138
|
+
pop = () => Navigation.dispatch(this.sceneId, 'pop', { from: this.moduleName });
|
|
139
|
+
popTo = (moduleName, inclusive = false) => Navigation.dispatch(this.sceneId, 'popTo', { moduleName, inclusive, from: this.moduleName });
|
|
140
|
+
popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot', { from: this.moduleName });
|
|
129
141
|
redirectTo = (moduleName, props = {}, options = {}) => Navigation.dispatch(this.sceneId, 'redirectTo', {
|
|
130
142
|
moduleName,
|
|
143
|
+
from: this.moduleName,
|
|
144
|
+
to: moduleName,
|
|
131
145
|
props,
|
|
132
146
|
options,
|
|
133
147
|
});
|
|
@@ -135,6 +149,8 @@ export class Navigator {
|
|
|
135
149
|
const requestCode = --tagGenerator;
|
|
136
150
|
const success = await Navigation.dispatch(this.sceneId, 'present', {
|
|
137
151
|
moduleName,
|
|
152
|
+
from: this.moduleName,
|
|
153
|
+
to: moduleName,
|
|
138
154
|
props,
|
|
139
155
|
options,
|
|
140
156
|
requestCode,
|
|
@@ -148,6 +164,7 @@ export class Navigator {
|
|
|
148
164
|
const requestCode = --tagGenerator;
|
|
149
165
|
const success = await Navigation.dispatch(this.sceneId, 'presentLayout', {
|
|
150
166
|
layout,
|
|
167
|
+
from: this.moduleName,
|
|
151
168
|
requestCode,
|
|
152
169
|
});
|
|
153
170
|
if (!success) {
|
|
@@ -155,11 +172,13 @@ export class Navigator {
|
|
|
155
172
|
}
|
|
156
173
|
return await Navigation.result(this.sceneId, requestCode);
|
|
157
174
|
};
|
|
158
|
-
dismiss = () => Navigation.dispatch(this.sceneId, 'dismiss');
|
|
175
|
+
dismiss = () => Navigation.dispatch(this.sceneId, 'dismiss', { from: this.moduleName });
|
|
159
176
|
showModal = async (moduleName, props = {}, options = {}) => {
|
|
160
177
|
const requestCode = --tagGenerator;
|
|
161
178
|
const success = await Navigation.dispatch(this.sceneId, 'showModal', {
|
|
162
179
|
moduleName,
|
|
180
|
+
from: this.moduleName,
|
|
181
|
+
to: moduleName,
|
|
163
182
|
props,
|
|
164
183
|
options,
|
|
165
184
|
requestCode,
|
|
@@ -172,6 +191,7 @@ export class Navigator {
|
|
|
172
191
|
showModalLayout = async (layout) => {
|
|
173
192
|
const requestCode = --tagGenerator;
|
|
174
193
|
const success = await Navigation.dispatch(this.sceneId, 'showModalLayout', {
|
|
194
|
+
from: this.moduleName,
|
|
175
195
|
layout,
|
|
176
196
|
requestCode,
|
|
177
197
|
});
|
|
@@ -180,15 +200,15 @@ export class Navigator {
|
|
|
180
200
|
}
|
|
181
201
|
return await Navigation.result(this.sceneId, requestCode);
|
|
182
202
|
};
|
|
183
|
-
hideModal = () => Navigation.dispatch(this.sceneId, 'hideModal');
|
|
203
|
+
hideModal = () => Navigation.dispatch(this.sceneId, 'hideModal', { from: this.moduleName });
|
|
184
204
|
setResult = (resultCode, data = null) => Navigation.setResult(this.sceneId, resultCode, data);
|
|
185
205
|
switchTab = async (index, popToRoot = false) => {
|
|
186
206
|
const from = await Navigation.currentTab(this.sceneId);
|
|
187
207
|
return Navigation.dispatch(this.sceneId, 'switchTab', { from, to: index, popToRoot });
|
|
188
208
|
};
|
|
189
|
-
toggleMenu = () => Navigation.dispatch(this.sceneId, 'toggleMenu');
|
|
190
|
-
openMenu = () => Navigation.dispatch(this.sceneId, 'openMenu');
|
|
191
|
-
closeMenu = () => Navigation.dispatch(this.sceneId, 'closeMenu');
|
|
209
|
+
toggleMenu = () => Navigation.dispatch(this.sceneId, 'toggleMenu', { from: this.moduleName });
|
|
210
|
+
openMenu = () => Navigation.dispatch(this.sceneId, 'openMenu', { from: this.moduleName });
|
|
211
|
+
closeMenu = () => Navigation.dispatch(this.sceneId, 'closeMenu', { from: this.moduleName });
|
|
192
212
|
isStackRoot = () => Navigation.isStackRoot(this.sceneId);
|
|
193
213
|
signalFirstRenderComplete = () => Navigation.signalFirstRenderComplete(this.sceneId);
|
|
194
214
|
}
|
package/lib/ReactRegistry.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ComponentProvider } from 'react-native';
|
|
2
2
|
import type { RouteConfig } from './Route';
|
|
3
3
|
import { HOC } from './Navigation';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use Navigation instead. import Navigation from 'hybrid-navigation'
|
|
6
|
+
*/
|
|
4
7
|
export declare class ReactRegistry {
|
|
5
8
|
/**
|
|
6
9
|
* @deprecated Use Navigation.startRegisterComponent() instead.
|
package/lib/ReactRegistry.js
CHANGED
package/lib/Route.d.ts
CHANGED
|
@@ -54,13 +54,6 @@ export interface RouteConfig {
|
|
|
54
54
|
dependency?: string;
|
|
55
55
|
mode?: RouteMode;
|
|
56
56
|
}
|
|
57
|
-
export interface RouteInfo {
|
|
58
|
-
moduleName: string;
|
|
59
|
-
dependencies: string[];
|
|
60
|
-
mode: RouteMode;
|
|
61
|
-
props: object;
|
|
62
|
-
options: object;
|
|
63
|
-
}
|
|
64
57
|
export interface RouteData {
|
|
65
58
|
moduleName: string;
|
|
66
59
|
regexp?: RegExp;
|
|
@@ -68,7 +61,19 @@ export interface RouteData {
|
|
|
68
61
|
dependency?: string;
|
|
69
62
|
mode: RouteMode;
|
|
70
63
|
}
|
|
64
|
+
export interface RouteInfo {
|
|
65
|
+
moduleName: string;
|
|
66
|
+
mode: RouteMode;
|
|
67
|
+
dependencies: string[];
|
|
68
|
+
props: object;
|
|
69
|
+
options: object;
|
|
70
|
+
}
|
|
71
71
|
export interface RouteHandler {
|
|
72
|
-
|
|
72
|
+
/**
|
|
73
|
+
* @param graph - current RouteGraph to process
|
|
74
|
+
* @param target - route may add to the graph
|
|
75
|
+
* @reurns [boolean, RouteGraph] - if the route is handled, return true and childGraph for next Handler to process, [false, graph] otherwise
|
|
76
|
+
*/
|
|
77
|
+
process: (graph: RouteGraph, target: RouteInfo) => Promise<[boolean, RouteGraph | null]>;
|
|
73
78
|
}
|
|
74
79
|
export declare type RouteInterceptor = (path: string) => boolean | Promise<boolean>;
|