hybrid-navigation 2.20.1 → 3.0.1

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.
Files changed (136) hide show
  1. package/HybridNavigation.podspec +7 -5
  2. package/README.md +17 -0
  3. package/android/build.gradle +56 -19
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +1 -2
  6. package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +320 -326
  7. package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +13 -20
  8. package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +6 -11
  9. package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +55 -21
  10. package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +31 -0
  11. package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +223 -0
  12. package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +370 -0
  13. package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +239 -224
  14. package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +177 -198
  15. package/android/src/main/java/com/reactnative/hybridnavigation/ReactDrawerFragment.java +2 -9
  16. package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +41 -78
  17. package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +438 -0
  18. package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +10 -19
  19. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +7 -15
  20. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +135 -173
  21. package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +54 -227
  22. package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +2 -3
  23. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +12 -14
  24. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +18 -21
  25. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +17 -20
  26. package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +13 -26
  27. package/dist/NativeEvent.d.ts +33 -0
  28. package/dist/NativeEvent.js +2 -0
  29. package/dist/NativeGarden.d.ts +18 -0
  30. package/dist/NativeGarden.js +2 -0
  31. package/dist/NativeNavigation.d.ts +47 -0
  32. package/dist/NativeNavigation.js +2 -0
  33. package/dist/Navigation.js +3 -3
  34. package/dist/NavigationModule.d.ts +3 -3
  35. package/dist/NavigationModule.js +18 -19
  36. package/dist/Navigator.js +1 -2
  37. package/dist/Options.d.ts +4 -7
  38. package/dist/Route.d.ts +0 -2
  39. package/dist/handler/BarButtonEventHandler.js +2 -2
  40. package/dist/handler/LayoutCommandHandler.js +3 -3
  41. package/dist/handler/ResultEventHandler.js +3 -3
  42. package/dist/handler/VisibilityEventHandler.js +11 -4
  43. package/dist/index.d.ts +0 -1
  44. package/dist/index.js +0 -1
  45. package/ios/HybridNavigation/GlobalStyle.h +0 -6
  46. package/ios/HybridNavigation/{GlobalStyle.m → GlobalStyle.mm} +54 -44
  47. package/ios/HybridNavigation/HBDUtils.h +0 -4
  48. package/ios/HybridNavigation/{HBDUtils.m → HBDUtils.mm} +0 -41
  49. package/ios/HybridNavigation/Navigator/{HBDScreenNavigator.m → HBDScreenNavigator.mm} +3 -9
  50. package/ios/HybridNavigation/Navigator/{HBDStackNavigator.m → HBDStackNavigator.mm} +0 -4
  51. package/ios/HybridNavigation/Navigator/{HBDTabNavigator.m → HBDTabNavigator.mm} +1 -55
  52. package/ios/HybridNavigation/React/HBDNativeEvent.h +13 -0
  53. package/ios/HybridNavigation/React/HBDNativeEvent.mm +31 -0
  54. package/ios/HybridNavigation/React/HBDNativeGarden.h +10 -0
  55. package/ios/HybridNavigation/React/HBDNativeGarden.mm +151 -0
  56. package/ios/HybridNavigation/React/HBDNativeNavigation.h +11 -0
  57. package/ios/HybridNavigation/React/HBDNativeNavigation.mm +263 -0
  58. package/ios/HybridNavigation/{ReactBridge → React}/HBDReactBridgeManager.h +3 -1
  59. package/ios/HybridNavigation/{ReactBridge/HBDReactBridgeManager.m → React/HBDReactBridgeManager.mm} +7 -30
  60. package/ios/HybridNavigation/View/{HBDNavigationBar.m → HBDNavigationBar.mm} +8 -28
  61. package/ios/HybridNavigation/View/HBDRootView.h +2 -2
  62. package/ios/HybridNavigation/View/{HBDRootView.m → HBDRootView.mm} +2 -2
  63. package/ios/HybridNavigation/View/HBDTitleView.h +2 -2
  64. package/ios/HybridNavigation/View/{HBDTitleView.m → HBDTitleView.mm} +3 -3
  65. package/ios/HybridNavigation/View/UIImage+WithBadge.h +13 -0
  66. package/ios/HybridNavigation/View/UIImage+WithBadge.mm +36 -0
  67. package/ios/HybridNavigation/ViewController/{HBDDrawerController.m → HBDDrawerController.mm} +2 -25
  68. package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -4
  69. package/ios/HybridNavigation/ViewController/{HBDReactViewController.m → HBDReactViewController.mm} +40 -31
  70. package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -2
  71. package/ios/HybridNavigation/ViewController/HBDTabBarController.mm +140 -0
  72. package/ios/HybridNavigation/ViewController/HBDViewController+Garden.h +0 -2
  73. package/ios/HybridNavigation/ViewController/{HBDViewController+Garden.m → HBDViewController+Garden.mm} +8 -26
  74. package/ios/HybridNavigation/ViewController/HBDViewController.h +2 -0
  75. package/ios/HybridNavigation/ViewController/{HBDViewController.m → HBDViewController.mm} +67 -57
  76. package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +0 -2
  77. package/ios/HybridNavigation/ViewController/{UIViewController+HBD.m → UIViewController+HBD.mm} +10 -44
  78. package/package.json +11 -2
  79. package/src/DeepLink.ts +3 -3
  80. package/src/NativeEvent.ts +40 -0
  81. package/src/NativeGarden.ts +27 -0
  82. package/src/NativeNavigation.ts +72 -0
  83. package/src/Navigation.ts +13 -13
  84. package/src/NavigationComponentWrap.tsx +4 -4
  85. package/src/NavigationModule.ts +21 -46
  86. package/src/Navigator.ts +13 -13
  87. package/src/Options.ts +9 -9
  88. package/src/Route.ts +0 -2
  89. package/src/handler/BarButtonEventHandler.ts +4 -8
  90. package/src/handler/DispatchCommandHandler.ts +4 -8
  91. package/src/handler/LayoutCommandHandler.ts +4 -5
  92. package/src/handler/ResultEventHandler.ts +11 -27
  93. package/src/handler/VisibilityEventHandler.ts +23 -32
  94. package/src/hooks.ts +2 -2
  95. package/src/index.ts +4 -5
  96. package/src/router/drawer.ts +5 -5
  97. package/src/router/index.ts +15 -15
  98. package/src/router/screen.ts +2 -2
  99. package/src/router/stack.ts +4 -4
  100. package/src/router/tabs.ts +3 -3
  101. package/src/store.ts +1 -1
  102. package/android/src/main/java/com/reactnative/hybridnavigation/DefaultTabBarProvider.java +0 -143
  103. package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +0 -230
  104. package/android/src/main/java/com/reactnative/hybridnavigation/HBDEventEmitter.java +0 -89
  105. package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +0 -71
  106. package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +0 -370
  107. package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +0 -445
  108. package/dist/Event.d.ts +0 -16
  109. package/dist/Event.js +0 -62
  110. package/dist/GardenModule.d.ts +0 -24
  111. package/dist/GardenModule.js +0 -21
  112. package/ios/HybridNavigation/HBDAnimationObserver.h +0 -24
  113. package/ios/HybridNavigation/HBDAnimationObserver.m +0 -45
  114. package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.h +0 -28
  115. package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.m +0 -72
  116. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +0 -6
  117. package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +0 -157
  118. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +0 -6
  119. package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +0 -249
  120. package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -9
  121. package/ios/HybridNavigation/View/HBDReactTabBar.m +0 -36
  122. package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -9
  123. package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -46
  124. package/ios/HybridNavigation/ViewController/HBDTabBarController.m +0 -265
  125. package/src/Event.ts +0 -117
  126. package/src/GardenModule.ts +0 -50
  127. /package/ios/HybridNavigation/Navigator/{HBDDrawerNavigator.m → HBDDrawerNavigator.mm} +0 -0
  128. /package/ios/HybridNavigation/Navigator/{HBDNavigatorRegistry.m → HBDNavigatorRegistry.mm} +0 -0
  129. /package/ios/HybridNavigation/{ReactBridge → React}/HBDNavigator.h +0 -0
  130. /package/ios/HybridNavigation/View/{HBDBackBarButtonItem.m → HBDBackBarButtonItem.mm} +0 -0
  131. /package/ios/HybridNavigation/View/{HBDBarButtonItem.m → HBDBarButtonItem.mm} +0 -0
  132. /package/ios/HybridNavigation/ViewController/{HBDFadeAnimation.m → HBDFadeAnimation.mm} +0 -0
  133. /package/ios/HybridNavigation/ViewController/{HBDNavigationController.m → HBDNavigationController.mm} +0 -0
  134. /package/ios/HybridNavigation/ViewController/{HBDPopAnimation.m → HBDPopAnimation.mm} +0 -0
  135. /package/ios/HybridNavigation/ViewController/{HBDPushAnimation.m → HBDPushAnimation.mm} +0 -0
  136. /package/ios/HybridNavigation/ViewController/{UINavigationController+HBD.m → UINavigationController+HBD.mm} +0 -0
