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,14 +1,20 @@
|
|
|
1
1
|
#import "HBDTabBarController.h"
|
|
2
2
|
|
|
3
|
+
#import "HBDFadeAnimation.h"
|
|
4
|
+
#import "HBDGlobalStyle.h"
|
|
5
|
+
#import "HBDNativeEvent.h"
|
|
6
|
+
#import "HBDReactBridgeManager.h"
|
|
3
7
|
#import "HBDReactViewController.h"
|
|
4
8
|
#import "HBDUtils.h"
|
|
5
|
-
#import "
|
|
9
|
+
#import "UIViewController+HBD.h"
|
|
6
10
|
|
|
7
11
|
#import <React/RCTLog.h>
|
|
8
12
|
|
|
9
|
-
|
|
10
13
|
@interface HBDTabBarController () <UITabBarControllerDelegate>
|
|
11
14
|
|
|
15
|
+
@property(nonatomic, assign) BOOL rendererAttached;
|
|
16
|
+
@property(nonatomic, assign) NSUInteger pendingPreviousSelectedIndex;
|
|
17
|
+
|
|
12
18
|
@end
|
|
13
19
|
|
|
14
20
|
@implementation HBDTabBarController
|
|
@@ -29,35 +35,175 @@
|
|
|
29
35
|
[super viewDidLoad];
|
|
30
36
|
self.definesPresentationContext = NO;
|
|
31
37
|
self.delegate = self;
|
|
38
|
+
[self applyGlobalStyle:[self hbd_globalStyle]];
|
|
39
|
+
[self attachRendererIfNeeded];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
- (void)attachRendererIfNeeded {
|
|
43
|
+
if (!self.tabBarRenderer || self.rendererAttached || !self.isViewLoaded) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
self.rendererAttached = YES;
|
|
47
|
+
if (@available(iOS 18.0, *)) {
|
|
48
|
+
[self setTabBarHidden:YES animated:NO];
|
|
49
|
+
} else {
|
|
50
|
+
self.tabBar.hidden = YES;
|
|
51
|
+
}
|
|
52
|
+
self.additionalSafeAreaInsets = UIEdgeInsetsMake(0, 0, self.tabBarRenderer.contentHeight, 0);
|
|
53
|
+
__weak HBDTabBarController *weakSelf = self;
|
|
54
|
+
[self.tabBarRenderer attachToTabBarController:self onSelectTabAtIndex:^(NSUInteger index) {
|
|
55
|
+
HBDTabBarController *strongSelf = weakSelf;
|
|
56
|
+
if (strongSelf && index < strongSelf.viewControllers.count) {
|
|
57
|
+
NSUInteger previousIndex = strongSelf.selectedIndex;
|
|
58
|
+
[strongSelf selectTabAtIndex:index animated:YES];
|
|
59
|
+
[strongSelf emitTabPressAtIndex:index previousIndex:previousIndex];
|
|
60
|
+
}
|
|
61
|
+
}];
|
|
62
|
+
UIView *barView = self.tabBarRenderer.barView;
|
|
63
|
+
if (barView && barView.superview != self.view) {
|
|
64
|
+
[self.view addSubview:barView];
|
|
65
|
+
}
|
|
66
|
+
[self reloadRendererAnimated:NO];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
- (void)setTabBarRenderer:(id<HBDTabBarRenderer>)tabBarRenderer {
|
|
70
|
+
if (_tabBarRenderer == tabBarRenderer) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (_tabBarRenderer.barView.superview == self.view) {
|
|
74
|
+
[_tabBarRenderer.barView removeFromSuperview];
|
|
75
|
+
}
|
|
76
|
+
_tabBarRenderer = tabBarRenderer;
|
|
77
|
+
self.rendererAttached = NO;
|
|
78
|
+
if (self.isViewLoaded) {
|
|
79
|
+
if (tabBarRenderer) {
|
|
80
|
+
[self attachRendererIfNeeded];
|
|
81
|
+
} else {
|
|
82
|
+
self.additionalSafeAreaInsets = UIEdgeInsetsZero;
|
|
83
|
+
if (@available(iOS 18.0, *)) {
|
|
84
|
+
[self setTabBarHidden:NO animated:NO];
|
|
85
|
+
} else {
|
|
86
|
+
self.tabBar.hidden = NO;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
- (void)setViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers animated:(BOOL)animated {
|
|
93
|
+
[super setViewControllers:viewControllers animated:animated];
|
|
94
|
+
[self reloadRendererAnimated:NO];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
- (void)selectTabAtIndex:(NSUInteger)index animated:(BOOL)animated {
|
|
98
|
+
if (index >= self.viewControllers.count) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
BOOL changed = self.selectedIndex != index;
|
|
102
|
+
[super setSelectedViewController:self.viewControllers[index]];
|
|
103
|
+
[self reloadRendererAnimated:animated && changed];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
- (void)reloadRendererAnimated:(BOOL)animated {
|
|
107
|
+
if (!self.tabBarRenderer || !self.rendererAttached) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
NSMutableArray<UITabBarItem *> *items = [NSMutableArray arrayWithCapacity:self.viewControllers.count];
|
|
111
|
+
for (UIViewController *vc in self.viewControllers) {
|
|
112
|
+
[items addObject:vc.tabBarItem ?: [UITabBarItem new]];
|
|
113
|
+
}
|
|
114
|
+
[self.tabBarRenderer reloadItems:items tabKeys:[self tabKeys] selectedIndex:self.selectedIndex animated:animated];
|
|
115
|
+
[self.view setNeedsLayout];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
- (void)viewDidLayoutSubviews {
|
|
119
|
+
[super viewDidLayoutSubviews];
|
|
120
|
+
if (!self.tabBarRenderer || !self.rendererAttached) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
UIView *barView = self.tabBarRenderer.barView;
|
|
124
|
+
if (barView) {
|
|
125
|
+
[self.view bringSubviewToFront:barView];
|
|
126
|
+
}
|
|
127
|
+
if ([self.tabBarRenderer respondsToSelector:@selector(layoutInContainerView:safeAreaFrame:)]) {
|
|
128
|
+
[self.tabBarRenderer layoutInContainerView:self.view safeAreaFrame:self.view.safeAreaLayoutGuide.layoutFrame];
|
|
129
|
+
} else if (barView) {
|
|
130
|
+
CGRect bounds = self.view.bounds;
|
|
131
|
+
CGRect safe = self.view.safeAreaLayoutGuide.layoutFrame;
|
|
132
|
+
CGFloat top = CGRectGetMaxY(safe);
|
|
133
|
+
barView.frame = CGRectMake(0, top, CGRectGetWidth(bounds), CGRectGetMaxY(bounds) - top);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (NSArray<NSString *> *)tabKeys {
|
|
138
|
+
NSMutableArray<NSString *> *keys = [NSMutableArray arrayWithCapacity:self.viewControllers.count];
|
|
139
|
+
for (UIViewController *vc in self.viewControllers) {
|
|
140
|
+
HBDViewController *hbdvc = [self tabViewController:vc];
|
|
141
|
+
[keys addObject:hbdvc.tabKey ?: @""];
|
|
142
|
+
}
|
|
143
|
+
return [keys copy];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
- (NSInteger)indexForTabKey:(NSString *)tabKey {
|
|
147
|
+
if (![tabKey isKindOfClass:[NSString class]] || tabKey.length == 0) {
|
|
148
|
+
return NSNotFound;
|
|
149
|
+
}
|
|
150
|
+
NSArray<NSString *> *keys = [self tabKeys];
|
|
151
|
+
for (NSUInteger i = 0; i < keys.count; i++) {
|
|
152
|
+
if ([keys[i] isEqualToString:tabKey]) {
|
|
153
|
+
return (NSInteger)i;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return NSNotFound;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (void)applyGlobalStyle:(HBDGlobalStyle *)style {
|
|
160
|
+
if (!style) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
[style applyToTabBar:self.tabBar];
|
|
164
|
+
for (UIViewController *tab in self.viewControllers) {
|
|
165
|
+
HBDViewController *hbdvc = [self tabViewController:tab];
|
|
166
|
+
[hbdvc applyTabBarOptions:hbdvc.options];
|
|
167
|
+
}
|
|
168
|
+
[self reloadRendererAnimated:NO];
|
|
32
169
|
}
|
|
33
170
|
|
|
34
171
|
- (void)setTabItem:(NSArray<NSDictionary *> *)options {
|
|
35
172
|
for (NSDictionary *option in options) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
173
|
+
NSInteger resolvedIndex = NSNotFound;
|
|
174
|
+
if ([option[@"index"] isKindOfClass:[NSNumber class]]) {
|
|
175
|
+
resolvedIndex = [option[@"index"] integerValue];
|
|
176
|
+
} else if ([option[@"key"] isKindOfClass:[NSString class]]) {
|
|
177
|
+
resolvedIndex = [self indexForTabKey:option[@"key"]];
|
|
178
|
+
}
|
|
179
|
+
if (resolvedIndex < 0 || (NSUInteger)resolvedIndex >= self.viewControllers.count) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
UIViewController *tab = self.viewControllers[(NSUInteger)resolvedIndex];
|
|
183
|
+
HBDViewController *hbdvc = [self tabViewController:tab];
|
|
184
|
+
[hbdvc updateTabBarItem:option];
|
|
40
185
|
}
|
|
186
|
+
[self reloadRendererAnimated:NO];
|
|
41
187
|
}
|
|
42
188
|
|
|
43
189
|
- (HBDViewController *)tabViewController:(UIViewController *)vc {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
190
|
+
if ([vc isKindOfClass:[UINavigationController class]]) {
|
|
191
|
+
UINavigationController *nav = (UINavigationController *)vc;
|
|
192
|
+
return [self tabViewController:[nav.viewControllers firstObject]];
|
|
193
|
+
} else if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
194
|
+
return (HBDViewController *)vc;
|
|
195
|
+
}
|
|
50
196
|
|
|
51
|
-
|
|
197
|
+
return nil;
|
|
52
198
|
}
|
|
53
199
|
|
|
54
200
|
- (void)updateTabBar:(NSDictionary *)options {
|
|
55
201
|
UITabBar *tabBar = self.tabBar;
|
|
56
202
|
NSString *tabBarBackgroundColor = options[@"tabBarBackgroundColor"];
|
|
57
203
|
if (tabBarBackgroundColor) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
204
|
+
if (@available(iOS 26.0, *)) {
|
|
205
|
+
//
|
|
206
|
+
} else {
|
|
61
207
|
[tabBar standardAppearance].backgroundImage = [HBDUtils imageWithColor:[HBDUtils colorWithHexString:tabBarBackgroundColor]];
|
|
62
208
|
[tabBar scrollEdgeAppearance].backgroundImage = [HBDUtils imageWithColor:[HBDUtils colorWithHexString:tabBarBackgroundColor]];
|
|
63
209
|
}
|
|
@@ -79,45 +225,81 @@
|
|
|
79
225
|
NSString *tabBarItemSelectedColor = options[@"tabBarItemSelectedColor"];
|
|
80
226
|
NSString *tabBarItemNormalColor = options[@"tabBarItemNormalColor"];
|
|
81
227
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
228
|
+
if (tabBarItemSelectedColor) {
|
|
229
|
+
if (!tabBarItemNormalColor) {
|
|
230
|
+
tabBarItemNormalColor = @"#666666";
|
|
231
|
+
}
|
|
232
|
+
UITabBarItemAppearance *tabBarItem = [UITabBarItemAppearance new];
|
|
233
|
+
tabBarItem.normal.titleTextAttributes = @{
|
|
234
|
+
NSForegroundColorAttributeName: [HBDUtils colorWithHexString:tabBarItemNormalColor],
|
|
235
|
+
};
|
|
236
|
+
tabBarItem.normal.iconColor = [HBDUtils colorWithHexString:tabBarItemNormalColor];
|
|
237
|
+
tabBarItem.selected.titleTextAttributes = @{
|
|
238
|
+
NSForegroundColorAttributeName: [HBDUtils colorWithHexString:tabBarItemSelectedColor],
|
|
239
|
+
};
|
|
240
|
+
tabBarItem.selected.iconColor = [HBDUtils colorWithHexString:tabBarItemSelectedColor];
|
|
241
|
+
tabBar.standardAppearance.stackedLayoutAppearance = tabBarItem;
|
|
242
|
+
tabBar.scrollEdgeAppearance.stackedLayoutAppearance = tabBarItem;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
for (UIViewController *tab in self.childViewControllers) {
|
|
246
|
+
HBDViewController *hbdvc = [self tabViewController:tab];
|
|
247
|
+
[hbdvc applyTabBarOptions:hbdvc.options];
|
|
248
|
+
}
|
|
249
|
+
if ([self.tabBarRenderer respondsToSelector:@selector(updateTabBarStyle:)]) {
|
|
250
|
+
[self.tabBarRenderer updateTabBarStyle:options];
|
|
251
|
+
}
|
|
252
|
+
[self reloadRendererAnimated:NO];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
- (void)hbd_didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
|
|
256
|
+
[super hbd_didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
|
|
109
257
|
}
|
|
110
258
|
|
|
111
259
|
- (void)setSelectedIndex:(NSUInteger)selectedIndex {
|
|
112
|
-
|
|
260
|
+
if (selectedIndex < self.viewControllers.count) {
|
|
261
|
+
[self setSelectedViewController:self.viewControllers[selectedIndex]];
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
- (void)setSelectedViewController:(__kindof UIViewController *)selectedViewController {
|
|
266
|
+
[super setSelectedViewController:selectedViewController];
|
|
267
|
+
[self reloadRendererAnimated:NO];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
- (void)emitTabPressAtIndex:(NSUInteger)index previousIndex:(NSUInteger)previousIndex {
|
|
271
|
+
if (![HBDReactBridgeManager get].isReactModuleRegisterCompleted) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
NSArray<NSString *> *keys = [self tabKeys];
|
|
275
|
+
NSString *tabKey = (index < keys.count) ? keys[index] : @"";
|
|
276
|
+
NSMutableDictionary *payload = [@{
|
|
277
|
+
@"index": @(index),
|
|
278
|
+
@"previousIndex": @(previousIndex),
|
|
279
|
+
@"reselected": @(index == previousIndex),
|
|
280
|
+
} mutableCopy];
|
|
281
|
+
if (tabKey.length > 0) {
|
|
282
|
+
payload[@"tabKey"] = tabKey;
|
|
283
|
+
}
|
|
284
|
+
HBDNativeEvent *event = [HBDNativeEvent getInstance];
|
|
285
|
+
if (event) {
|
|
286
|
+
[event emitOnTabPress:[payload copy]];
|
|
287
|
+
}
|
|
113
288
|
}
|
|
114
289
|
|
|
115
290
|
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
|
|
291
|
+
self.pendingPreviousSelectedIndex = self.selectedIndex;
|
|
116
292
|
return YES;
|
|
117
293
|
}
|
|
118
294
|
|
|
119
|
-
- (
|
|
295
|
+
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
|
|
296
|
+
NSUInteger index = [self.viewControllers indexOfObject:viewController];
|
|
297
|
+
if (index != NSNotFound) {
|
|
298
|
+
[self emitTabPressAtIndex:index previousIndex:self.pendingPreviousSelectedIndex];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
120
301
|
|
|
302
|
+
- (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
|
|
121
303
|
if (toVC.viewLoaded) {
|
|
122
304
|
return nil;
|
|
123
305
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
@class HBDTabBarController;
|
|
4
|
+
|
|
5
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
+
|
|
7
|
+
@protocol HBDTabBarRenderer <NSObject>
|
|
8
|
+
|
|
9
|
+
@property(nonatomic, strong, readonly) UIView *barView;
|
|
10
|
+
@property(nonatomic, assign, readonly) CGFloat contentHeight;
|
|
11
|
+
|
|
12
|
+
- (void)attachToTabBarController:(HBDTabBarController *)tabBarController
|
|
13
|
+
onSelectTabAtIndex:(void (^)(NSUInteger index))onSelectTabAtIndex;
|
|
14
|
+
|
|
15
|
+
- (void)reloadItems:(NSArray<UITabBarItem *> *)items
|
|
16
|
+
tabKeys:(NSArray<NSString *> *)tabKeys
|
|
17
|
+
selectedIndex:(NSUInteger)selectedIndex
|
|
18
|
+
animated:(BOOL)animated;
|
|
19
|
+
|
|
20
|
+
@optional
|
|
21
|
+
- (void)updateTabBarStyle:(NSDictionary *)options;
|
|
22
|
+
- (void)layoutInContainerView:(UIView *)containerView safeAreaFrame:(CGRect)safeAreaFrame;
|
|
23
|
+
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
typedef id<HBDTabBarRenderer> _Nonnull (^HBDTabBarRendererFactory)(void);
|
|
27
|
+
|
|
28
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -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,21 @@
|
|
|
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, copy, readonly) NSString *tabKey;
|
|
15
|
+
@property(nonatomic, strong, readonly) HBDSceneLifecycleStateMachine *lifecycleStateMachine;
|
|
12
16
|
|
|
13
17
|
- (instancetype)initWithModuleName:(NSString *)moduleName props:(NSDictionary *)props options:(NSDictionary *)options NS_DESIGNATED_INITIALIZER;
|
|
14
18
|
|
|
15
19
|
- (void)setAppProperties:(NSDictionary *)props;
|
|
16
20
|
|
|
17
|
-
- (
|
|
21
|
+
- (BOOL)isNativeManagedLifecycle;
|
|
18
22
|
|
|
19
|
-
- (void)
|
|
23
|
+
- (void)sceneLifecycleDidChangeFromState:(HBDSceneLifecycleState)prevState toState:(HBDSceneLifecycleState)newState;
|
|
24
|
+
|
|
25
|
+
- (void)updateOptions:(NSDictionary *)options;
|
|
26
|
+
|
|
27
|
+
- (void)applyTabBarOptions:(NSDictionary *)options;
|
|
20
28
|
|
|
21
29
|
- (void)updateTabBarItem:(NSDictionary *)options;
|
|
22
30
|
|