hybrid-navigation 4.0.3 → 4.0.4

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.
@@ -7,7 +7,6 @@ import android.os.Bundle;
7
7
  import androidx.annotation.NonNull;
8
8
  import androidx.annotation.Nullable;
9
9
 
10
- import com.facebook.react.bridge.Arguments;
11
10
  import com.navigation.androidx.AwesomeFragment;
12
11
  import com.navigation.androidx.FragmentHelper;
13
12
  import com.navigation.androidx.Style;
@@ -121,37 +120,6 @@ public class ReactTabBarFragment extends TabBarFragment {
121
120
  this.options = options;
122
121
  }
123
122
 
124
- public void setIntercepted(boolean intercepted) {
125
- this.intercepted = intercepted;
126
- }
127
-
128
- private boolean intercepted = true;
129
-
130
- @Override
131
- public void setSelectedIndex(int index, @NonNull Runnable completion) {
132
- if (shouldIntercept()) {
133
- sendSwitchTabEvent(index);
134
- // restore tab bar selected index
135
- setTabBarSelectedIndex(getSelectedIndex());
136
- completion.run();
137
- } else {
138
- super.setSelectedIndex(index, completion);
139
- intercepted = true;
140
- }
141
- }
142
-
143
- private boolean shouldIntercept() {
144
- return isAdded() && reactManager.hasRootLayout() && this.intercepted;
145
- }
146
-
147
- private void sendSwitchTabEvent(int index) {
148
- Bundle data = new Bundle();
149
- data.putString("sceneId", getSceneId());
150
- data.putInt("from", getSelectedIndex());
151
- data.putInt("to", index);
152
- NativeEvent.getInstance().emitOnSwitchTab(Arguments.fromBundle(data));
153
- }
154
-
155
123
  public Style getStyle() {
156
124
  return mStyle;
157
125
  }
@@ -160,14 +160,7 @@ public class TabNavigator implements Navigator {
160
160
 
161
161
  popToStackRootIfNeeded(extras, tabBarFragment);
162
162
 
163
- if (!(tabBarFragment instanceof ReactTabBarFragment reactTabBarFragment)) {
164
- tabBarFragment.setSelectedIndex(to, () -> callback.invoke(null, true));
165
- return;
166
- }
167
-
168
- reactTabBarFragment.setIntercepted(false);
169
- reactTabBarFragment.setSelectedIndex(to, () -> callback.invoke(null, true));
170
- reactTabBarFragment.setIntercepted(true);
163
+ tabBarFragment.setSelectedIndex(to, () -> callback.invoke(null, true));
171
164
  }
172
165
 
173
166
  private boolean isSameTab(int to, @NonNull ReadableMap extras) {
@@ -37,9 +37,7 @@
37
37
  if (options) {
38
38
  NSNumber *selectedIndex = options[@"selectedIndex"];
39
39
  if (selectedIndex) {
40
- tabBarController.intercepted = NO;
41
40
  tabBarController.selectedIndex = (NSUInteger) [selectedIndex integerValue];
42
- tabBarController.intercepted = YES;
43
41
  }
44
42
  }
45
43
 
@@ -108,14 +106,7 @@
108
106
  }
109
107
  }
110
108
 
111
- if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
112
- HBDTabBarController *hbdTabBarController = (HBDTabBarController *)tabBarController;
113
- hbdTabBarController.intercepted = NO;
114
- tabBarController.selectedIndex = to;
115
- hbdTabBarController.intercepted = YES;
116
- } else {
117
- tabBarController.selectedIndex = to;
118
- }
109
+ tabBarController.selectedIndex = to;
119
110
 
120
111
  callback(@[NSNull.null, @YES]);
121
112
  }
@@ -2,8 +2,6 @@
2
2
 
3
3
  @interface HBDTabBarController : UITabBarController
4
4
 
5
- @property(nonatomic, assign) BOOL intercepted;
6
-
7
5
  - (void)updateTabBar:(NSDictionary *)options;
8
6
 
9
7
  - (void)setTabItem:(NSArray<NSDictionary *> *)options;
@@ -1,10 +1,8 @@
1
1
  #import "HBDTabBarController.h"
2
2
 
3
3
  #import "HBDReactViewController.h"
4
- #import "HBDReactBridgeManager.h"
5
4
  #import "HBDUtils.h"
6
5
  #import "HBDFadeAnimation.h"
7
- #import "HBDNativeEvent.h"
8
6
 
9
7
  #import <React/RCTLog.h>
10
8
 
@@ -31,7 +29,6 @@
31
29
  [super viewDidLoad];
32
30
  self.definesPresentationContext = NO;
33
31
  self.delegate = self;
34
- self.intercepted = YES;
35
32
  }
36
33
 
37
34
  - (void)setTabItem:(NSArray<NSDictionary *> *)options {
@@ -116,16 +113,6 @@
116
113
  }
117
114
 
118
115
  - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
119
- if ([[HBDReactBridgeManager get] hasRootLayout] && self.intercepted) {
120
- long from = self.selectedIndex;
121
- long to = [self.childViewControllers indexOfObject:viewController];
122
- [[HBDNativeEvent getInstance] emitOnSwitchTab:@{
123
- @"sceneId": self.sceneId,
124
- @"from": @(from),
125
- @"to": @(to),
126
- }];
127
- return NO;
128
- }
129
116
  return YES;
130
117
  }
131
118
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hybrid-navigation",
3
3
  "description": "React Native Navigation that supports seamless navigation between Native and React.",
4
- "version": "4.0.3",
4
+ "version": "4.0.4",
5
5
  "main": "./dist/index",
6
6
  "module": "./dist/index",
7
7
  "types": "./dist/index.d.ts",