@@ -3,16 +3,17 @@
3
3
  #import "HBDReactBridgeManager.h"
4
4
  #import "HBDTitleView.h"
5
5
  #import "HBDRootView.h"
6
- #import "HBDEventEmitter.h"
7
6
  #import "HBDUtils.h"
7
+ #import "HBDNativeEvent.h"
8
8
 
9
9
  #import <React/RCTConvert.h>
10
+ #import <React/RCTSurfaceHostingProxyRootView.h>
10
11
 
11
12
  @interface HBDReactViewController ()
12
13
 
13
14
  @property(nonatomic, assign) BOOL firstRenderCompleted;
14
15
  @property(nonatomic, assign) BOOL viewAppeared;
15
- @property(nonatomic, strong, readwrite) RCTRootView *rootView;
16
+ @property(nonatomic, strong, readwrite) RCTSurfaceHostingProxyRootView *rootView;
16
17
 
17
18
  @end
18
19
 
@@ -38,7 +39,9 @@
38
39
  }
39
40
 
40
41
  - (void)loadView {
41
- RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:self.moduleName initialProperties:[self propsWithSceneId]];
42
+ RCTHost *host = [HBDReactBridgeManager get].rctHost;
43
+ RCTFabricSurface *surface = [host createSurfaceWithModuleName:self.moduleName initialProperties:[self propsWithSceneId]];
44
+ RCTSurfaceHostingProxyRootView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:(id)surface];
42
45
  self.rootView = rootView;
