hybrid-navigation 4.1.0 → 5.1.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 +4 -4
- package/android/proguard-rules.pro +0 -14
- package/android/src/main/java/com/navigation/androidx/AwesomeActivity.java +116 -27
- package/android/src/main/java/com/navigation/androidx/AwesomeFragment.java +162 -13
- package/android/src/main/java/com/navigation/androidx/DefaultTabBarProvider.java +2 -2
- package/android/src/main/java/com/navigation/androidx/DrawableUtils.java +83 -18
- package/android/src/main/java/com/navigation/androidx/DrawerFragment.java +185 -25
- package/android/src/main/java/com/navigation/androidx/FragmentHelper.java +18 -0
- package/android/src/main/java/com/navigation/androidx/HybridDrawerLayout.java +563 -143
- package/android/src/main/java/com/navigation/androidx/LifecycleDelegate.java +39 -12
- package/android/src/main/java/com/navigation/androidx/PresentableActivity.java +3 -0
- package/android/src/main/java/com/navigation/androidx/PresentationDelegate.java +10 -7
- package/android/src/main/java/com/navigation/androidx/StackDelegate.java +29 -9
- package/android/src/main/java/com/navigation/androidx/StackFragment.java +31 -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 +74 -7
- package/android/src/main/java/com/navigation/androidx/TabBarItem.java +4 -0
- package/android/src/main/java/com/navigation/androidx/TabView.java +11 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/DispatchResult.java +71 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +18 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +34 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDRootView.java +20 -10
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +179 -13
- 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 +283 -183
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationCommandQueue.java +507 -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 +421 -92
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +227 -78
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +6 -6
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +26 -0
- 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 +188 -26
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +67 -16
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +42 -14
- package/dist/DeepLink.d.ts +3 -2
- package/dist/DeepLink.js +37 -14
- package/dist/NativeEvent.d.ts +17 -10
- package/dist/NativeNavigation.d.ts +24 -18
- package/dist/Navigation.d.ts +34 -19
- package/dist/Navigation.js +225 -90
- package/dist/NavigationComponentWrap.d.ts +5 -3
- package/dist/NavigationComponentWrap.js +3 -6
- package/dist/Navigator.d.ts +32 -42
- package/dist/Navigator.js +117 -91
- package/dist/Options.d.ts +15 -3
- package/dist/Route.d.ts +149 -17
- package/dist/defineRoutes.d.ts +19 -0
- package/dist/defineRoutes.js +6 -0
- package/dist/handler/DispatchCommandHandler.d.ts +25 -6
- package/dist/handler/DispatchCommandHandler.js +99 -17
- package/dist/handler/LayoutCommandHandler.d.ts +8 -7
- package/dist/handler/LayoutCommandHandler.js +24 -15
- package/dist/handler/LeaveGuardHandler.d.ts +17 -0
- package/dist/handler/LeaveGuardHandler.js +350 -0
- package/dist/handler/LifecycleEventHandler.d.ts +30 -0
- package/dist/handler/LifecycleEventHandler.js +169 -0
- package/dist/handler/PresentationCoordinator.d.ts +24 -0
- package/dist/handler/PresentationCoordinator.js +449 -0
- package/dist/handler/ResultEventHandler.d.ts +21 -9
- package/dist/handler/ResultEventHandler.js +96 -13
- package/dist/handler/TabEventHandler.d.ts +8 -0
- package/dist/handler/TabEventHandler.js +25 -0
- package/dist/hooks.d.ts +7 -2
- package/dist/hooks.js +46 -4
- package/dist/index.d.ts +24 -0
- package/dist/index.js +3 -2
- package/dist/reveal.d.ts +46 -0
- package/dist/reveal.js +431 -0
- package/dist/routeConfigRegistry.d.ts +6 -0
- package/dist/routeConfigRegistry.js +19 -0
- package/dist/routeGraph.d.ts +12 -0
- package/dist/routeGraph.js +68 -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 +106 -58
- 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 +3 -2
- package/dist/router/tabs.js +4 -1
- package/dist/store.d.ts +4 -2
- package/dist/store.js +4 -0
- package/dist/testing.d.ts +79 -0
- package/dist/testing.js +251 -0
- package/ios/HBDGlobalStyle.h +29 -0
- package/ios/{GlobalStyle.mm → HBDGlobalStyle.mm} +43 -29
- package/ios/HybridNavigation.h +5 -1
- package/ios/Navigator/HBDDrawerNavigator.mm +24 -8
- package/ios/Navigator/HBDNavigatorRegistry.mm +1 -0
- package/ios/Navigator/HBDScreenNavigator.mm +278 -58
- package/ios/Navigator/HBDStackNavigator.mm +152 -61
- package/ios/Navigator/HBDTabNavigator.mm +60 -14
- package/ios/React/HBDNativeNavigation.mm +162 -123
- package/ios/React/HBDNavigator.h +37 -5
- package/ios/React/HBDOrientationCoordinator.h +29 -0
- package/ios/React/HBDOrientationCoordinator.mm +309 -0
- package/ios/React/HBDReactBridgeManager.h +46 -20
- package/ios/React/HBDReactBridgeManager.mm +496 -108
- 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 +126 -5
- package/ios/ViewController/HBDNavigationController.mm +31 -4
- package/ios/ViewController/HBDReactViewController.h +6 -0
- package/ios/ViewController/HBDReactViewController.mm +220 -106
- package/ios/ViewController/HBDTabBarController.h +15 -0
- package/ios/ViewController/HBDTabBarController.mm +227 -45
- package/ios/ViewController/HBDTabBarRenderer.h +28 -0
- package/ios/ViewController/HBDViewController.h +11 -3
- package/ios/ViewController/HBDViewController.mm +209 -159
- package/ios/ViewController/UINavigationController+HBD.h +2 -2
- package/ios/ViewController/UINavigationController+HBD.mm +3 -3
- package/ios/ViewController/UIViewController+HBD.h +18 -10
- package/ios/ViewController/UIViewController+HBD.mm +90 -65
- package/package.json +3 -1
- package/src/DeepLink.ts +41 -14
- package/src/NativeEvent.ts +18 -11
- package/src/NativeNavigation.ts +29 -31
- package/src/Navigation.ts +377 -120
- package/src/NavigationComponentWrap.tsx +18 -9
- package/src/Navigator.ts +219 -152
- package/src/Options.ts +12 -3
- package/src/Route.ts +228 -17
- package/src/defineRoutes.ts +46 -0
- package/src/handler/DispatchCommandHandler.ts +154 -21
- package/src/handler/LayoutCommandHandler.ts +40 -17
- package/src/handler/LeaveGuardHandler.ts +436 -0
- package/src/handler/LifecycleEventHandler.ts +219 -0
- package/src/handler/PresentationCoordinator.ts +560 -0
- package/src/handler/ResultEventHandler.ts +126 -19
- package/src/handler/TabEventHandler.ts +31 -0
- package/src/hooks.ts +75 -7
- package/src/index.ts +37 -2
- package/src/reveal.ts +565 -0
- package/src/routeConfigRegistry.ts +26 -0
- package/src/routeGraph.ts +87 -0
- package/src/router/drawer.ts +8 -5
- package/src/router/index.ts +139 -63
- package/src/router/screen.ts +3 -3
- package/src/router/stack.ts +80 -29
- package/src/router/tabs.ts +16 -7
- package/src/store.ts +6 -1
- package/src/testing.ts +395 -0
- package/testing.d.ts +1 -0
- package/testing.js +3 -0
- 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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#import "HBDNavigationController.h"
|
|
2
2
|
|
|
3
3
|
#import "HBDViewController.h"
|
|
4
|
+
#import "HBDNativeEvent.h"
|
|
5
|
+
#import "HBDOrientationCoordinator.h"
|
|
6
|
+
#import "HBDReactBridgeManager.h"
|
|
4
7
|
|
|
5
8
|
#import <React/RCTLog.h>
|
|
6
9
|
#import <React/RCTUtils.h>
|
|
@@ -8,6 +11,7 @@
|
|
|
8
11
|
@interface HBDNavigationController () <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
|
|
9
12
|
|
|
10
13
|
@property(nonatomic, weak) UIViewController *poppingViewController;
|
|
14
|
+
@property(nonatomic, assign) NSInteger poppingRequestCode;
|
|
11
15
|
@property(nonatomic, strong) UIScreenEdgePanGestureRecognizer *navigationPopGestureRecognizer;
|
|
12
16
|
|
|
13
17
|
- (UIGestureRecognizer *)superInteractivePopGestureRecognizer;
|
|
@@ -101,10 +105,23 @@
|
|
|
101
105
|
|
|
102
106
|
if (self.viewControllers.count > 1) {
|
|
103
107
|
UIViewController *topVC = self.topViewController;
|
|
104
|
-
if ([topVC isKindOfClass:[HBDViewController class]] &&
|
|
108
|
+
if ([topVC isKindOfClass:[HBDViewController class]] &&
|
|
109
|
+
[[HBDOrientationCoordinator shared] resolvedOrientationForViewController:(HBDViewController *)topVC] == HBDScreenOrientationLandscape) {
|
|
105
110
|
return NO;
|
|
106
111
|
}
|
|
107
|
-
|
|
112
|
+
if (topVC.hbd_beforeRemoveEnabled) {
|
|
113
|
+
if ([HBDReactBridgeManager get].isReactModuleRegisterCompleted && topVC.hbd_sceneId.length > 0) {
|
|
114
|
+
HBDNativeEvent *event = [HBDNativeEvent getInstance];
|
|
115
|
+
if (event) {
|
|
116
|
+
[event emitOnBeforeRemoveRequest:@{
|
|
117
|
+
@"sceneId": topVC.hbd_sceneId,
|
|
118
|
+
@"action": @"back",
|
|
119
|
+
}];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return NO;
|
|
123
|
+
}
|
|
124
|
+
return topVC.hbd_backInteractive;
|
|
108
125
|
}
|
|
109
126
|
return NO;
|
|
110
127
|
}
|
|
@@ -132,16 +149,19 @@
|
|
|
132
149
|
[self hideSystemNavigationBar];
|
|
133
150
|
|
|
134
151
|
UIViewController *poppingVC = self.poppingViewController;
|
|
135
|
-
|
|
136
|
-
|
|
152
|
+
NSInteger requestCode = self.poppingRequestCode;
|
|
153
|
+
if (poppingVC && poppingVC != viewController) {
|
|
154
|
+
[viewController hbd_didReceiveResultCode:poppingVC.hbd_resultCode resultData:poppingVC.hbd_resultData requestCode:requestCode];
|
|
137
155
|
}
|
|
138
156
|
|
|
139
157
|
self.poppingViewController = nil;
|
|
158
|
+
self.poppingRequestCode = 0;
|
|
140
159
|
}
|
|
141
160
|
|
|
142
161
|
- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
|
|
143
162
|
if (self.childViewControllers.count > 1) {
|
|
144
163
|
self.poppingViewController = self.topViewController;
|
|
164
|
+
self.poppingRequestCode = self.topViewController.hbd_requestCode;
|
|
145
165
|
}
|
|
146
166
|
|
|
147
167
|
return [super popViewControllerAnimated:animated];
|
|
@@ -150,6 +170,12 @@
|
|
|
150
170
|
- (NSArray<UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
151
171
|
if (self.childViewControllers.count > 1) {
|
|
152
172
|
self.poppingViewController = self.topViewController;
|
|
173
|
+
NSUInteger targetIndex = [self.childViewControllers indexOfObject:viewController];
|
|
174
|
+
if (targetIndex != NSNotFound && targetIndex + 1 < self.childViewControllers.count) {
|
|
175
|
+
self.poppingRequestCode = self.childViewControllers[targetIndex + 1].hbd_requestCode;
|
|
176
|
+
} else {
|
|
177
|
+
self.poppingRequestCode = self.topViewController.hbd_requestCode;
|
|
178
|
+
}
|
|
153
179
|
}
|
|
154
180
|
|
|
155
181
|
return [super popToViewController:viewController animated:animated];
|
|
@@ -158,6 +184,7 @@
|
|
|
158
184
|
- (NSArray<UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated {
|
|
159
185
|
if (self.childViewControllers.count > 1) {
|
|
160
186
|
self.poppingViewController = self.topViewController;
|
|
187
|
+
self.poppingRequestCode = self.childViewControllers[1].hbd_requestCode;
|
|
161
188
|
}
|
|
162
189
|
|
|
163
190
|
return [super popToRootViewControllerAnimated:animated];
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
#import "HBDViewController.h"
|
|
2
2
|
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
3
5
|
@interface HBDReactViewController : HBDViewController
|
|
4
6
|
|
|
5
7
|
- (void)signalFirstRenderComplete;
|
|
6
8
|
|
|
9
|
+
- (BOOL)prepareForAnimatedPushWithBounds:(CGRect)bounds timeout:(NSTimeInterval)timeout completion:(dispatch_block_t)completion;
|
|
10
|
+
|
|
7
11
|
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
#import "HBDReactViewController.h"
|
|
2
2
|
|
|
3
|
+
#import "HBDDrawerController.h"
|
|
4
|
+
#import "HBDGlobalStyle.h"
|
|
5
|
+
#import "HBDNativeEvent.h"
|
|
6
|
+
#import "HBDOrientationCoordinator.h"
|
|
3
7
|
#import "HBDReactBridgeManager.h"
|
|
4
8
|
#import "HBDRootView.h"
|
|
5
9
|
#import "HBDUtils.h"
|
|
6
|
-
#import "HBDNativeEvent.h"
|
|
7
|
-
#import "GlobalStyle.h"
|
|
8
10
|
|
|
9
11
|
#import <React/RCTConvert.h>
|
|
10
12
|
|
|
11
13
|
@interface HBDReactViewController ()
|
|
12
14
|
|
|
13
|
-
@property(nonatomic, assign) BOOL firstRenderCompleted;
|
|
14
|
-
@property(nonatomic, assign) BOOL viewAppeared;
|
|
15
|
-
@property(nonatomic, assign) BOOL appearanceEventSent;
|
|
16
|
-
@property(nonatomic, assign) BOOL appearanceEventScheduled;
|
|
17
|
-
@property(nonatomic, assign) NSUInteger appearanceEventGeneration;
|
|
18
15
|
@property(nonatomic, strong, readwrite) HBDRootView *rootView;
|
|
16
|
+
@property(nonatomic, copy, nullable) dispatch_block_t pushPrewarmCompletion;
|
|
17
|
+
@property(nonatomic, assign) NSUInteger pushPrewarmGeneration;
|
|
19
18
|
|
|
20
19
|
@end
|
|
21
20
|
|
|
22
|
-
@implementation HBDReactViewController
|
|
23
|
-
NSArray *_reactViewConstraints;
|
|
24
|
-
}
|
|
21
|
+
@implementation HBDReactViewController
|
|
25
22
|
|
|
26
23
|
- (void)syncRootViewBackgroundColor {
|
|
27
24
|
if (!self.rootView) {
|
|
@@ -33,36 +30,55 @@
|
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
- (void)dealloc {
|
|
36
|
-
[[
|
|
33
|
+
[[HBDReactBridgeManager get] unregisterPrewarmingViewController:self];
|
|
34
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBDReactBridgeWillReloadNotification object:nil];
|
|
37
35
|
RCTLogInfo(@"[Navigation] 销毁页面 %@", self.moduleName);
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
- (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options {
|
|
41
39
|
if (self = [super initWithModuleName:moduleName props:props options:options]) {
|
|
42
40
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleReload)
|
|
43
|
-
name:
|
|
41
|
+
name:HBDReactBridgeWillReloadNotification object:nil];
|
|
42
|
+
__weak HBDReactViewController *weakSelf = self;
|
|
43
|
+
self.lifecycleStateMachine.readyForVisibleCheck = ^BOOL(BOOL flushLayout) {
|
|
44
|
+
HBDReactViewController *controller = weakSelf;
|
|
45
|
+
if (!controller || !controller.isViewLoaded || !controller.view.window) {
|
|
46
|
+
return NO;
|
|
47
|
+
}
|
|
48
|
+
if (flushLayout) {
|
|
49
|
+
[controller.view.window layoutIfNeeded];
|
|
50
|
+
[controller.view layoutIfNeeded];
|
|
51
|
+
[controller.rootView layoutIfNeeded];
|
|
52
|
+
}
|
|
53
|
+
return controller.view.window != nil &&
|
|
54
|
+
controller.view.bounds.size.width > 0 &&
|
|
55
|
+
controller.view.bounds.size.height > 0;
|
|
56
|
+
};
|
|
44
57
|
}
|
|
45
58
|
return self;
|
|
46
59
|
}
|
|
47
60
|
|
|
61
|
+
- (BOOL)isNativeManagedLifecycle {
|
|
62
|
+
return NO;
|
|
63
|
+
}
|
|
64
|
+
|
|
48
65
|
- (void)handleReload {
|
|
49
|
-
self
|
|
50
|
-
self.
|
|
51
|
-
self.appearanceEventScheduled = NO;
|
|
52
|
-
self.appearanceEventSent = NO;
|
|
66
|
+
[self cancelPushPrewarm];
|
|
67
|
+
[self.lifecycleStateMachine handleReload];
|
|
53
68
|
}
|
|
54
69
|
|
|
55
70
|
- (void)loadView {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
RCTHost *rctHost = [HBDReactBridgeManager get].rctHost;
|
|
72
|
+
RCTFabricSurface *surface = [rctHost createSurfaceWithModuleName:self.moduleName initialProperties:[self initialPropertiesForSurface]];
|
|
73
|
+
HBDRootView *rootView = [[HBDRootView alloc] initWithSurface:(id)surface];
|
|
59
74
|
self.rootView = rootView;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
76
|
+
self.view = [[UIView alloc] init];
|
|
77
|
+
self.view.backgroundColor = [self hbd_globalStyle].screenBackgroundColor;
|
|
78
|
+
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
64
79
|
[self syncRootViewBackgroundColor];
|
|
65
80
|
[self.view addSubview:rootView];
|
|
81
|
+
[self.lifecycleStateMachine markMounted];
|
|
66
82
|
RCTLogInfo(@"[Navigation] 加载页面 %@", self.moduleName);
|
|
67
83
|
}
|
|
68
84
|
|
|
@@ -72,10 +88,17 @@
|
|
|
72
88
|
[self updateReactViewFrame];
|
|
73
89
|
}
|
|
74
90
|
|
|
91
|
+
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
|
92
|
+
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
|
93
|
+
if (!self.isViewLoaded || !self.rootView || !coordinator) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
[self.rootView prepareForSizeTransitionWithCoordinator:coordinator];
|
|
97
|
+
}
|
|
98
|
+
|
|
75
99
|
- (void)viewDidLayoutSubviews {
|
|
76
|
-
[super viewDidLayoutSubviews];
|
|
77
100
|
[self updateReactViewFrame];
|
|
78
|
-
[
|
|
101
|
+
[super viewDidLayoutSubviews];
|
|
79
102
|
}
|
|
80
103
|
|
|
81
104
|
- (void)updateReactViewFrame {
|
|
@@ -94,119 +117,210 @@
|
|
|
94
117
|
} else {
|
|
95
118
|
props = [@{} mutableCopy];
|
|
96
119
|
}
|
|
97
|
-
props[@"sceneId"] = self.
|
|
120
|
+
props[@"sceneId"] = self.hbd_sceneId;
|
|
98
121
|
return props;
|
|
99
122
|
}
|
|
100
123
|
|
|
101
|
-
- (
|
|
102
|
-
[
|
|
103
|
-
if ([
|
|
104
|
-
|
|
124
|
+
- (NSDictionary *)initialPropertiesForSurface {
|
|
125
|
+
NSMutableDictionary *props = [[self propsWithSceneId] mutableCopy];
|
|
126
|
+
if (props[@"initialMetrics"] == nil && [self hbd_globalStyle].injectInitialMetrics) {
|
|
127
|
+
NSDictionary *initialMetrics = [self buildInitialMetrics];
|
|
128
|
+
if (initialMetrics) {
|
|
129
|
+
props[@"initialMetrics"] = initialMetrics;
|
|
130
|
+
}
|
|
105
131
|
}
|
|
132
|
+
return props;
|
|
106
133
|
}
|
|
107
134
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (!self.firstRenderCompleted || !self.viewAppeared || self.appearanceEventSent ||
|
|
113
|
-
self.appearanceEventScheduled || !self.isViewLoaded || !self.view.window ||
|
|
114
|
-
self.view.bounds.size.width <= 0 || self.view.bounds.size.height <= 0) {
|
|
115
|
-
return;
|
|
135
|
+
- (BOOL)isInsideDrawerMenu {
|
|
136
|
+
HBDDrawerController *drawer = [self hbd_drawerController];
|
|
137
|
+
if (!drawer || !drawer.menuController) {
|
|
138
|
+
return NO;
|
|
116
139
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
HBDReactViewController *controller = weakSelf;
|
|
122
|
-
if (!controller || controller.appearanceEventGeneration != generation) {
|
|
123
|
-
return;
|
|
140
|
+
UIViewController *current = self;
|
|
141
|
+
while (current != nil) {
|
|
142
|
+
if (current == drawer.menuController) {
|
|
143
|
+
return YES;
|
|
124
144
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
129
|
-
HBDReactViewController *current = weakSelf;
|
|
130
|
-
if (!current || current.appearanceEventGeneration != generation) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
current.appearanceEventScheduled = NO;
|
|
134
|
-
if (!current.firstRenderCompleted || !current.viewAppeared ||
|
|
135
|
-
current.appearanceEventSent || !current.view.window ||
|
|
136
|
-
current.view.bounds.size.width <= 0 || current.view.bounds.size.height <= 0) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
current.appearanceEventSent = YES;
|
|
140
|
-
[current emitAppearEvent];
|
|
141
|
-
});
|
|
142
|
-
});
|
|
145
|
+
current = current.parentViewController;
|
|
146
|
+
}
|
|
147
|
+
return NO;
|
|
143
148
|
}
|
|
144
149
|
|
|
145
|
-
- (
|
|
146
|
-
|
|
150
|
+
- (BOOL)isFullscreenModalPresentationStyle:(UIModalPresentationStyle)style {
|
|
151
|
+
return style == UIModalPresentationFullScreen ||
|
|
152
|
+
style == UIModalPresentationOverFullScreen ||
|
|
153
|
+
style == UIModalPresentationCurrentContext ||
|
|
154
|
+
style == UIModalPresentationOverCurrentContext;
|
|
147
155
|
}
|
|
148
156
|
|
|
149
|
-
- (
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
- (BOOL)canUseCurrentWindowGeometry {
|
|
158
|
+
// Tab 根页与 Drawer 侧栏容器不按全屏窗口几何预热或注入,避免与 TabBar / 非全屏尺寸产生首帧偏差。
|
|
159
|
+
if (self.tabBarController != nil || self.options[@"tabItem"] != nil || [self isInsideDrawerMenu]) {
|
|
160
|
+
return NO;
|
|
161
|
+
}
|
|
162
|
+
BOOL isPresentedScene = self.presentingViewController != nil ||
|
|
163
|
+
self.navigationController.presentingViewController != nil ||
|
|
164
|
+
self.hbd_presentingSceneId.length > 0 ||
|
|
165
|
+
self.navigationController.hbd_presentingSceneId.length > 0;
|
|
166
|
+
if (isPresentedScene) {
|
|
167
|
+
UIViewController *host = self.navigationController ?: self;
|
|
168
|
+
if (![self isFullscreenModalPresentationStyle:host.modalPresentationStyle] &&
|
|
169
|
+
![self isFullscreenModalPresentationStyle:self.modalPresentationStyle]) {
|
|
170
|
+
return NO;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
152
173
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
self
|
|
156
|
-
|
|
157
|
-
if (self.appearanceEventSent) {
|
|
158
|
-
self.appearanceEventSent = NO;
|
|
159
|
-
[self emitDisappearEvent];
|
|
174
|
+
HBDOrientationCoordinator *coordinator = [HBDOrientationCoordinator shared];
|
|
175
|
+
UIWindow *window = [coordinator windowForViewController:self];
|
|
176
|
+
if (!window || ![coordinator isWindowOrientationCompatibleForViewController:self window:window]) {
|
|
177
|
+
return NO;
|
|
160
178
|
}
|
|
179
|
+
|
|
180
|
+
UIWindowScene *windowScene = window.windowScene;
|
|
181
|
+
if (!windowScene) {
|
|
182
|
+
return NO;
|
|
183
|
+
}
|
|
184
|
+
BOOL currentStatusHidden = windowScene.statusBarManager.statusBarHidden;
|
|
185
|
+
BOOL inheritsStatusBar = (self.modalPresentationStyle == UIModalPresentationOverFullScreen &&
|
|
186
|
+
self.options[@"statusBarHidden"] == nil);
|
|
187
|
+
if (!inheritsStatusBar && currentStatusHidden != [self prefersStatusBarHidden]) {
|
|
188
|
+
return NO;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return YES;
|
|
161
192
|
}
|
|
162
193
|
|
|
163
|
-
- (
|
|
164
|
-
[
|
|
165
|
-
|
|
166
|
-
if (coordinator && !coordinator.interactive) {
|
|
167
|
-
self.viewAppeared = YES;
|
|
168
|
-
[self scheduleAppearEventAfterLayout];
|
|
194
|
+
- (nullable NSDictionary *)buildInitialMetrics {
|
|
195
|
+
if (![self canUseCurrentWindowGeometry]) {
|
|
196
|
+
return nil;
|
|
169
197
|
}
|
|
198
|
+
|
|
199
|
+
UIWindow *window = [[HBDOrientationCoordinator shared] windowForViewController:self];
|
|
200
|
+
if (!window) {
|
|
201
|
+
return nil;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
UIEdgeInsets insets = window.safeAreaInsets;
|
|
205
|
+
CGRect frame = window.bounds;
|
|
206
|
+
return @{
|
|
207
|
+
@"insets": @{
|
|
208
|
+
@"top": @(insets.top),
|
|
209
|
+
@"right": @(insets.right),
|
|
210
|
+
@"bottom": @(insets.bottom),
|
|
211
|
+
@"left": @(insets.left),
|
|
212
|
+
},
|
|
213
|
+
@"frame": @{
|
|
214
|
+
@"x": @(frame.origin.x),
|
|
215
|
+
@"y": @(frame.origin.y),
|
|
216
|
+
@"width": @(frame.size.width),
|
|
217
|
+
@"height": @(frame.size.height),
|
|
218
|
+
},
|
|
219
|
+
};
|
|
170
220
|
}
|
|
171
221
|
|
|
172
|
-
- (void)
|
|
173
|
-
[super
|
|
174
|
-
|
|
175
|
-
|
|
222
|
+
- (void)setAppProperties:(NSDictionary *)props {
|
|
223
|
+
[super setAppProperties:props];
|
|
224
|
+
if ([HBDReactBridgeManager get].isReactModuleRegisterCompleted) {
|
|
225
|
+
self.rootView.appProperties = [self propsWithSceneId];
|
|
226
|
+
}
|
|
176
227
|
}
|
|
177
228
|
|
|
178
|
-
- (
|
|
179
|
-
[
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
229
|
+
- (BOOL)prepareForAnimatedPushWithBounds:(CGRect)bounds timeout:(NSTimeInterval)timeout completion:(dispatch_block_t)completion {
|
|
230
|
+
if (![self hbd_globalStyle].prewarmPush || !completion || CGRectIsEmpty(bounds) || ![self canUseCurrentWindowGeometry]) {
|
|
231
|
+
return NO;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
self.pushPrewarmGeneration += 1;
|
|
235
|
+
NSUInteger generation = self.pushPrewarmGeneration;
|
|
236
|
+
self.pushPrewarmCompletion = [completion copy];
|
|
237
|
+
|
|
238
|
+
[[HBDReactBridgeManager get] registerPrewarmingViewController:self];
|
|
239
|
+
|
|
240
|
+
// 提前加载并给 HBDRootView 真实尺寸,让 Fabric 在离屏阶段完成首帧挂载,避免右滑入场前半段空白。
|
|
241
|
+
[self loadViewIfNeeded];
|
|
242
|
+
self.view.frame = bounds;
|
|
243
|
+
[self updateReactViewFrame];
|
|
244
|
+
[self.view layoutIfNeeded];
|
|
245
|
+
[self.rootView layoutIfNeeded];
|
|
246
|
+
|
|
247
|
+
if (self.lifecycleStateMachine.isFirstRendered) {
|
|
248
|
+
__weak HBDReactViewController *weakSelf = self;
|
|
249
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
250
|
+
HBDReactViewController *strongSelf = weakSelf;
|
|
251
|
+
if (strongSelf && strongSelf.pushPrewarmGeneration == generation) {
|
|
252
|
+
[strongSelf finishPushPrewarmWait];
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return YES;
|
|
183
256
|
}
|
|
257
|
+
|
|
258
|
+
NSTimeInterval safeTimeout = timeout > 0 ? timeout : 0.18;
|
|
259
|
+
__weak HBDReactViewController *weakSelf = self;
|
|
260
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(safeTimeout * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
261
|
+
HBDReactViewController *strongSelf = weakSelf;
|
|
262
|
+
if (strongSelf && strongSelf.pushPrewarmGeneration == generation) {
|
|
263
|
+
[strongSelf finishPushPrewarmWait];
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
return YES;
|
|
184
267
|
}
|
|
185
268
|
|
|
186
|
-
- (void)
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
|
|
269
|
+
- (void)finishPushPrewarmWait {
|
|
270
|
+
dispatch_block_t completion = self.pushPrewarmCompletion;
|
|
271
|
+
if (!completion) {
|
|
272
|
+
return;
|
|
190
273
|
}
|
|
274
|
+
self.pushPrewarmCompletion = nil;
|
|
275
|
+
self.pushPrewarmGeneration += 1;
|
|
276
|
+
[[HBDReactBridgeManager get] unregisterPrewarmingViewController:self];
|
|
277
|
+
if (self.isViewLoaded && self.rootView) {
|
|
278
|
+
[self.view layoutIfNeeded];
|
|
279
|
+
[self.rootView layoutIfNeeded];
|
|
280
|
+
}
|
|
281
|
+
completion();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
- (void)cancelPushPrewarm {
|
|
285
|
+
self.pushPrewarmCompletion = nil;
|
|
286
|
+
self.pushPrewarmGeneration += 1;
|
|
287
|
+
[[HBDReactBridgeManager get] unregisterPrewarmingViewController:self];
|
|
191
288
|
}
|
|
192
289
|
|
|
193
290
|
- (void)signalFirstRenderComplete {
|
|
194
|
-
|
|
195
|
-
|
|
291
|
+
[self.lifecycleStateMachine markFirstRenderComplete];
|
|
292
|
+
if (self.pushPrewarmCompletion) {
|
|
293
|
+
NSUInteger generation = self.pushPrewarmGeneration;
|
|
294
|
+
__weak HBDReactViewController *weakSelf = self;
|
|
295
|
+
// 等待当前主队列上的 Fabric 挂载与 HBDRootView surfaceView 挂载完成,再启动 push 动画。
|
|
296
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
297
|
+
HBDReactViewController *strongSelf = weakSelf;
|
|
298
|
+
if (strongSelf && strongSelf.pushPrewarmGeneration == generation) {
|
|
299
|
+
[strongSelf finishPushPrewarmWait];
|
|
300
|
+
}
|
|
301
|
+
});
|
|
196
302
|
}
|
|
197
|
-
self.firstRenderCompleted = YES;
|
|
198
|
-
[self scheduleAppearEventAfterLayout];
|
|
199
303
|
}
|
|
200
304
|
|
|
201
|
-
- (void)
|
|
202
|
-
[super
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
@"resultData": RCTNullIfNil(data),
|
|
207
|
-
@"sceneId": self.sceneId,
|
|
208
|
-
}];
|
|
305
|
+
- (void)updateOptions:(NSDictionary *)options {
|
|
306
|
+
[super updateOptions:options];
|
|
307
|
+
if (options[@"screenBackgroundColor"] && [self isViewLoaded]) {
|
|
308
|
+
[self syncRootViewBackgroundColor];
|
|
309
|
+
}
|
|
209
310
|
}
|
|
210
311
|
|
|
312
|
+
- (void)hbd_didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
|
|
313
|
+
[super hbd_didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
314
|
+
HBDNativeEvent *event = [HBDNativeEvent getInstance];
|
|
315
|
+
if (!event) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
[event emitOnResult:@{
|
|
319
|
+
@"requestCode": @(requestCode),
|
|
320
|
+
@"resultCode": @(resultCode),
|
|
321
|
+
@"resultData": RCTNullIfNil(data),
|
|
322
|
+
@"sceneId": self.hbd_sceneId,
|
|
323
|
+
}];
|
|
324
|
+
}
|
|
211
325
|
|
|
212
326
|
@end
|
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
#import <UIKit/UIKit.h>
|
|
2
|
+
#import "HBDTabBarRenderer.h"
|
|
3
|
+
|
|
4
|
+
@class HBDGlobalStyle;
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
2
7
|
|
|
3
8
|
@interface HBDTabBarController : UITabBarController
|
|
4
9
|
|
|
10
|
+
@property(nonatomic, strong, nullable) id<HBDTabBarRenderer> tabBarRenderer;
|
|
11
|
+
|
|
12
|
+
- (void)applyGlobalStyle:(HBDGlobalStyle *)style;
|
|
13
|
+
|
|
5
14
|
- (void)updateTabBar:(NSDictionary *)options;
|
|
6
15
|
|
|
7
16
|
- (void)setTabItem:(NSArray<NSDictionary *> *)options;
|
|
8
17
|
|
|
18
|
+
- (NSArray<NSString *> *)tabKeys;
|
|
19
|
+
|
|
20
|
+
- (NSInteger)indexForTabKey:(NSString *)tabKey;
|
|
21
|
+
|
|
9
22
|
@end
|
|
23
|
+
|
|
24
|
+
NS_ASSUME_NONNULL_END
|