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
|
@@ -37,12 +37,13 @@
|
|
|
37
37
|
|
|
38
38
|
- (void)initialize {
|
|
39
39
|
RCTLogInfo(@"[Navigation] HBDNativeNavigation#initialize");
|
|
40
|
+
[self.bridgeManager bindNavigationModule:self];
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
- (void)invalidate {
|
|
43
44
|
RCTLogInfo(@"[Navigation] HBDNativeNavigation#invalidate");
|
|
44
45
|
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
45
|
-
[self.bridgeManager
|
|
46
|
+
[self.bridgeManager invalidateForModule:self];
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
@@ -52,8 +53,7 @@
|
|
|
52
53
|
- (nonnull facebook::react::ModuleConstants<JS::NativeNavigation::Constants::Builder>)constantsToExport {
|
|
53
54
|
JS::NativeNavigation::Constants::Builder::Input input = {
|
|
54
55
|
HBDResultOK,
|
|
55
|
-
HBDResultCancel
|
|
56
|
-
HBDResultBlock
|
|
56
|
+
HBDResultCancel
|
|
57
57
|
};
|
|
58
58
|
return facebook::react::typedConstants<JS::NativeNavigation::Constants::Builder>(std::move(input));
|
|
59
59
|
}
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
- (void)startRegisterReactComponent {
|
|
66
|
+
[self.bridgeManager bindNavigationModule:self];
|
|
66
67
|
[self.bridgeManager startRegisterReactModule];
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -82,13 +83,17 @@
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
- (void)currentTab:(nonnull NSString *)sceneId resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
[self.bridgeManager runWhenViewHierarchyReady:^{
|
|
87
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
88
|
+
UITabBarController *tabs = [self tabBarControllerWithViewController:vc];
|
|
89
|
+
if (tabs) {
|
|
90
|
+
resolve(@(tabs.selectedIndex));
|
|
91
|
+
} else {
|
|
92
|
+
resolve(@(-1));
|
|
93
|
+
}
|
|
94
|
+
} onCancelled:^{
|
|
90
95
|
resolve(@(-1));
|
|
91
|
-
}
|
|
96
|
+
}];
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
- (nullable NSString *)resolvedPresentingSceneIdForViewController:(UIViewController *)vc {
|
|
@@ -100,15 +105,6 @@
|
|
|
100
105
|
return nil;
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
- (NSInteger)resolvedRequestCodeForViewController:(UIViewController *)vc {
|
|
104
|
-
for (UIViewController *current = vc; current != nil; current = current.parentViewController) {
|
|
105
|
-
if (current.hbd_requestCode != 0) {
|
|
106
|
-
return current.hbd_requestCode;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return 0;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
108
|
- (nullable NSDictionary *)routeDictionaryForViewController:(nullable HBDViewController *)current {
|
|
113
109
|
if (!current) {
|
|
114
110
|
return nil;
|
|
@@ -118,7 +114,6 @@
|
|
|
118
114
|
@"sceneId": current.hbd_sceneId,
|
|
119
115
|
@"presentingId": RCTNullIfNil([self resolvedPresentingSceneIdForViewController:current]),
|
|
120
116
|
@"mode": [current hbd_mode],
|
|
121
|
-
@"requestCode": @([self resolvedRequestCodeForViewController:current]),
|
|
122
117
|
};
|
|
123
118
|
}
|
|
124
119
|
|
|
@@ -137,15 +132,6 @@
|
|
|
137
132
|
}];
|
|
138
133
|
}
|
|
139
134
|
|
|
140
|
-
- (void)routeGraph:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
141
|
-
[self.bridgeManager runWhenViewHierarchyReady:^{
|
|
142
|
-
NSArray *root = [self.bridgeManager routeGraph];
|
|
143
|
-
resolve(root ?: @[]);
|
|
144
|
-
} onCancelled:^{
|
|
145
|
-
resolve(@[]);
|
|
146
|
-
}];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
135
|
- (void)navigationSnapshot:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
150
136
|
[self.bridgeManager runWhenViewHierarchyReady:^{
|
|
151
137
|
HBDViewController *current = [self.bridgeManager primaryViewController];
|
|
@@ -182,31 +168,35 @@
|
|
|
182
168
|
}
|
|
183
169
|
|
|
184
170
|
- (void)isStackRoot:(nonnull NSString *)sceneId resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
171
|
+
[self.bridgeManager runWhenViewHierarchyReady:^{
|
|
172
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
173
|
+
if (!vc) {
|
|
174
|
+
resolve(@NO);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
190
177
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
178
|
+
UINavigationController *nav = vc.navigationController;
|
|
179
|
+
if (!nav) {
|
|
180
|
+
resolve(@NO);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
196
183
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
184
|
+
NSArray *children = nav.childViewControllers;
|
|
185
|
+
if (children.count == 0) {
|
|
186
|
+
resolve(@NO);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
202
189
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
190
|
+
UIViewController *root = children[0];
|
|
191
|
+
if ([self viewController:vc hasAncestorOrSelf:root]) {
|
|
192
|
+
resolve(@YES);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
208
195
|
|
|
209
|
-
|
|
196
|
+
resolve(@NO);
|
|
197
|
+
} onCancelled:^{
|
|
198
|
+
resolve(@NO);
|
|
199
|
+
}];
|
|
210
200
|
}
|
|
211
201
|
|
|
212
202
|
- (BOOL)viewController:(UIViewController *)viewController hasAncestorOrSelf:(UIViewController *)ancestor {
|
|
@@ -240,6 +230,14 @@ static HBDDispatchCompletion HBDOnceDispatchResolve(RCTPromiseResolveBlock resol
|
|
|
240
230
|
[self.bridgeManager enqueueNavigationWithSceneId:sceneId action:action extras:params completion:HBDOnceDispatchResolve(resolve)];
|
|
241
231
|
}
|
|
242
232
|
|
|
233
|
+
- (void)planRemoval:(nonnull NSString *)sceneId action:(nonnull NSString *)action params:(nonnull NSDictionary *)params resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
234
|
+
[self.bridgeManager runWhenViewHierarchyReady:^{
|
|
235
|
+
resolve([self.bridgeManager removalPlanWithSceneId:sceneId action:action extras:params ?: @{}]);
|
|
236
|
+
} onCancelled:^{
|
|
237
|
+
resolve(HBDRemovalPlan(@"noop", @[], nil, nil));
|
|
238
|
+
}];
|
|
239
|
+
}
|
|
240
|
+
|
|
243
241
|
- (void)setRoot:(nonnull NSDictionary *)layout sticky:(BOOL)sticky resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
244
242
|
[self.bridgeManager enqueueSetRootWithLayout:layout completion:HBDOnceDispatchResolve(resolve)];
|
|
245
243
|
}
|
|
@@ -261,10 +259,10 @@ static HBDDispatchCompletion HBDOnceDispatchResolve(RCTPromiseResolveBlock resol
|
|
|
261
259
|
}
|
|
262
260
|
}
|
|
263
261
|
|
|
264
|
-
- (void)
|
|
262
|
+
- (void)setBeforeRemovePolicy:(nonnull NSString *)sceneId interceptPop:(BOOL)interceptPop interceptDismiss:(BOOL)interceptDismiss {
|
|
265
263
|
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
266
264
|
if (vc) {
|
|
267
|
-
vc.
|
|
265
|
+
vc.hbd_interceptBackPop = interceptPop;
|
|
268
266
|
}
|
|
269
267
|
}
|
|
270
268
|
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#import "HBDNavigator.h"
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
@class HBDNavigationCommandQueue;
|
|
6
|
+
|
|
7
|
+
@protocol HBDNavigationCommandQueueDelegate <NSObject>
|
|
8
|
+
|
|
9
|
+
- (BOOL)commandQueueIsReactModuleRegisterCompleted:(HBDNavigationCommandQueue *)queue;
|
|
10
|
+
- (BOOL)commandQueueCanInstallRoot:(HBDNavigationCommandQueue *)queue;
|
|
11
|
+
- (BOOL)commandQueueHasRootLayout:(HBDNavigationCommandQueue *)queue;
|
|
12
|
+
- (BOOL)commandQueueHasInstalledRoot:(HBDNavigationCommandQueue *)queue;
|
|
13
|
+
- (BOOL)commandQueueHasInteractiveTransition:(HBDNavigationCommandQueue *)queue;
|
|
14
|
+
- (void)commandQueue:(HBDNavigationCommandQueue *)queue
|
|
15
|
+
executeSetRootWithLayout:(NSDictionary *)layout
|
|
16
|
+
completion:(HBDDispatchCompletion)completion;
|
|
17
|
+
- (void)commandQueue:(HBDNavigationCommandQueue *)queue
|
|
18
|
+
executeDispatchWithSceneId:(NSString *)sceneId
|
|
19
|
+
action:(NSString *)action
|
|
20
|
+
extras:(NSDictionary *)extras
|
|
21
|
+
completion:(HBDDispatchCompletion)completion;
|
|
22
|
+
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
@interface HBDNavigationCommandQueue : NSObject
|
|
26
|
+
|
|
27
|
+
@property(nonatomic, weak, nullable) id<HBDNavigationCommandQueueDelegate> delegate;
|
|
28
|
+
@property(nonatomic, assign, getter=isViewHierarchyReady) BOOL viewHierarchyReady;
|
|
29
|
+
@property(nonatomic, assign, readonly) NSUInteger activeCommandId;
|
|
30
|
+
@property(nonatomic, assign, readonly) NSUInteger commandQueueGeneration;
|
|
31
|
+
@property(nonatomic, assign, readonly) NSUInteger rootGeneration;
|
|
32
|
+
@property(nonatomic, assign, readonly) BOOL hasQueuedSetRoot;
|
|
33
|
+
|
|
34
|
+
- (NSUInteger)nextRootGeneration;
|
|
35
|
+
|
|
36
|
+
- (void)enqueueNavigationWithSceneId:(NSString *)sceneId
|
|
37
|
+
action:(NSString *)action
|
|
38
|
+
extras:(NSDictionary *)extras
|
|
39
|
+
completion:(nullable HBDDispatchCompletion)completion;
|
|
40
|
+
|
|
41
|
+
- (void)enqueueSetRootWithLayout:(NSDictionary *)layout
|
|
42
|
+
completion:(nullable HBDDispatchCompletion)completion;
|
|
43
|
+
|
|
44
|
+
- (void)drain;
|
|
45
|
+
|
|
46
|
+
- (void)runWhenViewHierarchyReady:(dispatch_block_t)task
|
|
47
|
+
onCancelled:(nullable dispatch_block_t)onCancelled;
|
|
48
|
+
|
|
49
|
+
- (void)supersedeAllCommandsWithReason:(NSString *)reason;
|
|
50
|
+
|
|
51
|
+
- (void)invalidateWithReason:(NSString *)reason;
|
|
52
|
+
|
|
53
|
+
@end
|
|
54
|
+
|
|
55
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
#import "HBDNavigationCommandQueue.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTLog.h>
|
|
4
|
+
|
|
5
|
+
static const NSTimeInterval HBDCommandTimeoutSeconds = 3.0;
|
|
6
|
+
static const NSTimeInterval HBDSetRootTimeoutSeconds = 5.0;
|
|
7
|
+
|
|
8
|
+
typedef NS_ENUM(NSInteger, HBDCommandType) {
|
|
9
|
+
HBDCommandTypeDispatch,
|
|
10
|
+
HBDCommandTypeSetRoot,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
@interface HBDNavigationCommand : NSObject
|
|
14
|
+
@property(nonatomic, assign) HBDCommandType type;
|
|
15
|
+
@property(nonatomic, copy, nullable) NSString *sceneId;
|
|
16
|
+
@property(nonatomic, copy, nullable) NSString *action;
|
|
17
|
+
@property(nonatomic, copy, nullable) NSDictionary *extras;
|
|
18
|
+
@property(nonatomic, copy, nullable) NSDictionary *layout;
|
|
19
|
+
@property(nonatomic, copy, nullable) HBDDispatchCompletion completion;
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
@implementation HBDNavigationCommand
|
|
23
|
+
@end
|
|
24
|
+
|
|
25
|
+
@interface HBDReadyTask : NSObject
|
|
26
|
+
@property(nonatomic, copy) dispatch_block_t task;
|
|
27
|
+
@property(nonatomic, copy, nullable) dispatch_block_t onCancelled;
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
@implementation HBDReadyTask
|
|
31
|
+
@end
|
|
32
|
+
|
|
33
|
+
@interface HBDNavigationCommandQueue ()
|
|
34
|
+
|
|
35
|
+
@property(nonatomic, strong) NSMutableArray<HBDReadyTask *> *viewHierarchyReadyTasks;
|
|
36
|
+
@property(nonatomic, assign) BOOL flushingViewHierarchyReadyTasks;
|
|
37
|
+
@property(nonatomic, strong) NSMutableArray<HBDNavigationCommand *> *commandQueue;
|
|
38
|
+
@property(nonatomic, assign) BOOL executingCommand;
|
|
39
|
+
@property(nonatomic, assign, readwrite) NSUInteger commandQueueGeneration;
|
|
40
|
+
@property(nonatomic, assign, readwrite) NSUInteger rootGeneration;
|
|
41
|
+
@property(nonatomic, strong, nullable) HBDNavigationCommand *activeCommand;
|
|
42
|
+
@property(nonatomic, assign, readwrite) NSUInteger activeCommandId;
|
|
43
|
+
@property(nonatomic, assign) NSUInteger nextCommandId;
|
|
44
|
+
@property(nonatomic, strong, nullable) dispatch_source_t activeTimeoutTimer;
|
|
45
|
+
|
|
46
|
+
@end
|
|
47
|
+
|
|
48
|
+
@implementation HBDNavigationCommandQueue
|
|
49
|
+
|
|
50
|
+
- (instancetype)init {
|
|
51
|
+
if (self = [super init]) {
|
|
52
|
+
_viewHierarchyReadyTasks = [NSMutableArray array];
|
|
53
|
+
_commandQueue = [NSMutableArray array];
|
|
54
|
+
}
|
|
55
|
+
return self;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)dealloc {
|
|
59
|
+
[self cancelActiveTimeoutTimer];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (NSUInteger)nextRootGeneration {
|
|
63
|
+
self.rootGeneration += 1;
|
|
64
|
+
return self.rootGeneration;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (BOOL)hasQueuedSetRoot {
|
|
68
|
+
if (self.activeCommand && self.activeCommand.type == HBDCommandTypeSetRoot) {
|
|
69
|
+
return YES;
|
|
70
|
+
}
|
|
71
|
+
for (HBDNavigationCommand *command in self.commandQueue) {
|
|
72
|
+
if (command.type == HBDCommandTypeSetRoot) {
|
|
73
|
+
return YES;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return NO;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (void)setViewHierarchyReady:(BOOL)viewHierarchyReady {
|
|
80
|
+
_viewHierarchyReady = viewHierarchyReady;
|
|
81
|
+
if (viewHierarchyReady) {
|
|
82
|
+
[self flushViewHierarchyReadyTasks];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (void)runWhenViewHierarchyReady:(dispatch_block_t)task onCancelled:(nullable dispatch_block_t)onCancelled {
|
|
87
|
+
if (!task) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (self.isViewHierarchyReady || !self.hasQueuedSetRoot) {
|
|
91
|
+
task();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
HBDReadyTask *entry = [HBDReadyTask new];
|
|
95
|
+
entry.task = task;
|
|
96
|
+
entry.onCancelled = onCancelled;
|
|
97
|
+
[self.viewHierarchyReadyTasks addObject:entry];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)cancelViewHierarchyReadyTasks {
|
|
101
|
+
NSArray<HBDReadyTask *> *pendingReadyTasks = [self.viewHierarchyReadyTasks copy];
|
|
102
|
+
[self.viewHierarchyReadyTasks removeAllObjects];
|
|
103
|
+
for (HBDReadyTask *entry in pendingReadyTasks) {
|
|
104
|
+
if (entry.onCancelled) {
|
|
105
|
+
entry.onCancelled();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
- (void)flushViewHierarchyReadyTasks {
|
|
111
|
+
if (!self.isViewHierarchyReady || self.flushingViewHierarchyReadyTasks) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
self.flushingViewHierarchyReadyTasks = YES;
|
|
116
|
+
while (self.isViewHierarchyReady && self.viewHierarchyReadyTasks.count > 0) {
|
|
117
|
+
HBDReadyTask *entry = self.viewHierarchyReadyTasks.firstObject;
|
|
118
|
+
[self.viewHierarchyReadyTasks removeObjectAtIndex:0];
|
|
119
|
+
if (entry.task) {
|
|
120
|
+
entry.task();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
self.flushingViewHierarchyReadyTasks = NO;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (void)enqueueNavigationWithSceneId:(NSString *)sceneId
|
|
127
|
+
action:(NSString *)action
|
|
128
|
+
extras:(NSDictionary *)extras
|
|
129
|
+
completion:(nullable HBDDispatchCompletion)completion {
|
|
130
|
+
HBDNavigationCommand *command = [HBDNavigationCommand new];
|
|
131
|
+
command.type = HBDCommandTypeDispatch;
|
|
132
|
+
command.sceneId = sceneId;
|
|
133
|
+
command.action = action;
|
|
134
|
+
command.extras = extras;
|
|
135
|
+
command.completion = completion;
|
|
136
|
+
[self.commandQueue addObject:command];
|
|
137
|
+
[self drain];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (void)enqueueSetRootWithLayout:(NSDictionary *)layout completion:(nullable HBDDispatchCompletion)completion {
|
|
141
|
+
NSArray<HBDNavigationCommand *> *superseded = [self.commandQueue copy];
|
|
142
|
+
[self.commandQueue removeAllObjects];
|
|
143
|
+
for (HBDNavigationCommand *cmd in superseded) {
|
|
144
|
+
if (cmd.completion) {
|
|
145
|
+
HBDDispatchCompletion cb = cmd.completion;
|
|
146
|
+
cmd.completion = nil;
|
|
147
|
+
cb(HBDDispatchResultFail(HBDDispatchCodeSuperseded, @"Navigation command was superseded by a newer setRoot call."));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
HBDNavigationCommand *command = [HBDNavigationCommand new];
|
|
152
|
+
command.type = HBDCommandTypeSetRoot;
|
|
153
|
+
command.layout = layout;
|
|
154
|
+
command.completion = completion;
|
|
155
|
+
[self.commandQueue addObject:command];
|
|
156
|
+
[self drain];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (void)cancelActiveTimeoutTimer {
|
|
160
|
+
if (self.activeTimeoutTimer) {
|
|
161
|
+
dispatch_source_cancel(self.activeTimeoutTimer);
|
|
162
|
+
self.activeTimeoutTimer = nil;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
- (void)startTimeoutTimerWithDuration:(NSTimeInterval)seconds handler:(dispatch_block_t)handler {
|
|
167
|
+
[self cancelActiveTimeoutTimer];
|
|
168
|
+
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
|
|
169
|
+
dispatch_source_set_timer(
|
|
170
|
+
timer,
|
|
171
|
+
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(seconds * NSEC_PER_SEC)),
|
|
172
|
+
DISPATCH_TIME_FOREVER,
|
|
173
|
+
(uint64_t)(0.05 * NSEC_PER_SEC)
|
|
174
|
+
);
|
|
175
|
+
dispatch_source_set_event_handler(timer, handler);
|
|
176
|
+
self.activeTimeoutTimer = timer;
|
|
177
|
+
dispatch_resume(timer);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
- (void)drain {
|
|
181
|
+
if (self.executingCommand || self.commandQueue.count == 0) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
id<HBDNavigationCommandQueueDelegate> delegate = self.delegate;
|
|
186
|
+
if (!delegate) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
HBDNavigationCommand *peek = self.commandQueue.firstObject;
|
|
191
|
+
if (peek.type == HBDCommandTypeSetRoot &&
|
|
192
|
+
(![delegate commandQueueIsReactModuleRegisterCompleted:self] ||
|
|
193
|
+
![delegate commandQueueCanInstallRoot:self])) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
HBDNavigationCommand *command = self.commandQueue.firstObject;
|
|
198
|
+
[self.commandQueue removeObjectAtIndex:0];
|
|
199
|
+
self.executingCommand = YES;
|
|
200
|
+
self.activeCommand = command;
|
|
201
|
+
self.activeCommandId = ++self.nextCommandId;
|
|
202
|
+
|
|
203
|
+
NSUInteger generation = self.commandQueueGeneration;
|
|
204
|
+
__block BOOL completed = NO;
|
|
205
|
+
__weak HBDNavigationCommandQueue *weakSelf = self;
|
|
206
|
+
HBDDispatchCompletion finishCommand = ^(NSDictionary *result) {
|
|
207
|
+
HBDNavigationCommandQueue *strongSelf = weakSelf;
|
|
208
|
+
if (!strongSelf || completed) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
completed = YES;
|
|
212
|
+
[strongSelf cancelActiveTimeoutTimer];
|
|
213
|
+
HBDDispatchCompletion callback = command.completion;
|
|
214
|
+
command.completion = nil;
|
|
215
|
+
if (strongSelf.activeCommand == command) {
|
|
216
|
+
strongSelf.activeCommand = nil;
|
|
217
|
+
strongSelf.activeCommandId = 0;
|
|
218
|
+
}
|
|
219
|
+
if (generation != strongSelf.commandQueueGeneration) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
NSDictionary *resolvedResult = result ?: HBDDispatchResultFail(HBDDispatchCodeInvalidAction, nil);
|
|
223
|
+
if (command.type == HBDCommandTypeSetRoot && ![resolvedResult[@"ok"] boolValue]) {
|
|
224
|
+
id<HBDNavigationCommandQueueDelegate> currentDelegate = strongSelf.delegate;
|
|
225
|
+
if (currentDelegate && [currentDelegate commandQueueHasInstalledRoot:strongSelf]) {
|
|
226
|
+
if (!strongSelf.hasQueuedSetRoot) {
|
|
227
|
+
strongSelf.viewHierarchyReady = YES;
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
[strongSelf cancelViewHierarchyReadyTasks];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (callback) {
|
|
234
|
+
callback(resolvedResult);
|
|
235
|
+
}
|
|
236
|
+
strongSelf.executingCommand = NO;
|
|
237
|
+
if (strongSelf.commandQueue.count > 0) {
|
|
238
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
239
|
+
[strongSelf drain];
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
if (command.type == HBDCommandTypeSetRoot) {
|
|
245
|
+
[self startTimeoutTimerWithDuration:HBDSetRootTimeoutSeconds handler:^{
|
|
246
|
+
HBDNavigationCommandQueue *strongSelf = weakSelf;
|
|
247
|
+
if (!strongSelf) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (!completed && generation == strongSelf.commandQueueGeneration) {
|
|
251
|
+
RCTLogWarn(@"[Navigation] setRoot command timed out, unlocking command queue.");
|
|
252
|
+
[strongSelf nextRootGeneration];
|
|
253
|
+
finishCommand(HBDDispatchResultFail(HBDDispatchCodeNotReady, @"setRoot command timed out."));
|
|
254
|
+
}
|
|
255
|
+
}];
|
|
256
|
+
[delegate commandQueue:self executeSetRootWithLayout:command.layout ?: @{} completion:finishCommand];
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (![delegate commandQueueIsReactModuleRegisterCompleted:self]) {
|
|
261
|
+
finishCommand(HBDDispatchResultFail(HBDDispatchCodeNotReady, @"React module registration is not completed."));
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if ([delegate commandQueueHasRootLayout:self] && !self.isViewHierarchyReady) {
|
|
266
|
+
finishCommand(HBDDispatchResultFail(HBDDispatchCodeNotReady, @"View hierarchy is not ready."));
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
[self startTimeoutTimerWithDuration:HBDCommandTimeoutSeconds handler:^{
|
|
271
|
+
HBDNavigationCommandQueue *strongSelf = weakSelf;
|
|
272
|
+
if (!strongSelf) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!completed && generation == strongSelf.commandQueueGeneration) {
|
|
276
|
+
id<HBDNavigationCommandQueueDelegate> currentDelegate = strongSelf.delegate;
|
|
277
|
+
if (currentDelegate && [currentDelegate commandQueueHasInteractiveTransition:strongSelf]) {
|
|
278
|
+
RCTLogWarn(@"[Navigation] Navigation command timed out while an interactive transition is active. action=%@", command.action ?: @"");
|
|
279
|
+
} else {
|
|
280
|
+
RCTLogWarn(@"[Navigation] Navigation command timed out, unlocking command queue. action=%@", command.action ?: @"");
|
|
281
|
+
}
|
|
282
|
+
finishCommand(HBDDispatchResultFail(HBDDispatchCodeNotReady, @"Navigation command timed out."));
|
|
283
|
+
}
|
|
284
|
+
}];
|
|
285
|
+
|
|
286
|
+
[delegate commandQueue:self
|
|
287
|
+
executeDispatchWithSceneId:command.sceneId ?: @""
|
|
288
|
+
action:command.action ?: @""
|
|
289
|
+
extras:command.extras ?: @{}
|
|
290
|
+
completion:finishCommand];
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
- (void)supersedeAllCommandsWithReason:(NSString *)reason {
|
|
294
|
+
[self abortCommandsWithResult:HBDDispatchResultFail(HBDDispatchCodeSuperseded, reason)
|
|
295
|
+
cancelReadyTasks:NO
|
|
296
|
+
bumpRootGeneration:NO];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
- (void)invalidateWithReason:(NSString *)reason {
|
|
300
|
+
[self abortCommandsWithResult:HBDDispatchResultFail(HBDDispatchCodeHostUnavailable, reason)
|
|
301
|
+
cancelReadyTasks:YES
|
|
302
|
+
bumpRootGeneration:YES];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
- (void)abortCommandsWithResult:(NSDictionary *)failure
|
|
306
|
+
cancelReadyTasks:(BOOL)cancelReady
|
|
307
|
+
bumpRootGeneration:(BOOL)bumpRootGeneration {
|
|
308
|
+
[self cancelActiveTimeoutTimer];
|
|
309
|
+
self.commandQueueGeneration += 1;
|
|
310
|
+
if (bumpRootGeneration) {
|
|
311
|
+
self.rootGeneration += 1;
|
|
312
|
+
}
|
|
313
|
+
self.executingCommand = NO;
|
|
314
|
+
self.activeCommandId = 0;
|
|
315
|
+
|
|
316
|
+
HBDNavigationCommand *activeCommand = self.activeCommand;
|
|
317
|
+
self.activeCommand = nil;
|
|
318
|
+
NSArray<HBDNavigationCommand *> *pendingCommands = [self.commandQueue copy];
|
|
319
|
+
[self.commandQueue removeAllObjects];
|
|
320
|
+
self.viewHierarchyReady = NO;
|
|
321
|
+
|
|
322
|
+
if (activeCommand) {
|
|
323
|
+
HBDDispatchCompletion completion = activeCommand.completion;
|
|
324
|
+
activeCommand.completion = nil;
|
|
325
|
+
if (completion) {
|
|
326
|
+
completion(failure);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
for (HBDNavigationCommand *command in pendingCommands) {
|
|
330
|
+
HBDDispatchCompletion completion = command.completion;
|
|
331
|
+
command.completion = nil;
|
|
332
|
+
if (completion) {
|
|
333
|
+
completion(failure);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (cancelReady) {
|
|
337
|
+
[self cancelViewHierarchyReadyTasks];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
@end
|
package/ios/React/HBDNavigator.h
CHANGED
|
@@ -32,6 +32,20 @@ static inline NSDictionary *HBDDispatchResultFail(NSString *code, NSString * _Nu
|
|
|
32
32
|
return @{ @"ok": @NO, @"code": code ?: HBDDispatchCodeInvalidAction };
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
static inline NSDictionary *HBDRemovalPlan(NSString *status, NSArray<NSString *> * _Nullable sceneIds, NSString * _Nullable effectiveAction, NSString * _Nullable dismissTarget) {
|
|
36
|
+
NSMutableDictionary *plan = [@{
|
|
37
|
+
@"status": status ?: @"noop",
|
|
38
|
+
@"sceneIds": sceneIds ?: @[],
|
|
39
|
+
} mutableCopy];
|
|
40
|
+
if (effectiveAction.length > 0) {
|
|
41
|
+
plan[@"effectiveAction"] = effectiveAction;
|
|
42
|
+
}
|
|
43
|
+
if (dismissTarget.length > 0) {
|
|
44
|
+
plan[@"dismissTarget"] = dismissTarget;
|
|
45
|
+
}
|
|
46
|
+
return [plan copy];
|
|
47
|
+
}
|
|
48
|
+
|
|
35
49
|
@protocol HBDNavigator <NSObject>
|
|
36
50
|
|
|
37
51
|
@property(nonatomic, copy, readonly) NSString *name;
|
|
@@ -47,6 +61,12 @@ static inline NSDictionary *HBDDispatchResultFail(NSString *code, NSString * _Nu
|
|
|
47
61
|
|
|
48
62
|
- (void)invalidate;
|
|
49
63
|
|
|
64
|
+
@optional
|
|
65
|
+
|
|
66
|
+
- (BOOL)handlesViewController:(UIViewController *)vc;
|
|
67
|
+
|
|
68
|
+
- (nullable NSDictionary *)removalPlanWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras;
|
|
69
|
+
|
|
50
70
|
@end
|
|
51
71
|
|
|
52
72
|
NS_ASSUME_NONNULL_END
|
|
@@ -123,7 +123,7 @@ HBDScreenOrientation HBDScreenOrientationFromString(NSString * _Nullable value)
|
|
|
123
123
|
return [self resolvedOrientationForViewController:(HBDViewController *)presenting visited:visited];
|
|
124
124
|
}
|
|
125
125
|
if (presenting && presenting != modalVC && presenting != modalContainer) {
|
|
126
|
-
HBDViewController *primary = [[HBDReactBridgeManager get]
|
|
126
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewControllerInHierarchy:presenting];
|
|
127
127
|
if (primary && primary != modalVC && ![visited containsObject:primary]) {
|
|
128
128
|
return [self resolvedOrientationForViewController:primary visited:visited];
|
|
129
129
|
}
|
|
@@ -132,7 +132,7 @@ HBDScreenOrientation HBDScreenOrientationFromString(NSString * _Nullable value)
|
|
|
132
132
|
|
|
133
133
|
UIViewController *presentingVC = modalContainer.presentingViewController ?: modalVC.presentingViewController;
|
|
134
134
|
if (presentingVC && presentingVC != modalVC && presentingVC != modalContainer) {
|
|
135
|
-
HBDViewController *primary = [[HBDReactBridgeManager get]
|
|
135
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewControllerInHierarchy:presentingVC];
|
|
136
136
|
if (primary && primary != modalVC && ![visited containsObject:primary]) {
|
|
137
137
|
return [self resolvedOrientationForViewController:primary visited:visited];
|
|
138
138
|
}
|
|
@@ -150,6 +150,17 @@ HBDScreenOrientation HBDScreenOrientationFromString(NSString * _Nullable value)
|
|
|
150
150
|
|
|
151
151
|
- (void)applyOrientationForViewController:(HBDViewController *)viewController
|
|
152
152
|
allowDeferredModal:(BOOL)allowDeferredModal {
|
|
153
|
+
if (!viewController) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewController];
|
|
157
|
+
if (primary != nil && primary != viewController && !primary.isBeingDismissed) {
|
|
158
|
+
if ([self modalContainerForViewController:primary] != nil && primary.screenOrientation == HBDScreenOrientationUnspecified) {
|
|
159
|
+
[self applyOrientationForViewController:primary allowDeferredModal:allowDeferredModal];
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
153
164
|
UIWindow *window = [self windowForViewController:viewController];
|
|
154
165
|
UIWindowScene *windowScene = [self windowSceneForViewController:viewController window:window];
|
|
155
166
|
if (!windowScene) {
|
|
@@ -248,7 +259,19 @@ HBDScreenOrientation HBDScreenOrientationFromString(NSString * _Nullable value)
|
|
|
248
259
|
if (!viewController.isViewLoaded || !viewController.view.window) {
|
|
249
260
|
return;
|
|
250
261
|
}
|
|
251
|
-
[
|
|
262
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewController];
|
|
263
|
+
if (!primary) {
|
|
264
|
+
[self applyOrientationForViewController:viewController];
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (primary == viewController) {
|
|
268
|
+
[self applyOrientationForViewController:viewController];
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
// If a transparent modal on top inherits orientation from the underlying scene, re-apply on the modal primary.
|
|
272
|
+
if ([self modalContainerForViewController:primary] != nil && primary.screenOrientation == HBDScreenOrientationUnspecified) {
|
|
273
|
+
[self applyOrientationForViewController:primary];
|
|
274
|
+
}
|
|
252
275
|
}
|
|
253
276
|
|
|
254
277
|
- (BOOL)isWindowOrientationCompatibleForViewController:(HBDViewController *)viewController window:(UIWindow *)window {
|