43
46
 
44
47
  BOOL passThroughTouches = [self.options[@"passThroughTouches"] boolValue];
@@ -67,7 +70,10 @@
67
70
  } else {
68
71
  size = UILayoutFittingCompressedSize;
69
72
  }
70
- RCTRootView *titleRootView = [[RCTRootView alloc] initWithBridge:[HBDReactBridgeManager get].bridge moduleName:moduleName initialProperties:[self propsWithSceneId]];
73
+
74
+ RCTHost *host = [HBDReactBridgeManager get].rctHost;
75
+ RCTFabricSurface *surface = [host createSurfaceWithModuleName:moduleName initialProperties:[self propsWithSceneId]];
76
+ RCTSurfaceHostingProxyRootView *titleRootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:(id)surface];
71
77
  HBDTitleView *titleView = [[HBDTitleView alloc] initWithRootView:titleRootView layoutFittingSize:size navigationBarBounds:self.navigationController.navigationBar.bounds];
72
78
  self.navigationItem.titleView = titleView;
73
79
  }
@@ -102,6 +108,13 @@
102
108
  return isTranslucent || self.extendedLayoutIncludesOpaqueBars;
103
109
  }
104
110
 
111
+ - (BOOL)shouldFitSafeAreaLayoutBottom {
112
+ if (self.navigationController && self.tabBarController) {
113
+ return self == [self.navigationController.viewControllers firstObject];
114
+ }
115
+ return NO;
116
+ }
117
+
105
118
  - (NSDictionary *)propsWithSceneId {
106
119
  NSMutableDictionary *props;
107
120
  if (self.props) {
@@ -131,10 +144,9 @@
131
144
  if (!self.viewAppeared) {
132
145
  self.viewAppeared = YES;
133
146
  if (self.firstRenderCompleted) {
134
- [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
135
- KEY_SCENE_ID: self.sceneId,
136
- KEY_ON: ON_COMPONENT_APPEAR
137
- }];
147
+ [[HBDNativeEvent getInstance] emitOnComponentAppear:@{
148
+ @"sceneId": self.sceneId,
149
+ }];
138
150
  }
139
151
  }
140
152
  }
@@ -145,10 +157,9 @@
145
157
  if (!self.viewAppeared) {
146
158
  self.viewAppeared = YES;
147
159
  if (self.firstRenderCompleted) {
148
- [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
149
- KEY_SCENE_ID: self.sceneId,
150
- KEY_ON: ON_COMPONENT_APPEAR
151
- }];
160
+ [[HBDNativeEvent getInstance] emitOnComponentAppear:@{
161
+ @"sceneId": self.sceneId,
162
+ }];
152
163
  }
153
164
  }
154
165
  }
@@ -160,10 +171,9 @@
160
171
  if (self.viewAppeared) {
161
172
  self.viewAppeared = NO;
162
173
  if (self.firstRenderCompleted) {
163
- [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
164
- KEY_SCENE_ID: self.sceneId,
165
- KEY_ON: ON_COMPONENT_DISAPPEAR
166
- }];
174
+ [[HBDNativeEvent getInstance] emitOnComponentDisappear:@{
175
+ @"sceneId": self.sceneId,
176
+ }];
167
177
  }
168
178
  }
169
179
  }
@@ -174,10 +184,9 @@
174
184
  if (self.viewAppeared) {
175
185
  self.viewAppeared = NO;
176
186
  if (self.firstRenderCompleted) {
177
- [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
178
- KEY_SCENE_ID: self.sceneId,
179
- KEY_ON: ON_COMPONENT_DISAPPEAR
180
- }];
187
+ [[HBDNativeEvent getInstance] emitOnComponentDisappear:@{
188
+ @"sceneId": self.sceneId,
189
+ }];
181
190
  }
182
191
  }
183
192
  }
@@ -188,22 +197,22 @@
188
197
  }
189
198
  self.firstRenderCompleted = YES;
