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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#import "HBDNavigationController.h"
|
|
2
2
|
|
|
3
3
|
#import "HBDViewController.h"
|
|
4
|
+
#import "HBDOrientationCoordinator.h"
|
|
4
5
|
|
|
5
6
|
#import <React/RCTLog.h>
|
|
6
7
|
#import <React/RCTUtils.h>
|
|
@@ -8,6 +9,7 @@
|
|
|
8
9
|
@interface HBDNavigationController () <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
|
|
9
10
|
|
|
10
11
|
@property(nonatomic, weak) UIViewController *poppingViewController;
|
|
12
|
+
@property(nonatomic, assign) NSInteger poppingRequestCode;
|
|
11
13
|
@property(nonatomic, strong) UIScreenEdgePanGestureRecognizer *navigationPopGestureRecognizer;
|
|
12
14
|
|
|
13
15
|
- (UIGestureRecognizer *)superInteractivePopGestureRecognizer;
|
|
@@ -101,10 +103,11 @@
|
|
|
101
103
|
|
|
102
104
|
if (self.viewControllers.count > 1) {
|
|
103
105
|
UIViewController *topVC = self.topViewController;
|
|
104
|
-
if ([topVC isKindOfClass:[HBDViewController class]] &&
|
|
106
|
+
if ([topVC isKindOfClass:[HBDViewController class]] &&
|
|
107
|
+
[[HBDOrientationCoordinator shared] resolvedOrientationForViewController:(HBDViewController *)topVC] == HBDScreenOrientationLandscape) {
|
|
105
108
|
return NO;
|
|
106
109
|
}
|
|
107
|
-
return topVC.
|
|
110
|
+
return topVC.hbd_backInteractive;
|
|
108
111
|
}
|
|
109
112
|
return NO;
|
|
110
113
|
}
|
|
@@ -132,16 +135,19 @@
|
|
|
132
135
|
[self hideSystemNavigationBar];
|
|
133
136
|
|
|
134
137
|
UIViewController *poppingVC = self.poppingViewController;
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
NSInteger requestCode = self.poppingRequestCode;
|
|
139
|
+
if (poppingVC && poppingVC != viewController) {
|
|
140
|
+
[viewController hbd_didReceiveResultCode:poppingVC.hbd_resultCode resultData:poppingVC.hbd_resultData requestCode:requestCode];
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
self.poppingViewController = nil;
|
|
144
|
+
self.poppingRequestCode = 0;
|
|
140
145
|
}
|
|
141
146
|
|
|
142
147
|
- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
|
|
143
148
|
if (self.childViewControllers.count > 1) {
|
|
144
149
|
self.poppingViewController = self.topViewController;
|
|
150
|
+
self.poppingRequestCode = self.topViewController.hbd_requestCode;
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
return [super popViewControllerAnimated:animated];
|
|
@@ -150,6 +156,12 @@
|
|
|
150
156
|
- (NSArray<UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated {
|
|
151
157
|
if (self.childViewControllers.count > 1) {
|
|
152
158
|
self.poppingViewController = self.topViewController;
|
|
159
|
+
NSUInteger targetIndex = [self.childViewControllers indexOfObject:viewController];
|
|
160
|
+
if (targetIndex != NSNotFound && targetIndex + 1 < self.childViewControllers.count) {
|
|
161
|
+
self.poppingRequestCode = self.childViewControllers[targetIndex + 1].hbd_requestCode;
|
|
162
|
+
} else {
|
|
163
|
+
self.poppingRequestCode = self.topViewController.hbd_requestCode;
|
|
164
|
+
}
|
|
153
165
|
}
|
|
154
166
|
|
|
155
167
|
return [super popToViewController:viewController animated:animated];
|
|
@@ -158,6 +170,7 @@
|
|
|
158
170
|
- (NSArray<UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated {
|
|
159
171
|
if (self.childViewControllers.count > 1) {
|
|
160
172
|
self.poppingViewController = self.topViewController;
|
|
173
|
+
self.poppingRequestCode = self.childViewControllers[1].hbd_requestCode;
|
|
161
174
|
}
|
|
162
175
|
|
|
163
176
|
return [super popToRootViewControllerAnimated:animated];
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
#import "HBDReactViewController.h"
|
|
2
2
|
|
|
3
|
+
#import "HBDGlobalStyle.h"
|
|
4
|
+
#import "HBDNativeEvent.h"
|
|
3
5
|
#import "HBDReactBridgeManager.h"
|
|
4
6
|
#import "HBDRootView.h"
|
|
5
7
|
#import "HBDUtils.h"
|
|
6
|
-
#import "HBDNativeEvent.h"
|
|
7
|
-
#import "GlobalStyle.h"
|
|
8
8
|
|
|
9
9
|
#import <React/RCTConvert.h>
|
|
10
10
|
|
|
11
11
|
@interface HBDReactViewController ()
|
|
12
12
|
|
|
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
13
|
@property(nonatomic, strong, readwrite) HBDRootView *rootView;
|
|
19
14
|
|
|
20
15
|
@end
|
|
21
16
|
|
|
22
|
-
@implementation HBDReactViewController
|
|
23
|
-
NSArray *_reactViewConstraints;
|
|
24
|
-
}
|
|
17
|
+
@implementation HBDReactViewController
|
|
25
18
|
|
|
26
19
|
- (void)syncRootViewBackgroundColor {
|
|
27
20
|
if (!self.rootView) {
|
|
@@ -33,36 +26,53 @@
|
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
- (void)dealloc {
|
|
36
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self name:
|
|
29
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:HBDReactBridgeWillReloadNotification object:nil];
|
|
37
30
|
RCTLogInfo(@"[Navigation] 销毁页面 %@", self.moduleName);
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
- (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options {
|
|
41
34
|
if (self = [super initWithModuleName:moduleName props:props options:options]) {
|
|
42
35
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleReload)
|
|
43
|
-
name:
|
|
36
|
+
name:HBDReactBridgeWillReloadNotification object:nil];
|
|
37
|
+
__weak HBDReactViewController *weakSelf = self;
|
|
38
|
+
self.lifecycleStateMachine.readyForVisibleCheck = ^BOOL(BOOL flushLayout) {
|
|
39
|
+
HBDReactViewController *controller = weakSelf;
|
|
40
|
+
if (!controller || !controller.isViewLoaded || !controller.view.window) {
|
|
41
|
+
return NO;
|
|
42
|
+
}
|
|
43
|
+
if (flushLayout) {
|
|
44
|
+
[controller.view.window layoutIfNeeded];
|
|
45
|
+
[controller.view layoutIfNeeded];
|
|
46
|
+
[controller.rootView layoutIfNeeded];
|
|
47
|
+
}
|
|
48
|
+
return controller.view.window != nil &&
|
|
49
|
+
controller.view.bounds.size.width > 0 &&
|
|
50
|
+
controller.view.bounds.size.height > 0;
|
|
51
|
+
};
|
|
44
52
|
}
|
|
45
53
|
return self;
|
|
46
54
|
}
|
|
47
55
|
|
|
56
|
+
- (BOOL)isNativeManagedLifecycle {
|
|
57
|
+
return NO;
|
|
58
|
+
}
|
|
59
|
+
|
|
48
60
|
- (void)handleReload {
|
|
49
|
-
self.
|
|
50
|
-
self.appearanceEventGeneration += 1;
|
|
51
|
-
self.appearanceEventScheduled = NO;
|
|
52
|
-
self.appearanceEventSent = NO;
|
|
61
|
+
[self.lifecycleStateMachine handleReload];
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
- (void)loadView {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
RCTHost *rctHost = [HBDReactBridgeManager get].rctHost;
|
|
66
|
+
RCTFabricSurface *surface = [rctHost createSurfaceWithModuleName:self.moduleName initialProperties:[self propsWithSceneId]];
|
|
67
|
+
HBDRootView *rootView = [[HBDRootView alloc] initWithSurface:(id)surface];
|
|
59
68
|
self.rootView = rootView;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
70
|
+
self.view = [[UIView alloc] init];
|
|
71
|
+
self.view.backgroundColor = [self hbd_globalStyle].screenBackgroundColor;
|
|
72
|
+
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
64
73
|
[self syncRootViewBackgroundColor];
|
|
65
74
|
[self.view addSubview:rootView];
|
|
75
|
+
[self.lifecycleStateMachine markMounted];
|
|
66
76
|
RCTLogInfo(@"[Navigation] 加载页面 %@", self.moduleName);
|
|
67
77
|
}
|
|
68
78
|
|
|
@@ -72,10 +82,17 @@
|
|
|
72
82
|
[self updateReactViewFrame];
|
|
73
83
|
}
|
|
74
84
|
|
|
85
|
+
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
|
86
|
+
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
|
87
|
+
if (!self.isViewLoaded || !self.rootView || !coordinator) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
[self.rootView prepareForSizeTransitionWithCoordinator:coordinator];
|
|
91
|
+
}
|
|
92
|
+
|
|
75
93
|
- (void)viewDidLayoutSubviews {
|
|
76
|
-
[super viewDidLayoutSubviews];
|
|
77
94
|
[self updateReactViewFrame];
|
|
78
|
-
[
|
|
95
|
+
[super viewDidLayoutSubviews];
|
|
79
96
|
}
|
|
80
97
|
|
|
81
98
|
- (void)updateReactViewFrame {
|
|
@@ -94,7 +111,7 @@
|
|
|
94
111
|
} else {
|
|
95
112
|
props = [@{} mutableCopy];
|
|
96
113
|
}
|
|
97
|
-
props[@"sceneId"] = self.
|
|
114
|
+
props[@"sceneId"] = self.hbd_sceneId;
|
|
98
115
|
return props;
|
|
99
116
|
}
|
|
100
117
|
|
|
@@ -105,108 +122,29 @@
|
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
124
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// safe-area measurements are enqueued before visibility-dependent content.
|
|
111
|
-
- (void)scheduleAppearEventAfterLayout {
|
|
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;
|
|
116
|
-
}
|
|
117
|
-
self.appearanceEventScheduled = YES;
|
|
118
|
-
NSUInteger generation = self.appearanceEventGeneration;
|
|
119
|
-
__weak HBDReactViewController *weakSelf = self;
|
|
120
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
121
|
-
HBDReactViewController *controller = weakSelf;
|
|
122
|
-
if (!controller || controller.appearanceEventGeneration != generation) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
[controller.view.window layoutIfNeeded];
|
|
126
|
-
[controller.view layoutIfNeeded];
|
|
127
|
-
[controller.rootView layoutIfNeeded];
|
|
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
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
- (void)emitAppearEvent {
|
|
146
|
-
[[HBDNativeEvent getInstance] emitOnComponentAppear:@{@"sceneId": self.sceneId}];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
- (void)emitDisappearEvent {
|
|
150
|
-
[[HBDNativeEvent getInstance] emitOnComponentDisappear:@{@"sceneId": self.sceneId}];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
- (void)finishAppearance {
|
|
154
|
-
self.viewAppeared = NO;
|
|
155
|
-
self.appearanceEventGeneration += 1;
|
|
156
|
-
self.appearanceEventScheduled = NO;
|
|
157
|
-
if (self.appearanceEventSent) {
|
|
158
|
-
self.appearanceEventSent = NO;
|
|
159
|
-
[self emitDisappearEvent];
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
- (void)viewWillAppear:(BOOL)animated {
|
|
164
|
-
[super viewWillAppear:animated];
|
|
165
|
-
id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
166
|
-
if (coordinator && !coordinator.interactive) {
|
|
167
|
-
self.viewAppeared = YES;
|
|
168
|
-
[self scheduleAppearEventAfterLayout];
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
- (void)viewDidAppear:(BOOL)animated {
|
|
173
|
-
[super viewDidAppear:animated];
|
|
174
|
-
self.viewAppeared = YES;
|
|
175
|
-
[self scheduleAppearEventAfterLayout];
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
- (void)viewWillDisappear:(BOOL)animated {
|
|
179
|
-
[super viewWillDisappear:animated];
|
|
180
|
-
id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
|
|
181
|
-
if (coordinator && !coordinator.interactive && self.viewAppeared) {
|
|
182
|
-
[self finishAppearance];
|
|
183
|
-
}
|
|
125
|
+
- (void)signalFirstRenderComplete {
|
|
126
|
+
[self.lifecycleStateMachine markFirstRenderComplete];
|
|
184
127
|
}
|
|
185
128
|
|
|
186
|
-
- (void)
|
|
187
|
-
[super
|
|
188
|
-
if (self
|
|
189
|
-
[self
|
|
129
|
+
- (void)updateOptions:(NSDictionary *)options {
|
|
130
|
+
[super updateOptions:options];
|
|
131
|
+
if (options[@"screenBackgroundColor"] && [self isViewLoaded]) {
|
|
132
|
+
[self syncRootViewBackgroundColor];
|
|
190
133
|
}
|
|
191
134
|
}
|
|
192
135
|
|
|
193
|
-
- (void)
|
|
194
|
-
|
|
136
|
+
- (void)hbd_didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
|
|
137
|
+
[super hbd_didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
138
|
+
HBDNativeEvent *event = [HBDNativeEvent getInstance];
|
|
139
|
+
if (!event) {
|
|
195
140
|
return;
|
|
196
141
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
[[HBDNativeEvent getInstance] emitOnResult:@{
|
|
204
|
-
@"requestCode": @(requestCode),
|
|
205
|
-
@"resultCode": @(resultCode),
|
|
206
|
-
@"resultData": RCTNullIfNil(data),
|
|
207
|
-
@"sceneId": self.sceneId,
|
|
208
|
-
}];
|
|
142
|
+
[event emitOnResult:@{
|
|
143
|
+
@"requestCode": @(requestCode),
|
|
144
|
+
@"resultCode": @(resultCode),
|
|
145
|
+
@"resultData": RCTNullIfNil(data),
|
|
146
|
+
@"sceneId": self.hbd_sceneId,
|
|
147
|
+
}];
|
|
209
148
|
}
|
|
210
149
|
|
|
211
|
-
|
|
212
150
|
@end
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
#import <UIKit/UIKit.h>
|
|
2
2
|
|
|
3
|
+
@class HBDGlobalStyle;
|
|
4
|
+
|
|
3
5
|
@interface HBDTabBarController : UITabBarController
|
|
4
6
|
|
|
7
|
+
- (void)applyGlobalStyle:(HBDGlobalStyle *)style;
|
|
8
|
+
|
|
5
9
|
- (void)updateTabBar:(NSDictionary *)options;
|
|
6
10
|
|
|
7
11
|
- (void)setTabItem:(NSArray<NSDictionary *> *)options;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#import "HBDTabBarController.h"
|
|
2
2
|
|
|
3
|
+
#import "HBDFadeAnimation.h"
|
|
4
|
+
#import "HBDGlobalStyle.h"
|
|
3
5
|
#import "HBDReactViewController.h"
|
|
4
6
|
#import "HBDUtils.h"
|
|
5
|
-
#import "
|
|
7
|
+
#import "UIViewController+HBD.h"
|
|
6
8
|
|
|
7
9
|
#import <React/RCTLog.h>
|
|
8
10
|
|
|
9
|
-
|
|
10
11
|
@interface HBDTabBarController () <UITabBarControllerDelegate>
|
|
11
12
|
|
|
12
13
|
@end
|
|
@@ -29,35 +30,50 @@
|
|
|
29
30
|
[super viewDidLoad];
|
|
30
31
|
self.definesPresentationContext = NO;
|
|
31
32
|
self.delegate = self;
|
|
33
|
+
[self applyGlobalStyle:[self hbd_globalStyle]];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)applyGlobalStyle:(HBDGlobalStyle *)style {
|
|
37
|
+
if (!style) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
[style applyToTabBar:self.tabBar];
|
|
41
|
+
for (UIViewController *tab in self.viewControllers) {
|
|
42
|
+
HBDViewController *hbdvc = [self tabViewController:tab];
|
|
43
|
+
[hbdvc applyTabBarOptions:hbdvc.options];
|
|
44
|
+
}
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
- (void)setTabItem:(NSArray<NSDictionary *> *)options {
|
|
35
48
|
for (NSDictionary *option in options) {
|
|
36
|
-
NSUInteger index = (NSUInteger)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
NSUInteger index = (NSUInteger)(option[@"index"] ? [option[@"index"] integerValue] : 0);
|
|
50
|
+
if (index >= self.viewControllers.count) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
UIViewController *tab = self.viewControllers[index];
|
|
54
|
+
HBDViewController *hbdvc = [self tabViewController:tab];
|
|
55
|
+
[hbdvc updateTabBarItem:option];
|
|
40
56
|
}
|
|
41
57
|
}
|
|
42
58
|
|
|
43
59
|
- (HBDViewController *)tabViewController:(UIViewController *)vc {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
if ([vc isKindOfClass:[UINavigationController class]]) {
|
|
61
|
+
UINavigationController *nav = (UINavigationController *)vc;
|
|
62
|
+
return [self tabViewController:[nav.viewControllers firstObject]];
|
|
63
|
+
} else if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
64
|
+
return (HBDViewController *)vc;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return nil;
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
- (void)updateTabBar:(NSDictionary *)options {
|
|
55
71
|
UITabBar *tabBar = self.tabBar;
|
|
56
72
|
NSString *tabBarBackgroundColor = options[@"tabBarBackgroundColor"];
|
|
57
73
|
if (tabBarBackgroundColor) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
if (@available(iOS 26.0, *)) {
|
|
75
|
+
//
|
|
76
|
+
} else {
|
|
61
77
|
[tabBar standardAppearance].backgroundImage = [HBDUtils imageWithColor:[HBDUtils colorWithHexString:tabBarBackgroundColor]];
|
|
62
78
|
[tabBar scrollEdgeAppearance].backgroundImage = [HBDUtils imageWithColor:[HBDUtils colorWithHexString:tabBarBackgroundColor]];
|
|
63
79
|
}
|
|
@@ -79,37 +95,37 @@
|
|
|
79
95
|
NSString *tabBarItemSelectedColor = options[@"tabBarItemSelectedColor"];
|
|
80
96
|
NSString *tabBarItemNormalColor = options[@"tabBarItemNormalColor"];
|
|
81
97
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
[hbdvc updateTabBarItem:hbdvc.options];
|
|
104
|
-
}
|
|
98
|
+
if (tabBarItemSelectedColor) {
|
|
99
|
+
if (!tabBarItemNormalColor) {
|
|
100
|
+
tabBarItemNormalColor = @"#666666";
|
|
101
|
+
}
|
|
102
|
+
UITabBarItemAppearance *tabBarItem = [UITabBarItemAppearance new];
|
|
103
|
+
tabBarItem.normal.titleTextAttributes = @{
|
|
104
|
+
NSForegroundColorAttributeName: [HBDUtils colorWithHexString:tabBarItemNormalColor],
|
|
105
|
+
};
|
|
106
|
+
tabBarItem.normal.iconColor = [HBDUtils colorWithHexString:tabBarItemNormalColor];
|
|
107
|
+
tabBarItem.selected.titleTextAttributes = @{
|
|
108
|
+
NSForegroundColorAttributeName: [HBDUtils colorWithHexString:tabBarItemSelectedColor],
|
|
109
|
+
};
|
|
110
|
+
tabBarItem.selected.iconColor = [HBDUtils colorWithHexString:tabBarItemSelectedColor];
|
|
111
|
+
tabBar.standardAppearance.stackedLayoutAppearance = tabBarItem;
|
|
112
|
+
tabBar.scrollEdgeAppearance.stackedLayoutAppearance = tabBarItem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (UIViewController *tab in self.childViewControllers) {
|
|
116
|
+
HBDViewController *hbdvc = [self tabViewController:tab];
|
|
117
|
+
[hbdvc applyTabBarOptions:hbdvc.options];
|
|
118
|
+
}
|
|
105
119
|
}
|
|
106
120
|
|
|
107
|
-
- (void)
|
|
108
|
-
[super
|
|
121
|
+
- (void)hbd_didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
|
|
122
|
+
[super hbd_didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
109
123
|
}
|
|
110
124
|
|
|
111
125
|
- (void)setSelectedIndex:(NSUInteger)selectedIndex {
|
|
112
|
-
|
|
126
|
+
if (selectedIndex < self.viewControllers.count) {
|
|
127
|
+
[self setSelectedViewController:self.viewControllers[selectedIndex]];
|
|
128
|
+
}
|
|
113
129
|
}
|
|
114
130
|
|
|
115
131
|
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
|
|
@@ -117,7 +133,6 @@
|
|
|
117
133
|
}
|
|
118
134
|
|
|
119
135
|
- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
|
|
120
|
-
|
|
121
136
|
if (toVC.viewLoaded) {
|
|
122
137
|
return nil;
|
|
123
138
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#import "UIViewController+HBD.h"
|
|
2
|
+
#import "HBDOrientationCoordinator.h"
|
|
3
|
+
#import "HBDSceneLifecycleStateMachine.h"
|
|
2
4
|
|
|
3
5
|
#import <UIKit/UIKit.h>
|
|
4
6
|
|
|
@@ -8,15 +10,20 @@
|
|
|
8
10
|
@property(nonatomic, copy, readonly) NSDictionary *props;
|
|
9
11
|
@property(nonatomic, copy, readonly) NSDictionary *options;
|
|
10
12
|
@property(nonatomic, assign, readonly) BOOL animatedTransition;
|
|
11
|
-
@property(nonatomic, assign, readonly)
|
|
13
|
+
@property(nonatomic, assign, readonly) HBDScreenOrientation screenOrientation;
|
|
14
|
+
@property(nonatomic, strong, readonly) HBDSceneLifecycleStateMachine *lifecycleStateMachine;
|
|
12
15
|
|
|
13
16
|
- (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options NS_DESIGNATED_INITIALIZER;
|
|
14
17
|
|
|
15
18
|
- (void)setAppProperties:(NSDictionary *)props;
|
|
16
19
|
|
|
17
|
-
- (
|
|
20
|
+
- (BOOL)isNativeManagedLifecycle;
|
|
18
21
|
|
|
19
|
-
- (void)
|
|
22
|
+
- (void)sceneLifecycleDidChangeFromState:(HBDSceneLifecycleState)prevState toState:(HBDSceneLifecycleState)newState;
|
|
23
|
+
|
|
24
|
+
- (void)updateOptions:(NSDictionary *)options;
|
|
25
|
+
|
|
26
|
+
- (void)applyTabBarOptions:(NSDictionary *)options;
|
|
20
27
|
|
|
21
28
|
- (void)updateTabBarItem:(NSDictionary *)options;
|
|
22
29
|
|