hybrid-navigation 5.4.0 → 5.5.0
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/HybridNavigation.podspec +1 -0
- package/android/proguard-rules.pro +5 -0
- package/android/src/main/java/com/navigation/androidx/AppUtils.java +8 -1
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +115 -36
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +153 -100
- package/android/src/main/java/com/navigation/androidx/DefaultTabBarProvider.java +1 -1
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +5 -1
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +95 -39
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +195 -29
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +225 -27
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +33 -9
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +5 -107
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +37 -10
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +82 -19
- package/android/src/main/java/com/navigation/androidx/Style.java +8 -4
- package/android/src/main/java/com/navigation/androidx/SystemUI.java +17 -5
- package/android/src/main/java/com/navigation/androidx/TabBar.java +69 -29
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +48 -11
- package/android/src/main/java/com/navigation/androidx/TabBarItem.java +1 -2
- package/android/src/main/java/com/navigation/androidx/TabView.java +20 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/Constants.java +1 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +19 -15
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +10 -48
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +22 -23
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +54 -22
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +4 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +35 -64
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationCommandQueue.java +185 -121
- package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +21 -5
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigatorRegistry.java +27 -30
- package/android/src/main/java/com/reactnative/hybridnavigation/OrientationCoordinator.java +41 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/Parameters.java +55 -154
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +30 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +12 -37
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +31 -190
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +115 -71
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +27 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactSurfaceCleanup.java +50 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +34 -4
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +39 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/RemovalPlan.java +76 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/SceneLifecycleStateMachine.java +72 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +19 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +11 -5
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +217 -99
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +122 -59
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +87 -24
- package/dist/DeepLink.d.ts +3 -1
- package/dist/DeepLink.js +39 -19
- package/dist/NativeNavigation.d.ts +8 -5
- package/dist/Navigation.d.ts +9 -24
- package/dist/Navigation.js +32 -97
- package/dist/NavigationComponentWrap.d.ts +1 -2
- package/dist/NavigationComponentWrap.js +0 -15
- package/dist/Navigator.d.ts +7 -5
- package/dist/Navigator.js +38 -33
- package/dist/Options.d.ts +1 -7
- package/dist/Options.js +1 -2
- package/dist/Route.d.ts +24 -12
- package/dist/handler/DispatchCommandHandler.d.ts +4 -5
- package/dist/handler/DispatchCommandHandler.js +37 -16
- package/dist/handler/LayoutCommandHandler.js +18 -3
- package/dist/handler/LeaveGuardHandler.d.ts +12 -8
- package/dist/handler/LeaveGuardHandler.js +174 -281
- package/dist/handler/LifecycleEventHandler.d.ts +7 -4
- package/dist/handler/LifecycleEventHandler.js +119 -32
- package/dist/handler/ResultEventHandler.d.ts +2 -2
- package/dist/handler/ResultEventHandler.js +72 -36
- package/dist/handler/SceneExitHandler.d.ts +6 -0
- package/dist/handler/SceneExitHandler.js +48 -8
- package/dist/hooks.d.ts +1 -0
- package/dist/hooks.js +39 -23
- package/dist/index.d.ts +9 -8
- package/dist/index.js +5 -8
- package/dist/routeGraph.d.ts +5 -0
- package/dist/routeGraph.js +47 -0
- package/dist/router/drawer.d.ts +2 -2
- package/dist/router/drawer.js +19 -9
- package/dist/router/helpers.d.ts +17 -0
- package/dist/router/helpers.js +90 -0
- package/dist/router/index.d.ts +2 -2
- package/dist/router/index.js +169 -97
- package/dist/router/screen.d.ts +2 -2
- package/dist/router/screen.js +16 -7
- package/dist/router/stack.d.ts +2 -2
- package/dist/router/stack.js +24 -49
- package/dist/router/tabs.js +5 -1
- package/dist/store.d.ts +2 -0
- package/dist/store.js +4 -0
- package/ios/HBDGlobalStyle.h +0 -1
- package/ios/HBDGlobalStyle.mm +27 -39
- package/ios/HBDUtils.h +0 -2
- package/ios/HBDUtils.mm +81 -41
- package/ios/Navigator/HBDDrawerNavigator.mm +31 -26
- package/ios/Navigator/HBDNavigatorRegistry.mm +23 -26
- package/ios/Navigator/HBDScreenNavigator.mm +240 -137
- package/ios/Navigator/HBDStackNavigator.mm +147 -97
- package/ios/Navigator/HBDTabNavigator.mm +99 -46
- package/ios/React/HBDNativeEvent.mm +38 -5
- package/ios/React/HBDNativeNavigation.mm +49 -51
- package/ios/React/HBDNavigationCommandQueue.h +55 -0
- package/ios/React/HBDNavigationCommandQueue.mm +341 -0
- package/ios/React/HBDNavigator.h +20 -0
- package/ios/React/HBDOrientationCoordinator.mm +26 -3
- package/ios/React/HBDReactBridgeManager.h +18 -6
- package/ios/React/HBDReactBridgeManager.mm +536 -315
- package/ios/React/HBDSceneLifecycleStateMachine.h +2 -0
- package/ios/React/HBDSceneLifecycleStateMachine.mm +18 -0
- package/ios/View/HBDRootView.h +1 -0
- package/ios/View/HBDRootView.mm +112 -4
- package/ios/View/UIImage+WithBadge.mm +9 -7
- package/ios/ViewController/HBDDrawerController.h +10 -0
- package/ios/ViewController/HBDDrawerController.mm +103 -71
- package/ios/ViewController/HBDNavigationController.mm +166 -58
- package/ios/ViewController/HBDReactViewController.h +0 -4
- package/ios/ViewController/HBDReactViewController.mm +13 -110
- package/ios/ViewController/HBDTabBarController.mm +67 -33
- package/ios/ViewController/HBDViewController.h +6 -0
- package/ios/ViewController/HBDViewController.mm +94 -37
- package/ios/ViewController/UINavigationController+HBD.h +2 -2
- package/ios/ViewController/UINavigationController+HBD.mm +13 -13
- package/ios/ViewController/UIViewController+HBD.h +23 -1
- package/ios/ViewController/UIViewController+HBD.mm +298 -40
- package/package.json +1 -1
- package/src/DeepLink.ts +39 -19
- package/src/NativeNavigation.ts +17 -5
- package/src/Navigation.ts +49 -170
- package/src/NavigationComponentWrap.tsx +1 -16
- package/src/Navigator.ts +50 -52
- package/src/Options.ts +4 -10
- package/src/Route.ts +37 -19
- package/src/handler/DispatchCommandHandler.ts +42 -20
- package/src/handler/LayoutCommandHandler.ts +15 -3
- package/src/handler/LeaveGuardHandler.ts +224 -329
- package/src/handler/LifecycleEventHandler.ts +131 -37
- package/src/handler/ResultEventHandler.ts +71 -37
- package/src/handler/SceneExitHandler.ts +60 -9
- package/src/hooks.ts +54 -26
- package/src/index.ts +77 -8
- package/src/routeGraph.ts +50 -0
- package/src/router/drawer.ts +21 -10
- package/src/router/helpers.ts +113 -0
- package/src/router/index.ts +187 -112
- package/src/router/screen.ts +35 -8
- package/src/router/stack.ts +40 -53
- package/src/router/tabs.ts +5 -1
- package/src/store.ts +5 -0
- package/dist/sceneCoverage.d.ts +0 -2
- package/dist/sceneCoverage.js +0 -25
- package/src/sceneCoverage.ts +0 -30
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#import "HBDGlobalStyle.h"
|
|
4
4
|
#import "HBDNavigationController.h"
|
|
5
|
+
#import "HBDOrientationCoordinator.h"
|
|
5
6
|
#import "HBDReactBridgeManager.h"
|
|
6
7
|
#import "HBDReactViewController.h"
|
|
7
8
|
#import "HBDTabBarController.h"
|
|
@@ -10,6 +11,16 @@
|
|
|
10
11
|
|
|
11
12
|
#import <React/RCTLog.h>
|
|
12
13
|
|
|
14
|
+
static const void *kHBDSuppressDismissResultKey = &kHBDSuppressDismissResultKey;
|
|
15
|
+
|
|
16
|
+
static BOOL HBDIsOverContextModal(UIViewController * _Nullable vc) {
|
|
17
|
+
if (!vc || [vc isKindOfClass:[UIAlertController class]]) {
|
|
18
|
+
return NO;
|
|
19
|
+
}
|
|
20
|
+
UIModalPresentationStyle style = vc.modalPresentationStyle;
|
|
21
|
+
return style == UIModalPresentationOverFullScreen || style == UIModalPresentationOverCurrentContext;
|
|
22
|
+
}
|
|
23
|
+
|
|
13
24
|
static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
14
25
|
if (!vc) {
|
|
15
26
|
return NO;
|
|
@@ -20,7 +31,7 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
20
31
|
[vc isKindOfClass:[HBDDrawerController class]]) {
|
|
21
32
|
return YES;
|
|
22
33
|
}
|
|
23
|
-
return
|
|
34
|
+
return [[HBDReactBridgeManager get] hasRegisteredLayoutForViewController:vc];
|
|
24
35
|
}
|
|
25
36
|
|
|
26
37
|
@implementation UIViewController (HBD)
|
|
@@ -35,11 +46,110 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
35
46
|
}
|
|
36
47
|
|
|
37
48
|
- (void)hbd_presentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^)(void))completion {
|
|
38
|
-
|
|
49
|
+
BOOL isManaged = HBDIsManagedViewController(viewController);
|
|
50
|
+
if ((isManaged || viewController.hbd_requestCode != 0) &&
|
|
39
51
|
viewController.hbd_presentingSceneId.length == 0) {
|
|
40
52
|
viewController.hbd_presentingSceneId = self.hbd_sceneId;
|
|
41
53
|
}
|
|
54
|
+
HBDViewController *covered = nil;
|
|
55
|
+
if (isManaged && HBDIsOverContextModal(viewController) && self.viewIfLoaded.window != nil && self.presentedViewController == nil) {
|
|
56
|
+
covered = [[HBDReactBridgeManager get] primaryViewControllerInHierarchy:self];
|
|
57
|
+
if (covered) {
|
|
58
|
+
[covered.lifecycleStateMachine markCovered];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
42
61
|
[self hbd_presentViewController:viewController animated:animated completion:completion];
|
|
62
|
+
if (covered && viewController.presentingViewController == nil) {
|
|
63
|
+
[covered.lifecycleStateMachine syncVisibility];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (UIViewController *)hbd_modalHostViewController {
|
|
68
|
+
UIViewController *host = self;
|
|
69
|
+
while (host.parentViewController != nil) {
|
|
70
|
+
host = host.parentViewController;
|
|
71
|
+
}
|
|
72
|
+
return host;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
- (BOOL)hbd_isCoveredByPresentation {
|
|
76
|
+
UIViewController *host = [self hbd_modalHostViewController];
|
|
77
|
+
UIViewController *presented = host.presentedViewController;
|
|
78
|
+
return presented != nil && !presented.isBeingDismissed && ![presented isKindOfClass:[UIAlertController class]];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (BOOL)hbd_isCoveredInContainers {
|
|
82
|
+
UIViewController *child = self;
|
|
83
|
+
UIViewController *parent = child.parentViewController;
|
|
84
|
+
while (parent != nil) {
|
|
85
|
+
if ([parent isKindOfClass:[UINavigationController class]]) {
|
|
86
|
+
UINavigationController *nav = (UINavigationController *)parent;
|
|
87
|
+
if (nav.topViewController != nil && nav.topViewController != child) {
|
|
88
|
+
return YES;
|
|
89
|
+
}
|
|
90
|
+
} else if ([parent isKindOfClass:[UITabBarController class]]) {
|
|
91
|
+
UITabBarController *tabs = (UITabBarController *)parent;
|
|
92
|
+
if (tabs.selectedViewController != nil && tabs.selectedViewController != child) {
|
|
93
|
+
return YES;
|
|
94
|
+
}
|
|
95
|
+
} else if ([parent isKindOfClass:[HBDDrawerController class]]) {
|
|
96
|
+
HBDDrawerController *drawer = (HBDDrawerController *)parent;
|
|
97
|
+
if (drawer.isMenuOpened) {
|
|
98
|
+
if (child == drawer.contentController) {
|
|
99
|
+
return YES;
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
if (child == drawer.menuController) {
|
|
103
|
+
return YES;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
child = parent;
|
|
108
|
+
parent = child.parentViewController;
|
|
109
|
+
}
|
|
110
|
+
return NO;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (void)hbd_collectLeafSceneIdsInto:(NSMutableArray<NSString *> *)out visited:(NSMutableSet<UIViewController *> *)visited {
|
|
114
|
+
if ([visited containsObject:self]) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
[visited addObject:self];
|
|
118
|
+
if ([self isKindOfClass:[HBDViewController class]]) {
|
|
119
|
+
[out addObject:self.hbd_sceneId];
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if ([self isKindOfClass:[HBDDrawerController class]]) {
|
|
123
|
+
HBDDrawerController *drawer = (HBDDrawerController *)self;
|
|
124
|
+
[drawer.menuController hbd_collectLeafSceneIdsInto:out visited:visited];
|
|
125
|
+
[drawer.contentController hbd_collectLeafSceneIdsInto:out visited:visited];
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
NSArray<UIViewController *> *children = self.childViewControllers;
|
|
129
|
+
for (NSInteger i = (NSInteger)children.count - 1; i >= 0; i--) {
|
|
130
|
+
[children[(NSUInteger)i] hbd_collectLeafSceneIdsInto:out visited:visited];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
- (NSArray<NSString *> *)hbd_collectLeafSceneIds {
|
|
135
|
+
NSMutableArray<NSString *> *result = [NSMutableArray array];
|
|
136
|
+
[self hbd_collectLeafSceneIdsInto:result visited:[NSMutableSet set]];
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (BOOL)hbd_isCoveredByOverContextModal {
|
|
141
|
+
UIViewController *current = self;
|
|
142
|
+
while (current != nil) {
|
|
143
|
+
UIViewController *presented = current.presentedViewController;
|
|
144
|
+
if (presented &&
|
|
145
|
+
!presented.isBeingDismissed &&
|
|
146
|
+
HBDIsManagedViewController(presented) &&
|
|
147
|
+
HBDIsOverContextModal(presented)) {
|
|
148
|
+
return YES;
|
|
149
|
+
}
|
|
150
|
+
current = current.parentViewController;
|
|
151
|
+
}
|
|
152
|
+
return NO;
|
|
43
153
|
}
|
|
44
154
|
|
|
45
155
|
- (BOOL)hbd_canPresentViewController {
|
|
@@ -56,6 +166,29 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
56
166
|
return YES;
|
|
57
167
|
}
|
|
58
168
|
|
|
169
|
+
+ (UIViewController *)hbd_resolveResultCarrier:(UIViewController *)carrier {
|
|
170
|
+
if (!carrier || carrier.hbd_hasLocalResult) {
|
|
171
|
+
return carrier;
|
|
172
|
+
}
|
|
173
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewControllerInHierarchy:carrier];
|
|
174
|
+
if (primary && primary != carrier && primary.hbd_hasLocalResult) {
|
|
175
|
+
return primary;
|
|
176
|
+
}
|
|
177
|
+
return carrier;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)hbd_dismissForRootResetAnimated:(BOOL)animated completion:(void (^)(void))completion {
|
|
181
|
+
objc_setAssociatedObject(self, kHBDSuppressDismissResultKey, @YES, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
182
|
+
[self dismissViewControllerAnimated:animated completion:completion];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
+ (void)hbd_markPresentedChainDestroyed:(NSArray<UIViewController *> *)presentedChain {
|
|
186
|
+
NSMutableSet<UIViewController *> *visited = [NSMutableSet set];
|
|
187
|
+
for (NSInteger i = (NSInteger)presentedChain.count - 1; i >= 0; i--) {
|
|
188
|
+
[presentedChain[(NSUInteger)i] hbd_markDestroyedRecursivelyWithVisited:visited];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
59
192
|
- (void)hbd_dismissViewControllerAnimated:(BOOL)animated completion:(void (^)(void))completion {
|
|
60
193
|
UIViewController *presented = self.presentedViewController;
|
|
61
194
|
UIViewController *presenting = presented.presentingViewController;
|
|
@@ -64,46 +197,99 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
64
197
|
presented = presenting.presentedViewController;
|
|
65
198
|
}
|
|
66
199
|
|
|
67
|
-
|
|
200
|
+
NSMutableArray<UIViewController *> *presentedChain = [NSMutableArray array];
|
|
201
|
+
UIViewController *cursor = presented;
|
|
202
|
+
while (cursor != nil && ![presentedChain containsObject:cursor]) {
|
|
203
|
+
[presentedChain addObject:cursor];
|
|
204
|
+
cursor = cursor.presentedViewController;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
BOOL suppressResult = [objc_getAssociatedObject(self, kHBDSuppressDismissResultKey) boolValue] ||
|
|
208
|
+
(presented != nil && [objc_getAssociatedObject(presented, kHBDSuppressDismissResultKey) boolValue]);
|
|
209
|
+
if (suppressResult) {
|
|
210
|
+
objc_setAssociatedObject(self, kHBDSuppressDismissResultKey, nil, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
211
|
+
if (presented != nil) {
|
|
212
|
+
objc_setAssociatedObject(presented, kHBDSuppressDismissResultKey, nil, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
BOOL shouldHandleDismiss = presented != nil &&
|
|
68
217
|
presenting != nil &&
|
|
69
218
|
![presented isKindOfClass:[UIAlertController class]] &&
|
|
70
219
|
(HBDIsManagedViewController(presented) || presented.hbd_requestCode != 0);
|
|
71
220
|
|
|
72
|
-
if (!
|
|
221
|
+
if (!shouldHandleDismiss) {
|
|
222
|
+
if (suppressResult && presentedChain.count > 0) {
|
|
223
|
+
[self hbd_dismissViewControllerAnimated:animated completion:^{
|
|
224
|
+
if (presented.presentingViewController == nil) {
|
|
225
|
+
[UIViewController hbd_markPresentedChainDestroyed:presentedChain];
|
|
226
|
+
}
|
|
227
|
+
if (completion) {
|
|
228
|
+
completion();
|
|
229
|
+
}
|
|
230
|
+
}];
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
73
233
|
[self hbd_dismissViewControllerAnimated:animated completion:completion];
|
|
74
234
|
return;
|
|
75
235
|
}
|
|
76
236
|
|
|
77
237
|
[self hbd_dismissViewControllerAnimated:animated completion:^{
|
|
78
|
-
if (
|
|
79
|
-
|
|
238
|
+
if (presented.presentingViewController == nil) {
|
|
239
|
+
if (!suppressResult) {
|
|
240
|
+
UIViewController *resultCarrier = [UIViewController hbd_resolveResultCarrier:presented];
|
|
241
|
+
NSInteger requestCode = presented.hbd_requestCode;
|
|
242
|
+
NSInteger resultCode = resultCarrier.hbd_resultCode;
|
|
243
|
+
NSDictionary *resultData = resultCarrier.hbd_resultData;
|
|
244
|
+
|
|
245
|
+
BOOL consumed = presented.hbd_presentingSceneId.length > 0 &&
|
|
246
|
+
[UIViewController hbd_dispatchResult:presenting
|
|
247
|
+
requestCode:requestCode
|
|
248
|
+
resultCode:resultCode
|
|
249
|
+
resultData:resultData
|
|
250
|
+
sceneId:presented.hbd_presentingSceneId];
|
|
251
|
+
if (!consumed) {
|
|
252
|
+
[presenting hbd_didReceiveResultCode:resultCode
|
|
253
|
+
resultData:resultData
|
|
254
|
+
requestCode:requestCode];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
[UIViewController hbd_markPresentedChainDestroyed:presentedChain];
|
|
259
|
+
if (!suppressResult && HBDIsManagedViewController(presented) && HBDIsOverContextModal(presented)) {
|
|
260
|
+
HBDViewController *revealed = [[HBDReactBridgeManager get] primaryViewControllerInHierarchy:presenting];
|
|
261
|
+
if (revealed) {
|
|
262
|
+
[revealed.lifecycleStateMachine syncVisibility];
|
|
263
|
+
[[HBDOrientationCoordinator shared] applyOrientationForViewController:revealed];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
80
266
|
}
|
|
81
267
|
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
BOOL consumed = presented.hbd_presentingSceneId.length > 0 &&
|
|
87
|
-
[UIViewController hbd_dispatchResult:presenting presented:presented sceneId:presented.hbd_presentingSceneId];
|
|
88
|
-
if (!consumed) {
|
|
89
|
-
[presenting hbd_didReceiveResultCode:presented.hbd_resultCode
|
|
90
|
-
resultData:presented.hbd_resultData
|
|
91
|
-
requestCode:presented.hbd_requestCode];
|
|
268
|
+
if (completion) {
|
|
269
|
+
completion();
|
|
92
270
|
}
|
|
93
271
|
}];
|
|
94
272
|
}
|
|
95
273
|
|
|
96
|
-
+ (BOOL)hbd_dispatchResult:(UIViewController *)presenting
|
|
274
|
+
+ (BOOL)hbd_dispatchResult:(UIViewController *)presenting
|
|
275
|
+
requestCode:(NSInteger)requestCode
|
|
276
|
+
resultCode:(NSInteger)resultCode
|
|
277
|
+
resultData:(nullable NSDictionary *)resultData
|
|
278
|
+
sceneId:(NSString *)sceneId {
|
|
97
279
|
if ([sceneId isEqualToString:presenting.hbd_sceneId]) {
|
|
98
|
-
[presenting hbd_didReceiveResultCode:
|
|
99
|
-
resultData:
|
|
100
|
-
requestCode:
|
|
280
|
+
[presenting hbd_didReceiveResultCode:resultCode
|
|
281
|
+
resultData:resultData
|
|
282
|
+
requestCode:requestCode];
|
|
101
283
|
return YES;
|
|
102
284
|
}
|
|
103
285
|
|
|
104
286
|
NSArray<UIViewController *> *children = presenting.childViewControllers;
|
|
105
287
|
for (UIViewController *vc in children) {
|
|
106
|
-
BOOL consumed = [self hbd_dispatchResult:vc
|
|
288
|
+
BOOL consumed = [self hbd_dispatchResult:vc
|
|
289
|
+
requestCode:requestCode
|
|
290
|
+
resultCode:resultCode
|
|
291
|
+
resultData:resultData
|
|
292
|
+
sceneId:sceneId];
|
|
107
293
|
if (consumed) {
|
|
108
294
|
return YES;
|
|
109
295
|
}
|
|
@@ -112,6 +298,40 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
112
298
|
return NO;
|
|
113
299
|
}
|
|
114
300
|
|
|
301
|
+
- (void)hbd_markDestroyedRecursively {
|
|
302
|
+
[self hbd_markDestroyedRecursivelyWithVisited:[NSMutableSet set]];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
- (void)hbd_markDestroyedRecursivelyWithVisited:(NSMutableSet<UIViewController *> *)visited {
|
|
306
|
+
if ([visited containsObject:self]) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
[visited addObject:self];
|
|
310
|
+
|
|
311
|
+
UIViewController *presented = self.presentedViewController;
|
|
312
|
+
if (presented && presented != self) {
|
|
313
|
+
[presented hbd_markDestroyedRecursivelyWithVisited:visited];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if ([self isKindOfClass:[HBDDrawerController class]]) {
|
|
317
|
+
HBDDrawerController *drawer = (HBDDrawerController *)self;
|
|
318
|
+
if (drawer.contentController) {
|
|
319
|
+
[drawer.contentController hbd_markDestroyedRecursivelyWithVisited:visited];
|
|
320
|
+
}
|
|
321
|
+
if (drawer.menuController) {
|
|
322
|
+
[drawer.menuController hbd_markDestroyedRecursivelyWithVisited:visited];
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
for (UIViewController *child in [self.childViewControllers copy]) {
|
|
327
|
+
[child hbd_markDestroyedRecursivelyWithVisited:visited];
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if ([self isKindOfClass:[HBDViewController class]]) {
|
|
331
|
+
[(HBDViewController *)self markSceneDestroyed];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
115
335
|
- (NSString *)hbd_sceneId {
|
|
116
336
|
id obj = objc_getAssociatedObject(self, _cmd);
|
|
117
337
|
if (!obj) {
|
|
@@ -121,6 +341,18 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
121
341
|
return obj;
|
|
122
342
|
}
|
|
123
343
|
|
|
344
|
+
- (nullable NSString *)hbd_existingSceneId {
|
|
345
|
+
return objc_getAssociatedObject(self, @selector(hbd_sceneId));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
- (nullable NSString *)hbd_layout {
|
|
349
|
+
return objc_getAssociatedObject(self, _cmd);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
- (void)setHbd_layout:(nullable NSString *)layout {
|
|
353
|
+
objc_setAssociatedObject(self, @selector(hbd_layout), layout, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
354
|
+
}
|
|
355
|
+
|
|
124
356
|
- (UIBarStyle)hbd_barStyle {
|
|
125
357
|
id obj = objc_getAssociatedObject(self, _cmd);
|
|
126
358
|
if (obj) {
|
|
@@ -151,20 +383,22 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
151
383
|
objc_setAssociatedObject(self, @selector(hbd_backInteractive), @(interactive), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
152
384
|
}
|
|
153
385
|
|
|
154
|
-
- (BOOL)
|
|
386
|
+
- (BOOL)hbd_interceptBackPop {
|
|
155
387
|
id obj = objc_getAssociatedObject(self, _cmd);
|
|
156
388
|
return obj ? [obj boolValue] : NO;
|
|
157
389
|
}
|
|
158
390
|
|
|
159
|
-
- (void)
|
|
160
|
-
objc_setAssociatedObject(self, @selector(
|
|
391
|
+
- (void)setHbd_interceptBackPop:(BOOL)enabled {
|
|
392
|
+
objc_setAssociatedObject(self, @selector(hbd_interceptBackPop), @(enabled), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
- (BOOL)hbd_hasLocalResult {
|
|
396
|
+
id obj = objc_getAssociatedObject(self, _cmd);
|
|
397
|
+
return obj ? [obj boolValue] : NO;
|
|
161
398
|
}
|
|
162
399
|
|
|
163
400
|
- (void)setHbd_resultCode:(NSInteger)resultCode {
|
|
164
|
-
|
|
165
|
-
if (presenting) {
|
|
166
|
-
objc_setAssociatedObject(presenting.presentedViewController, @selector(hbd_resultCode), @(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
167
|
-
}
|
|
401
|
+
objc_setAssociatedObject(self, @selector(hbd_hasLocalResult), @YES, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
168
402
|
objc_setAssociatedObject(self, @selector(hbd_resultCode), @(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
169
403
|
}
|
|
170
404
|
|
|
@@ -174,10 +408,7 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
174
408
|
}
|
|
175
409
|
|
|
176
410
|
- (void)setHbd_resultData:(NSDictionary *)data {
|
|
177
|
-
|
|
178
|
-
if (presenting) {
|
|
179
|
-
objc_setAssociatedObject(presenting.presentedViewController, @selector(hbd_resultData), data, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
180
|
-
}
|
|
411
|
+
objc_setAssociatedObject(self, @selector(hbd_hasLocalResult), @YES, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
181
412
|
objc_setAssociatedObject(self, @selector(hbd_resultData), data, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
182
413
|
}
|
|
183
414
|
|
|
@@ -195,13 +426,19 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
195
426
|
}
|
|
196
427
|
|
|
197
428
|
- (void)hbd_setLocalResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data {
|
|
429
|
+
objc_setAssociatedObject(self, @selector(hbd_hasLocalResult), @YES, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
198
430
|
objc_setAssociatedObject(self, @selector(hbd_resultCode), @(resultCode), OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
199
431
|
objc_setAssociatedObject(self, @selector(hbd_resultData), data, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
200
432
|
}
|
|
201
433
|
|
|
434
|
+
- (void)hbd_restoreLocalResult:(BOOL)hasLocalResult resultCode:(NSInteger)resultCode resultData:(NSDictionary *)data {
|
|
435
|
+
objc_setAssociatedObject(self, @selector(hbd_hasLocalResult), hasLocalResult ? @YES : nil, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
436
|
+
objc_setAssociatedObject(self, @selector(hbd_resultCode), hasLocalResult ? @(resultCode) : nil, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
437
|
+
objc_setAssociatedObject(self, @selector(hbd_resultData), hasLocalResult ? data : nil, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
438
|
+
}
|
|
439
|
+
|
|
202
440
|
- (void)hbd_setResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data {
|
|
203
|
-
self
|
|
204
|
-
self.hbd_resultData = data;
|
|
441
|
+
[self hbd_setLocalResultCode:resultCode resultData:data];
|
|
205
442
|
}
|
|
206
443
|
|
|
207
444
|
- (NSString *)hbd_presentingSceneId {
|
|
@@ -212,6 +449,14 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
212
449
|
objc_setAssociatedObject(self, @selector(hbd_presentingSceneId), presentingSceneId, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
213
450
|
}
|
|
214
451
|
|
|
452
|
+
- (NSString *)hbd_pushCallerSceneId {
|
|
453
|
+
return objc_getAssociatedObject(self, _cmd);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
- (void)setHbd_pushCallerSceneId:(NSString *)pushCallerSceneId {
|
|
457
|
+
objc_setAssociatedObject(self, @selector(hbd_pushCallerSceneId), pushCallerSceneId, OBJC_ASSOCIATION_COPY_NONATOMIC);
|
|
458
|
+
}
|
|
459
|
+
|
|
215
460
|
- (void)hbd_didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
|
|
216
461
|
if ([self isKindOfClass:[UITabBarController class]]) {
|
|
217
462
|
UIViewController *child = ((UITabBarController *)self).selectedViewController;
|
|
@@ -226,11 +471,20 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
226
471
|
}
|
|
227
472
|
|
|
228
473
|
if ([self isKindOfClass:[HBDDrawerController class]]) {
|
|
229
|
-
|
|
474
|
+
HBDDrawerController *drawer = (HBDDrawerController *)self;
|
|
475
|
+
UIViewController *child = drawer.isMenuOpened ? drawer.menuController : drawer.contentController;
|
|
230
476
|
[child hbd_didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
231
477
|
return;
|
|
232
478
|
}
|
|
233
479
|
|
|
480
|
+
if (![self isKindOfClass:[HBDViewController class]]) {
|
|
481
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewControllerInHierarchy:self];
|
|
482
|
+
if (primary && primary != self) {
|
|
483
|
+
[primary hbd_didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
234
488
|
NSArray *children = self.childViewControllers;
|
|
235
489
|
for (UIViewController *vc in children) {
|
|
236
490
|
[vc hbd_didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
@@ -253,13 +507,17 @@ static BOOL HBDIsManagedViewController(UIViewController * _Nullable vc) {
|
|
|
253
507
|
}
|
|
254
508
|
|
|
255
509
|
- (NSString *)hbd_mode {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
510
|
+
UIViewController *current = self;
|
|
511
|
+
while (current != nil) {
|
|
512
|
+
if (current.modalPresentationStyle == UIModalPresentationOverFullScreen) {
|
|
513
|
+
return @"modal";
|
|
514
|
+
}
|
|
515
|
+
current = current.parentViewController;
|
|
516
|
+
}
|
|
517
|
+
if (self.presentingViewController != nil) {
|
|
259
518
|
return @"present";
|
|
260
|
-
} else {
|
|
261
|
-
return @"normal";
|
|
262
519
|
}
|
|
520
|
+
return @"normal";
|
|
263
521
|
}
|
|
264
522
|
|
|
265
523
|
- (HBDGlobalStyle *)hbd_globalStyle {
|
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": "5.
|
|
4
|
+
"version": "5.5.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"module": "./dist/index",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
package/src/DeepLink.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { router } from './router';
|
|
|
4
4
|
class DeepLinkImpl {
|
|
5
5
|
private active = 0;
|
|
6
6
|
private uriPrefixes: string[] = [];
|
|
7
|
-
private
|
|
7
|
+
private hasCheckedInitialURL = false;
|
|
8
|
+
private pendingInitialUrl: string | null = null;
|
|
8
9
|
private subscription: EmitterSubscription | null = null;
|
|
9
10
|
|
|
10
11
|
activate(uriPrefix: string | string[]) {
|
|
@@ -12,25 +13,34 @@ class DeepLinkImpl {
|
|
|
12
13
|
if (prefixes.length === 0) {
|
|
13
14
|
throw new Error('must pass `uriPrefix` when activate router.');
|
|
14
15
|
}
|
|
15
|
-
this.uriPrefixes = prefixes;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
this.uriPrefixes = [...prefixes].sort((a, b) => b.length - a.length);
|
|
17
|
+
const wasInactive = this.active === 0;
|
|
18
|
+
this.active++;
|
|
19
|
+
if (wasInactive) {
|
|
20
|
+
this.subscription = Linking.addEventListener('url', this.handleLinking);
|
|
21
|
+
if (this.pendingInitialUrl) {
|
|
22
|
+
const url = this.pendingInitialUrl;
|
|
23
|
+
this.pendingInitialUrl = null;
|
|
24
|
+
this.openUrl(url);
|
|
25
|
+
} else if (!this.hasCheckedInitialURL) {
|
|
26
|
+
this.hasCheckedInitialURL = true;
|
|
19
27
|
Linking.getInitialURL()
|
|
20
28
|
.then(url => {
|
|
21
|
-
if (url
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
29
|
+
if (!url) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (this.active > 0) {
|
|
33
|
+
return this.openUrl(url);
|
|
27
34
|
}
|
|
35
|
+
this.pendingInitialUrl = url;
|
|
28
36
|
})
|
|
29
|
-
.catch(err =>
|
|
37
|
+
.catch(err => {
|
|
38
|
+
if (__DEV__) {
|
|
39
|
+
console.error('An error occurred', err);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
30
42
|
}
|
|
31
|
-
this.subscription = Linking.addEventListener('url', this.handleLinking);
|
|
32
43
|
}
|
|
33
|
-
this.active++;
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
deactivate() {
|
|
@@ -47,6 +57,20 @@ class DeepLinkImpl {
|
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
59
|
|
|
60
|
+
private openUrl(url: string) {
|
|
61
|
+
if (__DEV__) {
|
|
62
|
+
console.info(`deeplink:${url}`);
|
|
63
|
+
}
|
|
64
|
+
const path = this.extractPath(url);
|
|
65
|
+
if (path) {
|
|
66
|
+
return router.open(path).catch(err => {
|
|
67
|
+
if (__DEV__) {
|
|
68
|
+
console.error('An error occurred', err);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
50
74
|
private extractPath(url: string): string | null {
|
|
51
75
|
const lowerUrl = url.toLowerCase();
|
|
52
76
|
const matchedPrefix = this.uriPrefixes.find(prefix => {
|
|
@@ -76,11 +100,7 @@ class DeepLinkImpl {
|
|
|
76
100
|
}
|
|
77
101
|
|
|
78
102
|
private handleLinking = (event: { url: string }) => {
|
|
79
|
-
|
|
80
|
-
const path = this.extractPath(event.url);
|
|
81
|
-
if (path) {
|
|
82
|
-
router.open(path);
|
|
83
|
-
}
|
|
103
|
+
this.openUrl(event.url);
|
|
84
104
|
};
|
|
85
105
|
}
|
|
86
106
|
|
package/src/NativeNavigation.ts
CHANGED
|
@@ -15,7 +15,6 @@ export interface Route {
|
|
|
15
15
|
moduleName: string;
|
|
16
16
|
mode: LayoutMode;
|
|
17
17
|
presentingId: string | null;
|
|
18
|
-
requestCode: number;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
export interface NavigationSnapshot {
|
|
@@ -31,11 +30,17 @@ export interface RouteGraph {
|
|
|
31
30
|
children?: RouteGraph[];
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
export interface RemovalPlanWire {
|
|
34
|
+
status: string;
|
|
35
|
+
sceneIds: string[];
|
|
36
|
+
effectiveAction?: string;
|
|
37
|
+
dismissTarget?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
export interface Spec extends TurboModule {
|
|
35
41
|
getConstants: () => {
|
|
36
42
|
RESULT_OK: number;
|
|
37
43
|
RESULT_CANCEL: number;
|
|
38
|
-
RESULT_BLOCK: number;
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
startRegisterReactComponent: () => void;
|
|
@@ -53,15 +58,22 @@ export interface Spec extends TurboModule {
|
|
|
53
58
|
action: string,
|
|
54
59
|
params: CodegenTypes.UnsafeObject,
|
|
55
60
|
) => Promise<DispatchResultWire>;
|
|
61
|
+
planRemoval: (
|
|
62
|
+
sceneId: string,
|
|
63
|
+
action: string,
|
|
64
|
+
params: CodegenTypes.UnsafeObject,
|
|
65
|
+
) => Promise<RemovalPlanWire>;
|
|
56
66
|
currentTab: (sceneId: string) => Promise<number>;
|
|
57
67
|
isStackRoot: (sceneId: string) => Promise<boolean>;
|
|
58
68
|
findSceneIdByModuleName: (moduleName: string) => Promise<string | null>;
|
|
59
69
|
currentRoute: () => Promise<Route | null>;
|
|
60
|
-
/** @deprecated Use navigationSnapshot() and read its layers. */
|
|
61
|
-
routeGraph: () => Promise<RouteGraph[]>;
|
|
62
70
|
navigationSnapshot: () => Promise<NavigationSnapshot>;
|
|
63
71
|
|
|
64
|
-
|
|
72
|
+
setBeforeRemovePolicy: (
|
|
73
|
+
sceneId: string,
|
|
74
|
+
interceptPop: boolean,
|
|
75
|
+
interceptDismiss: boolean,
|
|
76
|
+
) => void;
|
|
65
77
|
setDefaultOptions: (options: CodegenTypes.UnsafeObject) => void;
|
|
66
78
|
updateOptions: (sceneId: string, options: CodegenTypes.UnsafeObject) => void;
|
|
67
79
|
updateTabBar: (sceneId: string, item: CodegenTypes.UnsafeObject) => void;
|