190
199
  if (self.viewAppeared) {
191
- [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
192
- KEY_SCENE_ID: self.sceneId,
193
- KEY_ON: ON_COMPONENT_APPEAR
194
- }];
200
+ if (self.firstRenderCompleted) {
201
+ [[HBDNativeEvent getInstance] emitOnComponentAppear:@{
202
+ @"sceneId": self.sceneId,
203
+ }];
204
+ }
195
205
  }
196
206
  }
197
207
 
198
208
  - (void)didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
199
209
  [super didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
200
- [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
201
- KEY_ON: ON_COMPONENT_RESULT,
202
- KEY_REQUEST_CODE: @(requestCode),
203
- KEY_RESULT_CODE: @(resultCode),
204
- KEY_RESULT_DATA: RCTNullIfNil(data),
205
- KEY_SCENE_ID: self.sceneId,
206
- }];
210
+ [[HBDNativeEvent getInstance] emitOnResult:@{
211
+ @"requestCode": @(requestCode),
212
+ @"resultCode": @(resultCode),
213
+ @"resultData": RCTNullIfNil(data),
214
+ @"sceneId": self.sceneId,
215
+ }];
207
216
  }
208
217
 
209
218
 
@@ -4,8 +4,6 @@
4
4
 
5
5
  @property(nonatomic, assign) BOOL intercepted;
6
6
 
7
- - (instancetype)initWithTabBarOptions:(NSDictionary *)options;
8
-
9
7
  - (void)updateTabBar:(NSDictionary *)options;
10
8
 
11
9
  - (void)setTabItem:(NSArray<NSDictionary *> *)options;
