hybrid-navigation 4.0.8 → 5.0.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 +9 -1
- package/README.md +12 -4
- package/android/build.gradle +5 -4
- package/android/proguard-rules.pro +3 -0
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +114 -23
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +116 -13
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +83 -18
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +192 -28
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +11 -0
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +563 -143
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +47 -15
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +3 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +8 -3
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +29 -9
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +28 -3
- package/android/src/main/java/com/navigation/androidx/SystemUI.java +59 -90
- package/android/src/main/java/com/navigation/androidx/TabBar.java +21 -2
- package/android/src/main/java/com/navigation/androidx/TabBarFragment.java +24 -7
- package/android/src/main/java/com/navigation/androidx/TabView.java +11 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/DispatchResult.java +59 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +18 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +15 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +3 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +113 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +13 -24
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +5 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +196 -194
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationCommandQueue.java +499 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Navigator.java +4 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/OrientationCoordinator.java +162 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +103 -66
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +50 -87
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +156 -77
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactSurfaceCleanup.java +3 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +8 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/SceneLifecycleState.java +21 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/SceneLifecycleStateMachine.java +116 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ScreenOrientation.java +42 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +17 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +14 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +62 -22
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +35 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +16 -13
- package/dist/DeepLink.d.ts +3 -2
- package/dist/DeepLink.js +37 -14
- package/dist/NativeEvent.d.ts +4 -12
- package/dist/NativeNavigation.d.ts +17 -19
- package/dist/Navigation.d.ts +21 -19
- package/dist/Navigation.js +83 -89
- package/dist/NavigationComponentWrap.d.ts +4 -3
- package/dist/NavigationComponentWrap.js +3 -6
- package/dist/Navigator.d.ts +31 -42
- package/dist/Navigator.js +97 -90
- package/dist/Options.d.ts +3 -1
- package/dist/Route.d.ts +85 -18
- package/dist/handler/DispatchCommandHandler.d.ts +10 -6
- package/dist/handler/DispatchCommandHandler.js +41 -17
- package/dist/handler/LayoutCommandHandler.d.ts +7 -7
- package/dist/handler/LayoutCommandHandler.js +21 -15
- package/dist/handler/LifecycleEventHandler.d.ts +26 -0
- package/dist/handler/LifecycleEventHandler.js +136 -0
- package/dist/handler/ResultEventHandler.d.ts +14 -9
- package/dist/handler/ResultEventHandler.js +88 -13
- package/dist/hooks.d.ts +5 -2
- package/dist/hooks.js +26 -4
- package/dist/index.d.ts +13 -0
- package/dist/index.js +0 -2
- package/dist/routeConfigRegistry.d.ts +6 -0
- package/dist/routeConfigRegistry.js +19 -0
- package/dist/router/drawer.d.ts +2 -2
- package/dist/router/drawer.js +6 -3
- package/dist/router/index.d.ts +8 -5
- package/dist/router/index.js +127 -43
- package/dist/router/screen.d.ts +2 -2
- package/dist/router/screen.js +1 -1
- package/dist/router/stack.d.ts +2 -2
- package/dist/router/stack.js +59 -30
- package/dist/router/tabs.d.ts +2 -2
- package/dist/router/tabs.js +4 -1
- package/dist/store.d.ts +2 -2
- package/ios/HBDGlobalStyle.h +26 -0
- package/ios/{GlobalStyle.mm → HBDGlobalStyle.mm} +30 -27
- package/ios/HybridNavigation.h +4 -1
- package/ios/Navigator/HBDDrawerNavigator.mm +24 -8
- package/ios/Navigator/HBDNavigatorRegistry.mm +1 -0
- package/ios/Navigator/HBDScreenNavigator.mm +106 -52
- package/ios/Navigator/HBDStackNavigator.mm +109 -61
- package/ios/Navigator/HBDTabNavigator.mm +32 -14
- package/ios/React/HBDNativeNavigation.mm +109 -131
- package/ios/React/HBDNavigator.h +29 -5
- package/ios/React/HBDOrientationCoordinator.h +27 -0
- package/ios/React/HBDOrientationCoordinator.mm +282 -0
- package/ios/React/HBDReactBridgeManager.h +37 -19
- package/ios/React/HBDReactBridgeManager.mm +490 -96
- package/ios/React/HBDSceneLifecycleStateMachine.h +38 -0
- package/ios/React/HBDSceneLifecycleStateMachine.mm +180 -0
- package/ios/View/HBDRootView.h +2 -0
- package/ios/View/HBDRootView.mm +148 -0
- package/ios/View/UIImage+WithBadge.h +3 -3
- package/ios/View/UIImage+WithBadge.mm +10 -15
- package/ios/ViewController/HBDDrawerController.mm +127 -6
- package/ios/ViewController/HBDNavigationController.mm +17 -4
- package/ios/ViewController/HBDReactViewController.mm +59 -121
- package/ios/ViewController/HBDTabBarController.h +4 -0
- package/ios/ViewController/HBDTabBarController.mm +59 -44
- package/ios/ViewController/HBDViewController.h +10 -3
- package/ios/ViewController/HBDViewController.mm +161 -147
- package/ios/ViewController/UINavigationController+HBD.h +2 -2
- package/ios/ViewController/UINavigationController+HBD.mm +3 -3
- package/ios/ViewController/UIViewController+HBD.h +17 -10
- package/ios/ViewController/UIViewController+HBD.mm +85 -69
- package/package.json +1 -1
- package/src/DeepLink.ts +41 -14
- package/src/NativeEvent.ts +4 -14
- package/src/NativeNavigation.ts +22 -33
- package/src/Navigation.ts +162 -121
- package/src/NavigationComponentWrap.tsx +9 -9
- package/src/Navigator.ts +191 -153
- package/src/Options.ts +3 -1
- package/src/Route.ts +134 -19
- package/src/handler/DispatchCommandHandler.ts +55 -21
- package/src/handler/LayoutCommandHandler.ts +36 -17
- package/src/handler/LifecycleEventHandler.ts +172 -0
- package/src/handler/ResultEventHandler.ts +112 -19
- package/src/hooks.ts +39 -7
- package/src/index.ts +26 -2
- package/src/routeConfigRegistry.ts +26 -0
- package/src/router/drawer.ts +8 -5
- package/src/router/index.ts +161 -50
- package/src/router/screen.ts +3 -3
- package/src/router/stack.ts +80 -29
- package/src/router/tabs.ts +15 -7
- package/src/store.ts +1 -1
- package/android/src/main/java/androidx/fragment/app/InternalFragment.java +0 -22
- package/android/src/main/java/com/navigation/androidx/SystemUI30.java +0 -87
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +0 -176
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +0 -130
- package/android/src/main/res/layout/nav_tab_bar_react.xml +0 -32
- package/android/src/main/res/layout/nav_tab_bar_react_indeterminate.xml +0 -32
- package/dist/NativeGarden.d.ts +0 -13
- package/dist/NativeGarden.js +0 -2
- package/dist/handler/VisibilityEventHandler.d.ts +0 -13
- package/dist/handler/VisibilityEventHandler.js +0 -39
- package/ios/GlobalStyle.h +0 -15
- package/ios/React/HBDNativeGarden.h +0 -10
- package/ios/React/HBDNativeGarden.mm +0 -111
- package/src/NativeGarden.ts +0 -16
- package/src/handler/VisibilityEventHandler.ts +0 -52
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
#import "HBDOrientationCoordinator.h"
|
|
2
|
+
|
|
3
|
+
#import "HBDGlobalStyle.h"
|
|
4
|
+
#import "HBDReactBridgeManager.h"
|
|
5
|
+
#import "HBDViewController.h"
|
|
6
|
+
#import "UIViewController+HBD.h"
|
|
7
|
+
|
|
8
|
+
HBDScreenOrientation HBDScreenOrientationFromString(NSString * _Nullable value) {
|
|
9
|
+
if (![value isKindOfClass:[NSString class]]) {
|
|
10
|
+
return HBDScreenOrientationUnspecified;
|
|
11
|
+
}
|
|
12
|
+
if ([value isEqualToString:@"portrait"]) {
|
|
13
|
+
return HBDScreenOrientationPortrait;
|
|
14
|
+
}
|
|
15
|
+
if ([value isEqualToString:@"landscape"]) {
|
|
16
|
+
return HBDScreenOrientationLandscape;
|
|
17
|
+
}
|
|
18
|
+
if ([value isEqualToString:@"auto"]) {
|
|
19
|
+
return HBDScreenOrientationAuto;
|
|
20
|
+
}
|
|
21
|
+
return HBDScreenOrientationUnspecified;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@interface HBDOrientationCoordinator ()
|
|
25
|
+
|
|
26
|
+
@property(nonatomic, strong, nullable) NSNumber *activeMask;
|
|
27
|
+
@property(nonatomic, assign) NSUInteger deferredGeneration;
|
|
28
|
+
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
@implementation HBDOrientationCoordinator
|
|
32
|
+
|
|
33
|
+
+ (instancetype)shared {
|
|
34
|
+
static dispatch_once_t onceToken;
|
|
35
|
+
static HBDOrientationCoordinator *coordinator;
|
|
36
|
+
dispatch_once(&onceToken, ^{
|
|
37
|
+
coordinator = [[self alloc] init];
|
|
38
|
+
});
|
|
39
|
+
return coordinator;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (UIInterfaceOrientationMask)maskForOrientation:(HBDScreenOrientation)orientation {
|
|
43
|
+
switch (orientation) {
|
|
44
|
+
case HBDScreenOrientationLandscape:
|
|
45
|
+
return UIInterfaceOrientationMaskLandscape;
|
|
46
|
+
case HBDScreenOrientationAuto:
|
|
47
|
+
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
|
|
48
|
+
return UIInterfaceOrientationMaskAll;
|
|
49
|
+
}
|
|
50
|
+
return UIInterfaceOrientationMaskAllButUpsideDown;
|
|
51
|
+
case HBDScreenOrientationPortrait:
|
|
52
|
+
case HBDScreenOrientationUnspecified:
|
|
53
|
+
return UIInterfaceOrientationMaskPortrait;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (UIInterfaceOrientationMask)supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window {
|
|
58
|
+
if (self.activeMask != nil) {
|
|
59
|
+
return (UIInterfaceOrientationMask)[self.activeMask unsignedIntegerValue];
|
|
60
|
+
}
|
|
61
|
+
return [self maskForOrientation:[HBDGlobalStyle globalStyle].defaultOrientation];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (HBDScreenOrientation)resolvedOrientationForViewController:(HBDViewController *)viewController {
|
|
65
|
+
return [self resolvedOrientationForViewController:viewController visited:[NSMutableSet set]];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (nullable UIViewController *)modalContainerForViewController:(UIViewController *)viewController {
|
|
69
|
+
UIViewController *current = viewController;
|
|
70
|
+
while (current != nil) {
|
|
71
|
+
if (current.modalPresentationStyle == UIModalPresentationOverFullScreen) {
|
|
72
|
+
return current;
|
|
73
|
+
}
|
|
74
|
+
current = current.parentViewController;
|
|
75
|
+
}
|
|
76
|
+
return nil;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
- (HBDScreenOrientation)resolvedOrientationForViewController:(HBDViewController *)viewController
|
|
80
|
+
visited:(NSMutableSet<UIViewController *> *)visited {
|
|
81
|
+
if (!viewController || [visited containsObject:viewController]) {
|
|
82
|
+
return [HBDGlobalStyle globalStyle].defaultOrientation;
|
|
83
|
+
}
|
|
84
|
+
[visited addObject:viewController];
|
|
85
|
+
|
|
86
|
+
HBDScreenOrientation explicitOrientation = viewController.screenOrientation;
|
|
87
|
+
if (explicitOrientation != HBDScreenOrientationUnspecified) {
|
|
88
|
+
return explicitOrientation;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
UIViewController *modalContainer = [self modalContainerForViewController:viewController];
|
|
92
|
+
if (modalContainer != nil) {
|
|
93
|
+
HBDScreenOrientation inherited = [self modalInheritedOrientationForViewController:viewController
|
|
94
|
+
modalContainer:modalContainer
|
|
95
|
+
visited:visited];
|
|
96
|
+
if (inherited != HBDScreenOrientationUnspecified) {
|
|
97
|
+
return inherited;
|
|
98
|
+
}
|
|
99
|
+
UIWindow *window = [self windowForViewController:viewController];
|
|
100
|
+
UIInterfaceOrientationMask activeMask = [self supportedInterfaceOrientationsForWindow:window];
|
|
101
|
+
if (activeMask == UIInterfaceOrientationMaskLandscape) {
|
|
102
|
+
return HBDScreenOrientationLandscape;
|
|
103
|
+
}
|
|
104
|
+
if (activeMask == UIInterfaceOrientationMaskAll || activeMask == UIInterfaceOrientationMaskAllButUpsideDown) {
|
|
105
|
+
return HBDScreenOrientationAuto;
|
|
106
|
+
}
|
|
107
|
+
return HBDScreenOrientationPortrait;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return [HBDGlobalStyle globalStyle].defaultOrientation;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (HBDScreenOrientation)modalInheritedOrientationForViewController:(HBDViewController *)modalVC
|
|
114
|
+
modalContainer:(UIViewController *)modalContainer
|
|
115
|
+
visited:(NSMutableSet<UIViewController *> *)visited {
|
|
116
|
+
NSString *presentingSceneId = modalVC.hbd_presentingSceneId;
|
|
117
|
+
if (presentingSceneId.length == 0 && modalContainer != modalVC) {
|
|
118
|
+
presentingSceneId = modalContainer.hbd_presentingSceneId;
|
|
119
|
+
}
|
|
120
|
+
if (presentingSceneId.length > 0) {
|
|
121
|
+
UIViewController *presenting = [[HBDReactBridgeManager get] viewControllerBySceneId:presentingSceneId];
|
|
122
|
+
if ([presenting isKindOfClass:[HBDViewController class]] && presenting != modalVC && ![visited containsObject:presenting]) {
|
|
123
|
+
return [self resolvedOrientationForViewController:(HBDViewController *)presenting visited:visited];
|
|
124
|
+
}
|
|
125
|
+
if (presenting && presenting != modalVC && presenting != modalContainer) {
|
|
126
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewControllerWithViewController:presenting];
|
|
127
|
+
if (primary && primary != modalVC && ![visited containsObject:primary]) {
|
|
128
|
+
return [self resolvedOrientationForViewController:primary visited:visited];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
UIViewController *presentingVC = modalContainer.presentingViewController ?: modalVC.presentingViewController;
|
|
134
|
+
if (presentingVC && presentingVC != modalVC && presentingVC != modalContainer) {
|
|
135
|
+
HBDViewController *primary = [[HBDReactBridgeManager get] primaryViewControllerWithViewController:presentingVC];
|
|
136
|
+
if (primary && primary != modalVC && ![visited containsObject:primary]) {
|
|
137
|
+
return [self resolvedOrientationForViewController:primary visited:visited];
|
|
138
|
+
}
|
|
139
|
+
if ([presentingVC isKindOfClass:[HBDViewController class]] && ![visited containsObject:presentingVC]) {
|
|
140
|
+
return [self resolvedOrientationForViewController:(HBDViewController *)presentingVC visited:visited];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return HBDScreenOrientationUnspecified;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
- (void)applyOrientationForViewController:(HBDViewController *)viewController {
|
|
148
|
+
[self applyOrientationForViewController:viewController allowDeferredModal:YES];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (void)applyOrientationForViewController:(HBDViewController *)viewController
|
|
152
|
+
allowDeferredModal:(BOOL)allowDeferredModal {
|
|
153
|
+
UIWindow *window = [self windowForViewController:viewController];
|
|
154
|
+
UIWindowScene *windowScene = [self windowSceneForViewController:viewController window:window];
|
|
155
|
+
if (!windowScene) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
HBDScreenOrientation targetOrientation = [self resolvedOrientationForViewController:viewController];
|
|
160
|
+
UIInterfaceOrientationMask targetMask = [self maskForOrientation:targetOrientation];
|
|
161
|
+
UIInterfaceOrientationMask previousMask = [self supportedInterfaceOrientationsForWindow:window];
|
|
162
|
+
UIInterfaceOrientation current = windowScene.interfaceOrientation;
|
|
163
|
+
BOOL currentSupported = ((1 << current) & targetMask) != 0;
|
|
164
|
+
|
|
165
|
+
// Non-animated modal presentation runs with UIView animations disabled; defer one runloop turn so rotation animates.
|
|
166
|
+
UIViewController *modalContainer = [self modalContainerForViewController:viewController];
|
|
167
|
+
if (allowDeferredModal && modalContainer != nil &&
|
|
168
|
+
(modalContainer.isBeingPresented || viewController.isBeingPresented || ![UIView areAnimationsEnabled]) &&
|
|
169
|
+
(!currentSupported || targetMask != previousMask)) {
|
|
170
|
+
NSUInteger generation = ++self.deferredGeneration;
|
|
171
|
+
__weak HBDOrientationCoordinator *weakSelf = self;
|
|
172
|
+
__weak HBDViewController *weakVC = viewController;
|
|
173
|
+
__weak UIViewController *weakModal = modalContainer;
|
|
174
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
175
|
+
HBDOrientationCoordinator *strongSelf = weakSelf;
|
|
176
|
+
HBDViewController *strongVC = weakVC;
|
|
177
|
+
UIViewController *strongModal = weakModal;
|
|
178
|
+
if (!strongSelf || !strongVC || !strongModal || strongSelf.deferredGeneration != generation) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (strongVC.isBeingDismissed || strongModal.isBeingDismissed ||
|
|
182
|
+
!strongVC.isViewLoaded || !strongVC.view.window) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
UIViewController *presentedOnModal = strongModal.presentedViewController;
|
|
186
|
+
if (presentedOnModal && !presentedOnModal.isBeingDismissed) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
[strongSelf applyOrientationForViewController:strongVC allowDeferredModal:NO];
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
self.deferredGeneration += 1;
|
|
195
|
+
self.activeMask = @(targetMask);
|
|
196
|
+
|
|
197
|
+
if (!currentSupported) {
|
|
198
|
+
[viewController.view endEditing:YES];
|
|
199
|
+
[viewController.navigationController.view endEditing:YES];
|
|
200
|
+
for (UIWindow *sceneWindow in windowScene.windows) {
|
|
201
|
+
[sceneWindow endEditing:YES];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (@available(iOS 16.0, *)) {
|
|
206
|
+
UIViewController *controller = viewController;
|
|
207
|
+
while (controller != nil) {
|
|
208
|
+
[controller setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
209
|
+
controller = controller.parentViewController;
|
|
210
|
+
}
|
|
211
|
+
UIViewController *rootViewController = window.rootViewController ?: windowScene.keyWindow.rootViewController;
|
|
212
|
+
if (rootViewController != nil) {
|
|
213
|
+
[rootViewController setNeedsUpdateOfSupportedInterfaceOrientations];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (!currentSupported) {
|
|
217
|
+
UIInterfaceOrientationMask requestMask = targetMask;
|
|
218
|
+
if (targetOrientation == HBDScreenOrientationLandscape && !UIInterfaceOrientationIsLandscape(current)) {
|
|
219
|
+
requestMask = ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight)
|
|
220
|
+
? UIInterfaceOrientationMaskLandscapeLeft
|
|
221
|
+
: UIInterfaceOrientationMaskLandscapeRight;
|
|
222
|
+
}
|
|
223
|
+
UIWindowSceneGeometryPreferencesIOS *geometryPreferences =
|
|
224
|
+
[[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:requestMask];
|
|
225
|
+
[windowScene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) {
|
|
226
|
+
#if DEBUG
|
|
227
|
+
if (error) {
|
|
228
|
+
NSLog(@"Failed to update geometry with UIInterfaceOrientationMask: %@", error);
|
|
229
|
+
}
|
|
230
|
+
#endif
|
|
231
|
+
}];
|
|
232
|
+
}
|
|
233
|
+
} else if (!currentSupported) {
|
|
234
|
+
UIInterfaceOrientation desiredOrientation = UIInterfaceOrientationPortrait;
|
|
235
|
+
if (targetOrientation == HBDScreenOrientationLandscape) {
|
|
236
|
+
desiredOrientation = ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight)
|
|
237
|
+
? UIInterfaceOrientationLandscapeLeft
|
|
238
|
+
: UIInterfaceOrientationLandscapeRight;
|
|
239
|
+
}
|
|
240
|
+
UIDevice *currentDevice = [UIDevice currentDevice];
|
|
241
|
+
[currentDevice setValue:@(UIInterfaceOrientationUnknown) forKey:@"orientation"];
|
|
242
|
+
[currentDevice setValue:@(desiredOrientation) forKey:@"orientation"];
|
|
243
|
+
[UIViewController attemptRotationToDeviceOrientation];
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
- (void)sceneOptionsDidUpdate:(HBDViewController *)viewController {
|
|
248
|
+
if (!viewController.isViewLoaded || !viewController.view.window) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
[self applyOrientationForViewController:viewController];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
- (nullable UIWindow *)windowForViewController:(UIViewController *)viewController {
|
|
255
|
+
UIWindow *window = viewController.viewIfLoaded.window ?: viewController.navigationController.viewIfLoaded.window;
|
|
256
|
+
if (window) {
|
|
257
|
+
return window;
|
|
258
|
+
}
|
|
259
|
+
return [[HBDReactBridgeManager get] mainWindow];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
- (nullable UIWindowScene *)windowSceneForViewController:(UIViewController *)viewController window:(nullable UIWindow *)window {
|
|
263
|
+
if ([window.windowScene isKindOfClass:[UIWindowScene class]]) {
|
|
264
|
+
return window.windowScene;
|
|
265
|
+
}
|
|
266
|
+
UIWindowScene *fallbackScene = nil;
|
|
267
|
+
for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
|
|
268
|
+
if (![scene isKindOfClass:[UIWindowScene class]]) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
UIWindowScene *windowScene = (UIWindowScene *)scene;
|
|
272
|
+
if (windowScene.activationState == UISceneActivationStateForegroundActive) {
|
|
273
|
+
return windowScene;
|
|
274
|
+
}
|
|
275
|
+
if (windowScene.activationState == UISceneActivationStateForegroundInactive || !fallbackScene) {
|
|
276
|
+
fallbackScene = windowScene;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return fallbackScene;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@end
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
#import <React/RCTBridge.h>
|
|
2
1
|
#import "HBDNavigator.h"
|
|
3
2
|
#import <ReactCommon/RCTHost.h>
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
extern const NSInteger ResultOK;
|
|
7
|
-
extern const NSInteger ResultCancel;
|
|
8
|
-
extern const NSInteger ResultBlock;
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
5
|
|
|
6
|
+
extern NSString *const HBDReactModuleRegistryDidCompletedNotification;
|
|
7
|
+
extern NSString *const HBDReactBridgeWillReloadNotification;
|
|
8
|
+
extern const NSInteger HBDResultOK;
|
|
9
|
+
extern const NSInteger HBDResultCancel;
|
|
10
|
+
extern const NSInteger HBDResultBlock;
|
|
11
|
+
|
|
12
|
+
@class HBDGlobalStyle;
|
|
10
13
|
@class HBDReactBridgeManager;
|
|
11
14
|
@class HBDViewController;
|
|
12
15
|
|
|
@@ -20,13 +23,14 @@ extern const NSInteger ResultBlock;
|
|
|
20
23
|
|
|
21
24
|
+ (instancetype)get;
|
|
22
25
|
|
|
23
|
-
@property(nonatomic, strong, readonly)
|
|
24
|
-
@property(nonatomic, strong
|
|
25
|
-
@property(nonatomic, weak) id
|
|
26
|
+
@property(nonatomic, strong, readonly, nullable) RCTHost *rctHost;
|
|
27
|
+
@property(nonatomic, strong) HBDGlobalStyle *globalStyle;
|
|
28
|
+
@property(nonatomic, weak, nullable) id<HBDReactBridgeManagerDelegate> delegate;
|
|
26
29
|
@property(nonatomic, assign, readonly, getter=isReactModuleRegisterCompleted) BOOL reactModuleRegisterCompleted;
|
|
27
30
|
@property(nonatomic, assign, getter=isViewHierarchyReady) BOOL viewHierarchyReady;
|
|
28
31
|
@property(nonatomic, assign) BOOL hasRootLayout;
|
|
29
|
-
@property(nonatomic, copy)
|
|
32
|
+
@property(nonatomic, copy, nullable) HBDDispatchCompletion didSetRoot;
|
|
33
|
+
@property(nonatomic, assign, readonly) NSUInteger activeCommandId;
|
|
30
34
|
|
|
31
35
|
- (void)installWithReactHost:(RCTHost *)rctHost;
|
|
32
36
|
|
|
@@ -34,11 +38,11 @@ extern const NSInteger ResultBlock;
|
|
|
34
38
|
|
|
35
39
|
- (BOOL)hasNativeModule:(NSString *)moduleName;
|
|
36
40
|
|
|
37
|
-
- (Class)nativeModuleClass:(NSString *)moduleName;
|
|
41
|
+
- (nullable Class)nativeModuleClass:(NSString *)moduleName;
|
|
38
42
|
|
|
39
|
-
- (void)registerReactModule:(NSString *)moduleName options:(NSDictionary *)options;
|
|
43
|
+
- (void)registerReactModule:(NSString *)moduleName options:(nullable NSDictionary *)options;
|
|
40
44
|
|
|
41
|
-
- (NSDictionary *)reactModuleOptions:(NSString *)moduleName;
|
|
45
|
+
- (nullable NSDictionary *)reactModuleOptions:(NSString *)moduleName;
|
|
42
46
|
|
|
43
47
|
- (BOOL)hasReactModule:(NSString *)moduleName;
|
|
44
48
|
|
|
@@ -46,26 +50,40 @@ extern const NSInteger ResultBlock;
|
|
|
46
50
|
|
|
47
51
|
- (void)endRegisterReactModule;
|
|
48
52
|
|
|
49
|
-
- (HBDViewController *)viewControllerWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options;
|
|
53
|
+
- (nullable HBDViewController *)viewControllerWithModuleName:(NSString *)moduleName props:(nullable NSDictionary *)props options:(nullable NSDictionary *)options;
|
|
54
|
+
|
|
55
|
+
- (nullable UIViewController *)viewControllerWithLayout:(NSDictionary *)layout;
|
|
50
56
|
|
|
51
|
-
- (UIViewController *)
|
|
57
|
+
- (nullable UIViewController *)viewControllerBySceneId:(NSString *)sceneId;
|
|
52
58
|
|
|
53
|
-
- (
|
|
59
|
+
- (nullable UIWindow *)mainWindow;
|
|
54
60
|
|
|
55
61
|
- (void)setRootViewController:(UIViewController *)rootViewController;
|
|
56
62
|
|
|
57
63
|
- (NSArray *)routeGraph;
|
|
58
64
|
|
|
59
|
-
- (NSDictionary *)routeGraphWithViewController:(UIViewController *)vc;
|
|
65
|
+
- (nullable NSDictionary *)routeGraphWithViewController:(UIViewController *)vc;
|
|
66
|
+
|
|
67
|
+
- (nullable HBDViewController *)primaryViewController;
|
|
68
|
+
|
|
69
|
+
- (nullable HBDViewController *)primaryViewControllerWithViewController:(nullable UIViewController *)vc;
|
|
60
70
|
|
|
61
|
-
- (
|
|
71
|
+
- (nullable NSString *)findSceneIdByModuleName:(NSString *)moduleName;
|
|
62
72
|
|
|
63
|
-
- (
|
|
73
|
+
- (void)handleNavigationWithViewController:(UIViewController *)vc action:(NSString *)action extras:(NSDictionary *)extras completion:(HBDDispatchCompletion)completion;
|
|
64
74
|
|
|
65
|
-
- (void)
|
|
75
|
+
- (void)enqueueNavigationWithSceneId:(NSString *)sceneId action:(NSString *)action extras:(NSDictionary *)extras completion:(nullable HBDDispatchCompletion)completion;
|
|
76
|
+
|
|
77
|
+
- (void)enqueueSetRootWithLayout:(NSDictionary *)layout completion:(nullable HBDDispatchCompletion)completion;
|
|
78
|
+
|
|
79
|
+
- (void)runWhenViewHierarchyReady:(dispatch_block_t)task;
|
|
80
|
+
|
|
81
|
+
- (void)runWhenViewHierarchyReady:(dispatch_block_t)task onCancelled:(nullable dispatch_block_t)onCancelled;
|
|
66
82
|
|
|
67
83
|
- (void)registerNavigator:(id<HBDNavigator>)navigator;
|
|
68
84
|
|
|
69
85
|
- (void)invalidate;
|
|
70
86
|
|
|
71
87
|
@end
|
|
88
|
+
|
|
89
|
+
NS_ASSUME_NONNULL_END
|