hybrid-navigation 2.4.3 → 2.7.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/CHANGELOG.md +25 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Constants.java +1 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +13 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +29 -84
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +1 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +5 -5
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +57 -94
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +12 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +10 -17
- package/android/src/main/java/com/reactnative/hybridnavigation/{ReactNavigationFragment.java → ReactStackFragment.java} +2 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +0 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +49 -51
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +39 -59
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/NavigatorRegistry.java +2 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +7 -7
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +24 -24
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +4 -4
- package/docs/integration-native.md +3 -3
- package/docs/pass-and-return-value.md +4 -4
- package/docs/qa.md +17 -0
- package/docs/style.md +48 -63
- package/ios/HybridNavigation/Bridge/HBDGardenModule.m +3 -13
- package/ios/HybridNavigation/Bridge/HBDNavigationModule.m +1 -1
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +1 -3
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +34 -33
- package/ios/HybridNavigation/ViewController/HBDViewController.m +5 -0
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +38 -12
- package/lib/Garden.d.ts +14 -0
- package/lib/Garden.js +33 -2
- package/lib/Navigator.js +1 -1
- package/lib/typing.d.ts +1 -0
- package/package.json +7 -7
- package/android/src/main/java/com/reactnative/hybridnavigation/UiTaskExecutor.java +0 -81
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
package com.reactnative.hybridnavigation;
|
|
2
2
|
|
|
3
|
+
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
4
|
+
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
5
|
+
import static com.reactnative.hybridnavigation.Constants.ACTION_SET_TAB_ITEM;
|
|
6
|
+
import static com.reactnative.hybridnavigation.Constants.ACTION_UPDATE_TAB_BAR;
|
|
7
|
+
import static com.reactnative.hybridnavigation.Constants.ARG_ACTION;
|
|
8
|
+
import static com.reactnative.hybridnavigation.Constants.ARG_OPTIONS;
|
|
9
|
+
|
|
3
10
|
import android.content.Context;
|
|
4
11
|
import android.graphics.Color;
|
|
5
12
|
import android.graphics.drawable.ColorDrawable;
|
|
@@ -15,7 +22,7 @@ import androidx.annotation.Nullable;
|
|
|
15
22
|
import com.facebook.react.ReactInstanceManager;
|
|
16
23
|
import com.facebook.react.bridge.ReactContext;
|
|
17
24
|
import com.navigation.androidx.AwesomeFragment;
|
|
18
|
-
import com.navigation.androidx.
|
|
25
|
+
import com.navigation.androidx.StackFragment;
|
|
19
26
|
import com.navigation.androidx.Style;
|
|
20
27
|
import com.navigation.androidx.TabBarFragment;
|
|
21
28
|
import com.navigation.androidx.TabBarItem;
|
|
@@ -24,14 +31,6 @@ import com.navigation.androidx.TabBarProvider;
|
|
|
24
31
|
import java.util.ArrayList;
|
|
25
32
|
import java.util.List;
|
|
26
33
|
|
|
27
|
-
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
|
28
|
-
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
|
29
|
-
import static com.reactnative.hybridnavigation.Constants.ACTION_SET_TAB_BADGE;
|
|
30
|
-
import static com.reactnative.hybridnavigation.Constants.ACTION_SET_TAB_ICON;
|
|
31
|
-
import static com.reactnative.hybridnavigation.Constants.ACTION_UPDATE_TAB_BAR;
|
|
32
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_ACTION;
|
|
33
|
-
import static com.reactnative.hybridnavigation.Constants.ARG_OPTIONS;
|
|
34
|
-
|
|
35
34
|
public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.ReactBridgeReloadListener {
|
|
36
35
|
|
|
37
36
|
private static final String TAG = "Navigator";
|
|
@@ -110,9 +109,9 @@ public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.R
|
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
private Pair<String, String> extractSceneIdAndModuleName(AwesomeFragment awesomeFragment) {
|
|
113
|
-
if (awesomeFragment instanceof
|
|
114
|
-
|
|
115
|
-
awesomeFragment =
|
|
112
|
+
if (awesomeFragment instanceof StackFragment) {
|
|
113
|
+
StackFragment stackFragment = (StackFragment) awesomeFragment;
|
|
114
|
+
awesomeFragment = stackFragment.getRootFragment();
|
|
116
115
|
}
|
|
117
116
|
if (awesomeFragment instanceof HybridFragment) {
|
|
118
117
|
HybridFragment hybridFragment = (HybridFragment) awesomeFragment;
|
|
@@ -152,8 +151,6 @@ public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.R
|
|
|
152
151
|
public void onDestroyTabBar() {
|
|
153
152
|
unmountReactView();
|
|
154
153
|
tabBarFragment = null;
|
|
155
|
-
|
|
156
|
-
|
|
157
154
|
getReactBridgeManager().removeReactBridgeReloadListener(this);
|
|
158
155
|
}
|
|
159
156
|
|
|
@@ -184,20 +181,16 @@ public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.R
|
|
|
184
181
|
}
|
|
185
182
|
|
|
186
183
|
switch (action) {
|
|
187
|
-
case
|
|
188
|
-
|
|
189
|
-
break;
|
|
190
|
-
case ACTION_SET_TAB_ICON:
|
|
191
|
-
setTabIcon(options.getParcelableArrayList(ARG_OPTIONS));
|
|
184
|
+
case ACTION_SET_TAB_ITEM:
|
|
185
|
+
setTabItem(options.getParcelableArrayList(ARG_OPTIONS));
|
|
192
186
|
break;
|
|
193
187
|
case ACTION_UPDATE_TAB_BAR:
|
|
194
188
|
updateTabBarAppearance(options.getBundle(ARG_OPTIONS));
|
|
195
189
|
break;
|
|
196
190
|
}
|
|
197
191
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
private void setTabBadge(@Nullable ArrayList<Bundle> options) {
|
|
192
|
+
|
|
193
|
+
private void setTabItem(@Nullable ArrayList<Bundle> options) {
|
|
201
194
|
if (options == null) {
|
|
202
195
|
return;
|
|
203
196
|
}
|
|
@@ -211,53 +204,40 @@ public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.R
|
|
|
211
204
|
|
|
212
205
|
for (Bundle option : options) {
|
|
213
206
|
int index = (int) option.getDouble("index");
|
|
214
|
-
boolean hidden = option.getBoolean("hidden", true);
|
|
215
|
-
|
|
216
|
-
String text = !hidden ? option.getString("text", null) : null;
|
|
217
|
-
boolean dot = !hidden && option.getBoolean("dot", false);
|
|
218
|
-
|
|
219
207
|
Bundle tab = tabs.get(index);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
if (options == null) {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
Bundle tabBar = tabBarFragment.getOptions();
|
|
233
|
-
ArrayList<Bundle> tabs = tabBar.getParcelableArrayList("tabs");
|
|
234
|
-
|
|
235
|
-
if (tabs == null) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
for (Bundle option : options) {
|
|
240
|
-
int index = (int) option.getDouble("index");
|
|
208
|
+
|
|
209
|
+
// title
|
|
210
|
+
String title = option.getString("title");
|
|
211
|
+
if (title != null) {
|
|
212
|
+
tab.putString("title", title);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// icon
|
|
241
216
|
Bundle icon = option.getBundle("icon");
|
|
242
|
-
Bundle unselectedIcon = option.getBundle("unselectedIcon");
|
|
243
|
-
Context context = tabBarFragment.requireContext();
|
|
244
|
-
Bundle tab = tabs.get(index);
|
|
245
217
|
if (icon != null) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
218
|
+
Bundle unselected = icon.getBundle("unselected");
|
|
219
|
+
Bundle selected = icon.getBundle("selected");
|
|
220
|
+
if (unselected != null) {
|
|
221
|
+
tab.putString("unselectedIcon", unselected.getString("uri"));
|
|
222
|
+
}
|
|
223
|
+
tab.putString("icon", selected.getString("uri"));
|
|
249
224
|
}
|
|
250
225
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
226
|
+
// badge
|
|
227
|
+
Bundle badge = option.getBundle("badge");
|
|
228
|
+
if (badge != null) {
|
|
229
|
+
boolean hidden = badge.getBoolean("hidden", true);
|
|
230
|
+
String text = !hidden ? badge.getString("text", "") : "";
|
|
231
|
+
boolean dot = !hidden && badge.getBoolean("dot", false);
|
|
232
|
+
|
|
233
|
+
tab.putString("badgeText", text);
|
|
234
|
+
tab.putBoolean("dot", dot);
|
|
254
235
|
}
|
|
255
236
|
}
|
|
256
237
|
|
|
257
238
|
reactRootView.setAppProperties(getProps(tabBarFragment));
|
|
258
239
|
}
|
|
259
|
-
|
|
260
|
-
|
|
240
|
+
|
|
261
241
|
private void updateTabBarAppearance(@Nullable Bundle bundle) {
|
|
262
242
|
if (bundle == null) {
|
|
263
243
|
return;
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/NavigatorRegistry.java
CHANGED
|
@@ -5,7 +5,7 @@ import androidx.annotation.Nullable;
|
|
|
5
5
|
|
|
6
6
|
import com.navigation.androidx.AwesomeFragment;
|
|
7
7
|
import com.navigation.androidx.DrawerFragment;
|
|
8
|
-
import com.navigation.androidx.
|
|
8
|
+
import com.navigation.androidx.StackFragment;
|
|
9
9
|
import com.navigation.androidx.TabBarFragment;
|
|
10
10
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
11
11
|
|
|
@@ -63,7 +63,7 @@ public class NavigatorRegistry {
|
|
|
63
63
|
if (fragment instanceof HybridFragment) {
|
|
64
64
|
return "screen";
|
|
65
65
|
}
|
|
66
|
-
if (fragment instanceof
|
|
66
|
+
if (fragment instanceof StackFragment) {
|
|
67
67
|
return "stack";
|
|
68
68
|
}
|
|
69
69
|
if (fragment instanceof TabBarFragment) {
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java
CHANGED
|
@@ -12,7 +12,7 @@ import com.navigation.androidx.AwesomeFragment;
|
|
|
12
12
|
import com.navigation.androidx.FragmentHelper;
|
|
13
13
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
14
14
|
import com.reactnative.hybridnavigation.ReactBridgeManager;
|
|
15
|
-
import com.reactnative.hybridnavigation.
|
|
15
|
+
import com.reactnative.hybridnavigation.ReactStackFragment;
|
|
16
16
|
|
|
17
17
|
import java.util.Arrays;
|
|
18
18
|
import java.util.List;
|
|
@@ -99,9 +99,9 @@ public class ScreenNavigator implements Navigator {
|
|
|
99
99
|
fragment = createFragmentWithExtras(extras);
|
|
100
100
|
if (fragment != null) {
|
|
101
101
|
int requestCode = extras.getInt("requestCode");
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
target.presentFragment(
|
|
102
|
+
ReactStackFragment stackFragment = new ReactStackFragment();
|
|
103
|
+
stackFragment.setRootFragment(fragment);
|
|
104
|
+
target.presentFragment(stackFragment, requestCode, () -> promise.resolve(true));
|
|
105
105
|
} else {
|
|
106
106
|
promise.resolve(false);
|
|
107
107
|
}
|
|
@@ -118,13 +118,13 @@ public class ScreenNavigator implements Navigator {
|
|
|
118
118
|
fragment = createFragmentWithExtras(extras);
|
|
119
119
|
if (fragment != null) {
|
|
120
120
|
int requestCode = extras.getInt("requestCode");
|
|
121
|
-
target.
|
|
121
|
+
target.showAsDialog(fragment, requestCode, () -> promise.resolve(true));
|
|
122
122
|
} else {
|
|
123
123
|
promise.resolve(false);
|
|
124
124
|
}
|
|
125
125
|
break;
|
|
126
126
|
case "hideModal":
|
|
127
|
-
target.
|
|
127
|
+
target.hideAsDialog(() -> promise.resolve(true));
|
|
128
128
|
break;
|
|
129
129
|
case "presentLayout":
|
|
130
130
|
ReadableMap layout = extras.getMap("layout");
|
|
@@ -141,7 +141,7 @@ public class ScreenNavigator implements Navigator {
|
|
|
141
141
|
fragment = getReactBridgeManager().createFragment(modalLayout);
|
|
142
142
|
if (fragment != null) {
|
|
143
143
|
int requestCode = extras.getInt("requestCode");
|
|
144
|
-
target.
|
|
144
|
+
target.showAsDialog(fragment, requestCode, () -> promise.resolve(true));
|
|
145
145
|
} else {
|
|
146
146
|
promise.resolve(false);
|
|
147
147
|
}
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java
CHANGED
|
@@ -14,11 +14,11 @@ import com.facebook.react.bridge.ReadableArray;
|
|
|
14
14
|
import com.facebook.react.bridge.ReadableMap;
|
|
15
15
|
import com.navigation.androidx.AwesomeFragment;
|
|
16
16
|
import com.navigation.androidx.DrawerFragment;
|
|
17
|
-
import com.navigation.androidx.
|
|
17
|
+
import com.navigation.androidx.StackFragment;
|
|
18
18
|
import com.navigation.androidx.TabBarFragment;
|
|
19
19
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
20
20
|
import com.reactnative.hybridnavigation.ReactBridgeManager;
|
|
21
|
-
import com.reactnative.hybridnavigation.
|
|
21
|
+
import com.reactnative.hybridnavigation.ReactStackFragment;
|
|
22
22
|
|
|
23
23
|
import java.util.ArrayList;
|
|
24
24
|
import java.util.Arrays;
|
|
@@ -55,9 +55,9 @@ public class StackNavigator implements Navigator {
|
|
|
55
55
|
ReadableMap root = children.getMap(0);
|
|
56
56
|
AwesomeFragment rootFragment = getReactBridgeManager().createFragment(root);
|
|
57
57
|
if (rootFragment != null) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return
|
|
58
|
+
ReactStackFragment stackFragment = new ReactStackFragment();
|
|
59
|
+
stackFragment.setRootFragment(rootFragment);
|
|
60
|
+
return stackFragment;
|
|
61
61
|
} else {
|
|
62
62
|
throw new IllegalArgumentException("can't create stack component with " + layout);
|
|
63
63
|
}
|
|
@@ -68,8 +68,8 @@ public class StackNavigator implements Navigator {
|
|
|
68
68
|
@Nullable
|
|
69
69
|
@Override
|
|
70
70
|
public Bundle buildRouteGraph(@NonNull AwesomeFragment fragment) {
|
|
71
|
-
if (fragment instanceof
|
|
72
|
-
|
|
71
|
+
if (fragment instanceof StackFragment && fragment.isAdded()) {
|
|
72
|
+
StackFragment stack = (StackFragment) fragment;
|
|
73
73
|
ArrayList<Bundle> children = new ArrayList<>();
|
|
74
74
|
List<AwesomeFragment> fragments = stack.getChildFragments();
|
|
75
75
|
for (int i = 0; i < fragments.size(); i++) {
|
|
@@ -91,8 +91,8 @@ public class StackNavigator implements Navigator {
|
|
|
91
91
|
|
|
92
92
|
@Override
|
|
93
93
|
public HybridFragment primaryFragment(@NonNull AwesomeFragment fragment) {
|
|
94
|
-
if (fragment instanceof
|
|
95
|
-
|
|
94
|
+
if (fragment instanceof StackFragment && fragment.isAdded()) {
|
|
95
|
+
StackFragment stack = (StackFragment) fragment;
|
|
96
96
|
return getReactBridgeManager().primaryFragment(stack.getTopFragment());
|
|
97
97
|
}
|
|
98
98
|
return null;
|
|
@@ -100,8 +100,8 @@ public class StackNavigator implements Navigator {
|
|
|
100
100
|
|
|
101
101
|
@Override
|
|
102
102
|
public void handleNavigation(@NonNull AwesomeFragment target, @NonNull String action, @NonNull ReadableMap extras, @NonNull Promise promise) {
|
|
103
|
-
|
|
104
|
-
if (
|
|
103
|
+
StackFragment stackFragment = getStackFragment(target);
|
|
104
|
+
if (stackFragment == null) {
|
|
105
105
|
promise.resolve(false);
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
@@ -112,18 +112,18 @@ public class StackNavigator implements Navigator {
|
|
|
112
112
|
case "push":
|
|
113
113
|
fragment = createFragmentWithExtras(extras);
|
|
114
114
|
if (fragment != null) {
|
|
115
|
-
|
|
115
|
+
stackFragment.pushFragment(fragment, true, () -> promise.resolve(true));
|
|
116
116
|
} else {
|
|
117
117
|
promise.resolve(false);
|
|
118
118
|
}
|
|
119
119
|
break;
|
|
120
120
|
case "pop":
|
|
121
|
-
|
|
121
|
+
stackFragment.popFragment(true, () -> promise.resolve(true));
|
|
122
122
|
break;
|
|
123
123
|
case "popTo":
|
|
124
124
|
String moduleName = extras.getString("moduleName");
|
|
125
125
|
boolean inclusive = extras.getBoolean("inclusive");
|
|
126
|
-
FragmentManager fragmentManager =
|
|
126
|
+
FragmentManager fragmentManager = stackFragment.getChildFragmentManager();
|
|
127
127
|
int count = fragmentManager.getBackStackEntryCount();
|
|
128
128
|
for (int i = count - 1; i > -1; i--) {
|
|
129
129
|
FragmentManager.BackStackEntry entry = fragmentManager.getBackStackEntryAt(i);
|
|
@@ -145,18 +145,18 @@ public class StackNavigator implements Navigator {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
if (fragment != null) {
|
|
148
|
-
|
|
148
|
+
stackFragment.popToFragment(fragment, true, () -> promise.resolve(true));
|
|
149
149
|
} else {
|
|
150
150
|
promise.resolve(false);
|
|
151
151
|
}
|
|
152
152
|
break;
|
|
153
153
|
case "popToRoot":
|
|
154
|
-
|
|
154
|
+
stackFragment.popToRootFragment(true, () -> promise.resolve(true));
|
|
155
155
|
break;
|
|
156
156
|
case "redirectTo":
|
|
157
157
|
fragment = createFragmentWithExtras(extras);
|
|
158
158
|
if (fragment != null) {
|
|
159
|
-
|
|
159
|
+
stackFragment.redirectToFragment(fragment, true, () -> promise.resolve(true), target);
|
|
160
160
|
} else {
|
|
161
161
|
promise.resolve(false);
|
|
162
162
|
}
|
|
@@ -165,7 +165,7 @@ public class StackNavigator implements Navigator {
|
|
|
165
165
|
ReadableMap layout = extras.getMap("layout");
|
|
166
166
|
fragment = getReactBridgeManager().createFragment(layout);
|
|
167
167
|
if (fragment != null) {
|
|
168
|
-
|
|
168
|
+
stackFragment.pushFragment(fragment, true, () -> promise.resolve(true));
|
|
169
169
|
} else {
|
|
170
170
|
promise.resolve(false);
|
|
171
171
|
}
|
|
@@ -192,19 +192,19 @@ public class StackNavigator implements Navigator {
|
|
|
192
192
|
return fragment;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
private
|
|
195
|
+
private StackFragment getStackFragment(AwesomeFragment fragment) {
|
|
196
196
|
if (fragment != null) {
|
|
197
|
-
|
|
198
|
-
if (
|
|
197
|
+
StackFragment stackFragment = fragment.getStackFragment();
|
|
198
|
+
if (stackFragment == null && fragment.getDrawerFragment() != null) {
|
|
199
199
|
DrawerFragment drawerFragment = fragment.getDrawerFragment();
|
|
200
200
|
TabBarFragment tabBarFragment = drawerFragment.getContentFragment().getTabBarFragment();
|
|
201
201
|
if (tabBarFragment != null) {
|
|
202
|
-
|
|
202
|
+
stackFragment = tabBarFragment.getSelectedFragment().getStackFragment();
|
|
203
203
|
} else {
|
|
204
|
-
|
|
204
|
+
stackFragment = drawerFragment.getContentFragment().getStackFragment();
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
-
return
|
|
207
|
+
return stackFragment;
|
|
208
208
|
}
|
|
209
209
|
return null;
|
|
210
210
|
}
|
|
@@ -9,7 +9,7 @@ import com.facebook.react.bridge.Promise;
|
|
|
9
9
|
import com.facebook.react.bridge.ReadableArray;
|
|
10
10
|
import com.facebook.react.bridge.ReadableMap;
|
|
11
11
|
import com.navigation.androidx.AwesomeFragment;
|
|
12
|
-
import com.navigation.androidx.
|
|
12
|
+
import com.navigation.androidx.StackFragment;
|
|
13
13
|
import com.navigation.androidx.TabBarFragment;
|
|
14
14
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
15
15
|
import com.reactnative.hybridnavigation.ReactBridgeManager;
|
|
@@ -152,9 +152,9 @@ public class TabNavigator implements Navigator {
|
|
|
152
152
|
|
|
153
153
|
boolean popToRoot = extras.hasKey("popToRoot") && extras.getBoolean("popToRoot");
|
|
154
154
|
if (popToRoot) {
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
|
|
155
|
+
StackFragment stackFragment = tabBarFragment.getSelectedFragment().getStackFragment();
|
|
156
|
+
if (stackFragment != null && stackFragment.getChildFragments().size() > 1) {
|
|
157
|
+
stackFragment.popToRootFragment(false);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -244,9 +244,9 @@ protected void onCreateMainComponent() {
|
|
|
244
244
|
// super.onCreateMainComponent();
|
|
245
245
|
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
246
246
|
|
|
247
|
-
|
|
247
|
+
ReactStackFragment navigation = new ReactStackFragment();
|
|
248
248
|
navigation.setRootFragment(bridgeManager.createFragment("Navigation"));
|
|
249
|
-
|
|
249
|
+
ReactStackFragment options = new ReactStackFragment();
|
|
250
250
|
options.setRootFragment(bridgeManager.createFragment("Options"));
|
|
251
251
|
|
|
252
252
|
ReactTabBarFragment tabBarFragment = new ReactTabBarFragment();
|
|
@@ -262,7 +262,7 @@ protected void onCreateMainComponent() {
|
|
|
262
262
|
@Override
|
|
263
263
|
protected void onCreateMainComponent() {
|
|
264
264
|
AwesomeFragment home = getReactBridgeManager().createFragment("Home");
|
|
265
|
-
|
|
265
|
+
ReactStackFragment navigation = new ReactStackFragment();
|
|
266
266
|
navigation.setRootFragment(home);
|
|
267
267
|
|
|
268
268
|
setActivityRootFragment(navigation);
|
|
@@ -90,13 +90,13 @@ HBDViewController *vc = [[HBDReactBridgeManager get] controllerWithModuleName:@"
|
|
|
90
90
|
|
|
91
91
|
```java
|
|
92
92
|
// android
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
|
|
93
|
+
StackFragment stackFragment = getStackFragment();
|
|
94
|
+
if (stackFragment != null) {
|
|
95
|
+
stackFragment.pushFragment(fragment);
|
|
96
96
|
}
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
关于
|
|
99
|
+
关于 StackFragment 的更多细节,请看 [AndroidNavigation](https://github.com/listenzz/AndroidNavigation) 这个子项目。
|
|
100
100
|
|
|
101
101
|
```objc
|
|
102
102
|
// ios
|
package/docs/qa.md
CHANGED
|
@@ -36,3 +36,20 @@ module.exports = {
|
|
|
36
36
|
},
|
|
37
37
|
}
|
|
38
38
|
```
|
|
39
|
+
|
|
40
|
+
## 如何拦截 Android 物理返回键
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
useVisibleEffect(
|
|
44
|
+
useCallback(() => {
|
|
45
|
+
const handleBackPress = () => {
|
|
46
|
+
console.log('---------------')
|
|
47
|
+
// true 表示拦截,false 表示不拦截
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
BackHandler.addEventListener('hardwareBackPress', handleBackPress)
|
|
52
|
+
return () => BackHandler.removeEventListener('hardwareBackPress', handleBackPress)
|
|
53
|
+
}, []),
|
|
54
|
+
)
|
|
55
|
+
```
|