@@ -0,0 +1,140 @@
1
+ #import "HBDTabBarController.h"
2
+
3
+ #import "HBDReactViewController.h"
4
+ #import "HBDReactBridgeManager.h"
5
+ #import "HBDUtils.h"
6
+ #import "HBDFadeAnimation.h"
7
+ #import "HBDNativeEvent.h"
8
+
9
+ #import <React/RCTLog.h>
10
+
11
+
12
+ @interface HBDTabBarController () <UITabBarControllerDelegate>
13
+
14
+ @end
15
+
16
+ @implementation HBDTabBarController
17
+
18
+ - (UIViewController *)childViewControllerForStatusBarHidden {
19
+ return self.selectedViewController;
20
+ }
21
+
22
+ - (UIViewController *)childViewControllerForHomeIndicatorAutoHidden {
23
+ return self.selectedViewController;
24
+ }
25
+
26
+ - (void)viewDidLoad {
27
+ [super viewDidLoad];
28
+ self.definesPresentationContext = NO;
29
+ self.delegate = self;
30
+ self.intercepted = YES;
31
+ }
32
+
33
+ - (void)setTabItem:(NSArray<NSDictionary *> *)options {
34
+ for (NSDictionary *option in options) {
35
+ NSUInteger index = (NSUInteger) (option[@"index"] ? [option[@"index"] integerValue] : 0);
36
+ UIViewController *tab = self.viewControllers[index];
37
+ HBDViewController *hbdvc = [self tabViewController:tab];
38
+ [hbdvc updateTabBarItem:option];
39
+ }
40
+ }
41
+
42
+ - (HBDViewController *)tabViewController:(UIViewController *)vc {
43
+ if ([vc isKindOfClass:[UINavigationController class]]) {
44
+ UINavigationController *nav = (UINavigationController *)vc;
45
+ return [self tabViewController:[nav.viewControllers firstObject]];
46
+ } else if ([vc isKindOfClass:[HBDViewController class]]) {
47
+ return (HBDViewController *)vc;
48
+ }
49
+
50
+ return nil;
51
+ }
52
+
53
+ - (void)updateTabBar:(NSDictionary *)options {
54
+ UITabBar *tabBar = self.tabBar;
55
+ NSString *tabBarBackgroundColor = options[@"tabBarBackgroundColor"];
56
+ if (tabBarBackgroundColor) {
57
+ if (@available(iOS 26.0, *)) {
58
+ // [tabBar setBackgroundColor: [HBDUtils colorWithHexString:tabBarBackgroundColor]];
59
+ } else
60
+ if (@available(iOS 15.0, *)) {
61
+ [tabBar standardAppearance].backgroundImage = [HBDUtils imageWithColor:[HBDUtils colorWithHexString:tabBarBackgroundColor]];
62
+ [tabBar scrollEdgeAppearance].backgroundImage = [HBDUtils imageWithColor:[HBDUtils colorWithHexString:tabBarBackgroundColor]];
63
+ } else {
64
+ [tabBar setBackgroundImage:[HBDUtils imageWithColor:[HBDUtils colorWithHexString:tabBarBackgroundColor]]];
65
+ }
66
+ }
67
+
68
+ NSDictionary *tabBarShadowImage = options[@"tabBarShadowImage"];
69
+ if (RCTNilIfNull(tabBarShadowImage)) {
70
+ UIImage *image = [UIImage new];
71
+ NSDictionary *imageItem = tabBarShadowImage[@"image"];
72
+ NSString *color = tabBarShadowImage[@"color"];
73
+ if (imageItem) {
74
+ image = [HBDUtils UIImage:imageItem];
75
+ } else if (color) {
76
+ image = [HBDUtils imageWithColor:[HBDUtils colorWithHexString:color]];
77
+ }
78
+ tabBar.shadowImage = image;
79
+ }
80
+
81
+ NSString *tabBarItemSelectedColor = options[@"tabBarItemSelectedColor"];
82
+ NSString *tabBarItemNormalColor = options[@"tabBarItemNormalColor"];
83
+
84
+ if (tabBarItemSelectedColor) {
85
+ if (!tabBarItemNormalColor) {
86
+ tabBarItemNormalColor = @"#666666";
87
+ }
88
+ UITabBarItemAppearance *tabBarItem = [UITabBarItemAppearance new];
89
+ tabBarItem.normal.titleTextAttributes = @{
90
+ NSForegroundColorAttributeName: [HBDUtils colorWithHexString:tabBarItemNormalColor],
91
+ };
92
+ tabBarItem.normal.iconColor = [HBDUtils colorWithHexString:tabBarItemNormalColor];
93
+ tabBarItem.selected.titleTextAttributes = @{
94
+ NSForegroundColorAttributeName: [HBDUtils colorWithHexString:tabBarItemSelectedColor],
95
+ };
96
+ tabBarItem.selected.iconColor = [HBDUtils colorWithHexString:tabBarItemSelectedColor];
97
+ tabBar.standardAppearance.stackedLayoutAppearance = tabBarItem;
98
+ tabBar.scrollEdgeAppearance.stackedLayoutAppearance = tabBarItem;
99
+ [UITabBar appearance].standardAppearance.stackedLayoutAppearance = tabBarItem;
100
+ [UITabBar appearance].scrollEdgeAppearance.stackedLayoutAppearance = tabBarItem;
101
+ }
102
+
103
+ for (UIViewController *tab in self.childViewControllers) {
104
+ HBDViewController *hbdvc = [self tabViewController:tab];
105
+ [hbdvc updateTabBarItem:hbdvc.options];
106
+ }
107
+ }
108
+
109
+ - (void)didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
110
+ [super didReceiveResultCode:resultCode resultData:data requestCode:requestCode];
111
+ }
112
+
113
+ - (void)setSelectedIndex:(NSUInteger)selectedIndex {
114
+ [self setSelectedViewController:self.viewControllers[selectedIndex]];
115
+ }
116
+
117
+ - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
118
+ if ([[HBDReactBridgeManager get] hasRootLayout] && self.intercepted) {
119
+ long from = self.selectedIndex;
120
+ long to = [self.childViewControllers indexOfObject:viewController];
121
+ [[HBDNativeEvent getInstance] emitOnSwitchTab:@{
122
+ @"sceneId": self.sceneId,
123
+ @"from": @(from),
124
+ @"to": @(to),
125
+ }];
126
+ return NO;
127
+ }
128
+ return YES;
129
+ }
130
+
131
+ - (id<UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController animationControllerForTransitionFromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC {
132
+
133
+ if (toVC.viewLoaded) {
134
+ return nil;
135
+ }
136
+
137
+ return [[HBDFadeAnimation alloc] init];
138
+ }
139
+
140
+ @end
@@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN
12
12
 
13
13
  - (void)setRightBarButtonItems:(NSArray *)items;
14
14
 
15
- - (void)setPassThroughTouches:(BOOL)passThrough;
16
-
17
15
  @end
18
16
 
19
17
  NS_ASSUME_NONNULL_END
@@ -2,10 +2,9 @@
2
2
 
3
3
  #import "HBDBarButtonItem.h"
4
4
  #import "HBDUtils.h"
5
- #import "HBDEventEmitter.h"
5
+ #import "HBDNativeEvent.h"
6
6
 
7
7
  #import <React/RCTConvert.h>
8
- #import <React/RCTRootView.h>
9
8
 
10
9
  @implementation HBDViewController (Garden)
11
10
 
@@ -126,25 +125,16 @@
126
125
 
127
126
  - (HBDBarButtonItem *)createBarButtonItem:(NSDictionary *)item {
128
127
  HBDBarButtonItem *barButtonItem;
129
- NSDictionary *insetsOption = item[@"insetsIOS"];
130
- UIEdgeInsets insets = UIEdgeInsetsZero;
131
- if (insetsOption) {
132
- insets = [RCTConvert UIEdgeInsets:insetsOption];
133
- }
134
-
135
128
  NSDictionary *icon = item[@"icon"];
136
129
  if (RCTNilIfNull(icon)) {
137
130
  UIImage *iconImage = [HBDUtils UIImage:icon];
138
131
  if (item[@"renderOriginal"] && [item[@"renderOriginal"] boolValue]) {
139
132
  iconImage = [iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
140
133
  }
141
-
142
134
  barButtonItem = [[HBDBarButtonItem alloc] initWithImage:iconImage style:UIBarButtonItemStylePlain];
143
- barButtonItem.imageInsets = insets;
144
135
  } else {
145
136
  NSString *title = item[@"title"];
146
137
  barButtonItem = [[HBDBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain];
147
- [barButtonItem setTitlePositionAdjustment:UIOffsetMake(insets.left, 0) forBarMetrics:UIBarMetricsDefault];
148
138
  }
149
139
 
150
140
  NSNumber *enabled = item[@"enabled"];
@@ -152,8 +142,6 @@
152
142
  barButtonItem.enabled = [enabled boolValue];
153
143
  }
154
144
 
155
- NSString *action = item[@"action"];
156
- NSString *sceneId = self.sceneId;
157
145
 
158
146
  NSString *tintColor = item[@"tintColor"];
159
147
  if (tintColor) {
@@ -164,24 +152,18 @@
164
152
  button.tintColor = [HBDUtils colorWithHexString:tintColor];
165
153
  }
166
154
  }
167
-
155
+
156
+ NSString *action = item[@"action"];
157
+ NSString *sceneId = self.sceneId;
168
158
  if (action) {
169
159
  barButtonItem.actionBlock = ^{
170
- [HBDEventEmitter sendEvent:EVENT_NAVIGATION data:@{
171
- KEY_ON: ON_BAR_BUTTON_ITEM_CLICK,
172
- KEY_ACTION: action,
173
- KEY_SCENE_ID: sceneId,
174
- }];
160
+ [[HBDNativeEvent getInstance] emitOnBarButtonItemClick:@{
161
+ @"action": action,
162
+ @"sceneId": sceneId,
163
+ }];
175
164
  };
176
165
  }
177
166
  return barButtonItem;
178
167
  }
179
168
 
180
- - (void)setPassThroughTouches:(BOOL)passThrough {
181
- if ([self.view isKindOfClass:[RCTRootView class]]) {
182
- RCTRootView *rootView = (RCTRootView *) self.view;
183
- rootView.passThroughTouches = passThrough;
184
- }
185
- }
186
-
187
169
  @end
@@ -15,4 +15,6 @@
15
15
 
16
16
  - (void)updateNavigationBarOptions:(NSDictionary *)options;
17
17
 
18
+ - (void)updateTabBarItem:(NSDictionary *)options;
19
+
18
20
  @end
@@ -2,9 +2,9 @@
2
2
 
3
3
  #import "HBDViewController+Garden.h"
4
4
  #import "HBDUtils.h"
5
- #import "HBDAnimationObserver.h"
6
5
  #import "GlobalStyle.h"
7
6
  #import "HBDBackBarButtonItem.h"
7
+ #import "UIImage+WithBadge.h"
8
8
 
9
9
  #import <React/RCTLog.h>
10
10
 
@@ -71,22 +71,7 @@
71
71
  }
72
72
 
73
73
  - (BOOL)prefersStatusBarHidden {
74
- if (@available(iOS 13.0, *)) {
75
- return [self hbd_statusBarHidden] && ![HBDUtils isInCall];
76
- }
77
-
78
- if ([HBDUtils isIphoneX]) {
79
- return [self hbd_statusBarHidden] && ![HBDUtils isInCall];
80
- } else {
81
- UIView *statusBar = [[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];
82
- BOOL hidden = [self hbd_statusBarHidden] && ![HBDUtils isInCall];
83
- CGFloat statusBarHeight = [HBDUtils statusBarHeight];
84
- [UIView animateWithDuration:0.2 animations:^{
85
- statusBar.transform = hidden ? CGAffineTransformTranslate(CGAffineTransformIdentity, 0, -statusBarHeight) : CGAffineTransformIdentity;
86
- statusBar.alpha = hidden ? 0 : 1.0;
87
- }];
88
- return NO;
89
- }
74
+ return [self hbd_statusBarHidden];
90
75
  }
91
76
 
92
77
  - (BOOL)prefersHomeIndicatorAutoHidden {
@@ -105,21 +90,9 @@
105
90
 
106
91
  - (void)viewDidAppear:(BOOL)animated {
107
92
  [super viewDidAppear:animated];
108
- [[HBDAnimationObserver sharedObserver] endAnimation];
109
- if (![HBDUtils isIphoneX]) {
110
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
111
- }
112
-
113
93
  [self adjustScreenOrientation];
114
94
  }
115
95
 
116
- - (void)viewDidDisappear:(BOOL)animated {
117
- [super viewDidDisappear:animated];
118
- if (![HBDUtils isIphoneX]) {
119
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
120
- }
121
- }
122
-
123
96
  - (void)adjustScreenOrientation {
124
97
  if (@available(iOS 15.0, *)) {
125
98
  UIWindowScene *windowScene = [self getWindowScene];
@@ -166,10 +139,6 @@
166
139
  return nil;
167
140
  }
168
141
 
169
- - (void)statusBarFrameWillChange:(NSNotification *)notification {
170
- [self setNeedsStatusBarAppearanceUpdate];
171
- }
172
-
173
142
  - (void)viewDidLoad {
174
143
  [super viewDidLoad];
175
144
  [self setScreenBackgroundColor];
@@ -212,19 +181,76 @@
212
181
  - (void)applyTabBarOptions:(NSDictionary *)options {
213
182
  NSDictionary *tabItem = options[@"tabItem"];
214
183
  if (tabItem) {
215
- UITabBarItem *tabBarItem = [[UITabBarItem alloc] init];
184
+ UITabBarItem *tabBarItem = self.tabBarItem;
185
+ // title
216
186
  tabBarItem.title = tabItem[@"title"];
217
- NSDictionary *unselectedIcon = tabItem[@"unselectedIcon"];
218
- if (unselectedIcon) {
219
- tabBarItem.selectedImage = [[HBDUtils UIImage:tabItem[@"icon"]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
220
- tabBarItem.image = [[HBDUtils UIImage:unselectedIcon] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
221
- } else {
222
- tabBarItem.image = [HBDUtils UIImage:tabItem[@"icon"]];
223
- }
187
+
188
+ // badge
189
+ NSDictionary *badge = tabItem[@"badge"];
190
+ tabBarItem.badgeValue = [self badgeText:badge];
191
+ tabBarItem.badgeColor = [UITabBarItem appearance].badgeColor;
192
+
193
+ NSDictionary *unselectedIcon = tabItem[@"unselectedIcon"];
194
+ NSDictionary *icon = tabItem[@"icon"];
195
+ UITabBar *appearance = [UITabBar appearance];
196
+ BOOL dot = [self showDotBadge:badge];
197
+
198
+ UITabBarItemAppearance *itemAppearance = appearance.standardAppearance.stackedLayoutAppearance;
199
+ if (unselectedIcon) {
200
+ tabBarItem.selectedImage = [[HBDUtils UIImage:icon] withIconColor:itemAppearance.selected.iconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
201
+ tabBarItem.image = [[HBDUtils UIImage:unselectedIcon] withIconColor:itemAppearance.normal.iconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
202
+ } else {
203
+ tabBarItem.selectedImage = [[HBDUtils UIImage:icon] withIconColor:itemAppearance.selected.iconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
204
+ tabBarItem.image = [[HBDUtils UIImage:icon] withIconColor:itemAppearance.normal.iconColor badgeColor:dot ? tabBarItem.badgeColor : UIColor.clearColor];
205
+ }
206
+
224
207
  self.tabBarItem = tabBarItem;
225
208
  }
226
209
  }
227
210
 
211
+ - (void)updateTabBarItem:(NSDictionary *)option {
212
+ // title
213
+ NSString *title = option[@"title"];
214
+ if (title != nil) {
215
+ self.options[@"tabItem"][@"title"] = title;
216
+ }
217
+
218
+ // badge
219
+ NSDictionary *badge = option[@"badge"];
220
+ if (badge != nil) {
221
+ self.options[@"tabItem"][@"badge"] = badge;
222
+ }
223
+
224
+ // icon
225
+ NSDictionary *icon = option[@"icon"];
226
+ if (icon != nil) {
227
+ self.options[@"tabItem"][@"icon"] = icon[@"selected"];
228
+ self.options[@"tabItem"][@"unselectedIcon"] = icon[@"unselected"];
229
+ }
230
+
231
+ [self applyTabBarOptions:self.options];
232
+
233
+ if (self.navigationController) {
234
+ self.navigationController.tabBarItem = self.tabBarItem;
235
+ }
236
+ }
237
+
238
+ - (BOOL)showDotBadge:(NSDictionary *)badge {
239
+ if (badge) {
240
+ BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
241
+ return hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
242
+ }
243
+ return NO;
244
+ }
245
+
246
+ - (NSString *)badgeText:(NSDictionary *)badge {
247
+ if (badge) {
248
+ BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
249
+ return hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
250
+ }
251
+ return nil;
252
+ }
253
+
228
254
  - (void)applyNavigationBarOptions:(NSDictionary *)options {
229
255
  NSString *topBarStyle = options[@"topBarStyle"];
230
256
  if (topBarStyle) {
@@ -283,17 +309,6 @@
283
309
  }
284
310
  }
285
311
 
286
- NSDictionary *backItem = options[@"backItemIOS"];
287
- if (backItem) {
288
- UIBarButtonItem *backButton = [[HBDBackBarButtonItem alloc] init];
289
- backButton.title = backItem[@"title"];
290
- NSString *tintColor = backItem[@"tintColor"];
291
- if (tintColor) {
292
- backButton.tintColor = [HBDUtils colorWithHexString:tintColor];
293
- }
294
- self.navigationItem.backBarButtonItem = backButton;
295
- }
296
-
297
312
  NSNumber *swipeBackEnabled = options[@"swipeBackEnabled"];
298
313
  if (swipeBackEnabled) {
299
314
  self.hbd_swipeBackEnabled = [swipeBackEnabled boolValue];
@@ -399,11 +414,6 @@
399
414
  [self setNeedsUpdateOfHomeIndicatorAutoHidden];
400
415
  }
401
416
 
402
- NSNumber *passThroughTouches = options[@"passThroughTouches"];
403
- if (passThroughTouches) {
404
- [self setPassThroughTouches:[passThroughTouches boolValue]];
405
- }
406
-
407
417
  if ([self shouldUpdateNavigationBar:options compareTo:previous]) {
408
418
  [self hbd_setNeedsUpdateNavigationBar];
409
419
  }
@@ -32,8 +32,6 @@
32
32
 
33
33
  - (HBDDrawerController *)drawerController;
34
34
 
35
- - (void)hbd_updateTabBarItem:(NSDictionary *)options;
36
-
37
35
  - (NSString *)hbd_mode;
38
36
 
39
37
  @end
@@ -4,7 +4,6 @@
4
4
  #import "HBDReactViewController.h"
5
5
  #import "HBDUtils.h"
6
6
  #import "GlobalStyle.h"
7
- #import "UITabBar+Badge.h"
8
7
 
9
8
  #import <React/RCTLog.h>
10
9
 
@@ -93,7 +92,7 @@
93
92
  - (UIBarStyle)hbd_barStyle {
94
93
  id obj = objc_getAssociatedObject(self, _cmd);
95
94
  if (obj) {
96
- return [obj integerValue];
95
+ return (UIBarStyle)[obj integerValue];
97
96
  }
98
97
  return [UINavigationBar appearance].barStyle;
99
98
  }
@@ -193,12 +192,19 @@
193
192
 
194
193
  - (void)setHbd_barHidden:(BOOL)hidden {
195
194
  if (hidden) {
196
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[UIView new]];
197
195
  self.navigationItem.titleView = [UIView new];
198
196
  } else {
199
- self.navigationItem.leftBarButtonItem = nil;
200
197
  self.navigationItem.titleView = nil;
201
198
  }
199
+ if (@available(iOS 16.0, *)) {
200
+ [self.navigationItem setHidesBackButton:hidden];
201
+ } else {
202
+ if (hidden) {
203
+ self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[UIView new]];
204
+ } else {
205
+ self.navigationItem.leftBarButtonItem = nil;
206
+ }
207
+ }
202
208
  objc_setAssociatedObject(self, @selector(hbd_barHidden), @(hidden), OBJC_ASSOCIATION_COPY_NONATOMIC);
203
209
  }
204
210
 
@@ -338,46 +344,6 @@
338
344
  return nil;
339
345
  }
340
346
 
341
- - (void)hbd_updateTabBarItem:(NSDictionary *)option {
342
- UITabBarItem *tabBarItem = self.tabBarItem;
343
- NSUInteger index = option[@"index"] ? [option[@"index"] integerValue] : 0;
344
-
345
- // title
346
- NSString *title = option[@"title"];
347
- if (title != nil) {
348
- tabBarItem.title = title;
349
- }
350
-
351
- // icon
352
- NSDictionary *icon = option[@"icon"];
353
- if (icon != nil) {
354
- NSDictionary *unselected = icon[@"unselected"];
355
- NSDictionary *selected = icon[@"selected"];
356
- if (unselected) {
357
- tabBarItem.selectedImage = [[HBDUtils UIImage:selected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
358
- tabBarItem.image = [[HBDUtils UIImage:unselected] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
359
- } else {
360
- tabBarItem.image = [HBDUtils UIImage:selected];
361
- }
362
- }
363
-
364
- // badge
365
- NSDictionary *badge = option[@"badge"];
366
- if (badge != nil) {
367
- BOOL hidden = badge[@"hidden"] ? [badge[@"hidden"] boolValue] : YES;
368
- NSString *text = hidden ? nil : (badge[@"text"] ? badge[@"text"] : nil);
369
- BOOL dot = hidden ? NO : (badge[@"dot"] ? [badge[@"dot"] boolValue] : NO);
370
-
371
- tabBarItem.badgeValue = text;
372
- UITabBar *tabBar = self.tabBarController.tabBar;
373
- if (dot) {
374
- [tabBar showDotBadgeAtIndex:index];
375
- } else {
376
- [tabBar hideDotBadgeAtIndex:index];
377
- }
378
- }
379
- }
380
-
381
347
  - (NSString *)hbd_mode {
382
348
  if (self.modalPresentationStyle == UIModalPresentationOverFullScreen) {
383
349
  return @"modal";