hybrid-navigation 2.20.1 → 3.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 +7 -5
- package/README.md +17 -0
- package/android/build.gradle +56 -19
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +320 -326
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +13 -20
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridFragment.java +6 -11
- package/android/src/main/java/com/reactnative/hybridnavigation/HybridNavigationPackage.java +55 -21
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeEvent.java +31 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeGarden.java +223 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/NativeNavigation.java +370 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +239 -224
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +177 -198
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactDrawerFragment.java +2 -9
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +41 -78
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactManager.java +438 -0
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactStackFragment.java +10 -19
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBar.java +7 -15
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarFragment.java +135 -173
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +54 -227
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +2 -3
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/DrawerNavigator.java +12 -14
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +18 -21
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java +17 -20
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/TabNavigator.java +13 -26
- package/dist/NativeEvent.d.ts +33 -0
- package/dist/NativeEvent.js +2 -0
- package/dist/NativeGarden.d.ts +18 -0
- package/dist/NativeGarden.js +2 -0
- package/dist/NativeNavigation.d.ts +47 -0
- package/dist/NativeNavigation.js +2 -0
- package/dist/Navigation.js +3 -3
- package/dist/NavigationModule.d.ts +3 -3
- package/dist/NavigationModule.js +18 -19
- package/dist/Navigator.js +1 -2
- package/dist/Options.d.ts +4 -7
- package/dist/Route.d.ts +0 -2
- package/dist/handler/BarButtonEventHandler.js +2 -2
- package/dist/handler/LayoutCommandHandler.js +3 -3
- package/dist/handler/ResultEventHandler.js +3 -3
- package/dist/handler/VisibilityEventHandler.js +11 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/ios/HybridNavigation/GlobalStyle.h +0 -6
- package/ios/HybridNavigation/{GlobalStyle.m → GlobalStyle.mm} +54 -44
- package/ios/HybridNavigation/HBDUtils.h +0 -4
- package/ios/HybridNavigation/{HBDUtils.m → HBDUtils.mm} +0 -41
- package/ios/HybridNavigation/Navigator/{HBDScreenNavigator.m → HBDScreenNavigator.mm} +3 -9
- package/ios/HybridNavigation/Navigator/{HBDStackNavigator.m → HBDStackNavigator.mm} +0 -4
- package/ios/HybridNavigation/Navigator/{HBDTabNavigator.m → HBDTabNavigator.mm} +1 -55
- package/ios/HybridNavigation/React/HBDNativeEvent.h +13 -0
- package/ios/HybridNavigation/React/HBDNativeEvent.mm +31 -0
- package/ios/HybridNavigation/React/HBDNativeGarden.h +10 -0
- package/ios/HybridNavigation/React/HBDNativeGarden.mm +151 -0
- package/ios/HybridNavigation/React/HBDNativeNavigation.h +11 -0
- package/ios/HybridNavigation/React/HBDNativeNavigation.mm +263 -0
- package/ios/HybridNavigation/{ReactBridge → React}/HBDReactBridgeManager.h +3 -1
- package/ios/HybridNavigation/{ReactBridge/HBDReactBridgeManager.m → React/HBDReactBridgeManager.mm} +7 -30
- package/ios/HybridNavigation/View/HBDRootView.h +2 -2
- package/ios/HybridNavigation/View/{HBDRootView.m → HBDRootView.mm} +2 -2
- package/ios/HybridNavigation/View/HBDTitleView.h +2 -2
- package/ios/HybridNavigation/View/{HBDTitleView.m → HBDTitleView.mm} +3 -3
- package/ios/HybridNavigation/View/UIImage+WithBadge.h +13 -0
- package/ios/HybridNavigation/View/UIImage+WithBadge.mm +36 -0
- package/ios/HybridNavigation/ViewController/{HBDDrawerController.m → HBDDrawerController.mm} +2 -25
- package/ios/HybridNavigation/ViewController/HBDReactViewController.h +0 -4
- package/ios/HybridNavigation/ViewController/{HBDReactViewController.m → HBDReactViewController.mm} +40 -31
- package/ios/HybridNavigation/ViewController/HBDTabBarController.h +0 -2
- package/ios/HybridNavigation/ViewController/HBDTabBarController.mm +140 -0
- package/ios/HybridNavigation/ViewController/HBDViewController+Garden.h +0 -2
- package/ios/HybridNavigation/ViewController/{HBDViewController+Garden.m → HBDViewController+Garden.mm} +8 -26
- package/ios/HybridNavigation/ViewController/HBDViewController.h +2 -0
- package/ios/HybridNavigation/ViewController/{HBDViewController.m → HBDViewController.mm} +67 -57
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.h +0 -2
- package/ios/HybridNavigation/ViewController/{UIViewController+HBD.m → UIViewController+HBD.mm} +1 -42
- package/package.json +11 -2
- package/src/DeepLink.ts +3 -3
- package/src/NativeEvent.ts +40 -0
- package/src/NativeGarden.ts +27 -0
- package/src/NativeNavigation.ts +72 -0
- package/src/Navigation.ts +13 -13
- package/src/NavigationComponentWrap.tsx +4 -4
- package/src/NavigationModule.ts +21 -46
- package/src/Navigator.ts +13 -13
- package/src/Options.ts +9 -9
- package/src/Route.ts +0 -2
- package/src/handler/BarButtonEventHandler.ts +4 -8
- package/src/handler/DispatchCommandHandler.ts +4 -8
- package/src/handler/LayoutCommandHandler.ts +4 -5
- package/src/handler/ResultEventHandler.ts +11 -27
- package/src/handler/VisibilityEventHandler.ts +23 -32
- package/src/hooks.ts +2 -2
- package/src/index.ts +4 -5
- package/src/router/drawer.ts +5 -5
- package/src/router/index.ts +15 -15
- package/src/router/screen.ts +2 -2
- package/src/router/stack.ts +4 -4
- package/src/router/tabs.ts +3 -3
- package/src/store.ts +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/DefaultTabBarProvider.java +0 -143
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +0 -230
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDEventEmitter.java +0 -89
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +0 -71
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +0 -370
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +0 -445
- package/dist/Event.d.ts +0 -16
- package/dist/Event.js +0 -62
- package/dist/GardenModule.d.ts +0 -24
- package/dist/GardenModule.js +0 -21
- package/ios/HybridNavigation/HBDAnimationObserver.h +0 -24
- package/ios/HybridNavigation/HBDAnimationObserver.m +0 -45
- package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.h +0 -28
- package/ios/HybridNavigation/ReactBridge/HBDEventEmitter.m +0 -72
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.h +0 -6
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +0 -157
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.h +0 -6
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +0 -249
- package/ios/HybridNavigation/View/HBDReactTabBar.h +0 -9
- package/ios/HybridNavigation/View/HBDReactTabBar.m +0 -36
- package/ios/HybridNavigation/View/UITabBar+Badge.h +0 -9
- package/ios/HybridNavigation/View/UITabBar+Badge.m +0 -46
- package/ios/HybridNavigation/ViewController/HBDTabBarController.m +0 -265
- package/src/Event.ts +0 -117
- package/src/GardenModule.ts +0 -50
- /package/ios/HybridNavigation/Navigator/{HBDDrawerNavigator.m → HBDDrawerNavigator.mm} +0 -0
- /package/ios/HybridNavigation/Navigator/{HBDNavigatorRegistry.m → HBDNavigatorRegistry.mm} +0 -0
- /package/ios/HybridNavigation/{ReactBridge → React}/HBDNavigator.h +0 -0
- /package/ios/HybridNavigation/View/{HBDBackBarButtonItem.m → HBDBackBarButtonItem.mm} +0 -0
- /package/ios/HybridNavigation/View/{HBDBarButtonItem.m → HBDBarButtonItem.mm} +0 -0
- /package/ios/HybridNavigation/View/{HBDNavigationBar.m → HBDNavigationBar.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDFadeAnimation.m → HBDFadeAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDNavigationController.m → HBDNavigationController.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDPopAnimation.m → HBDPopAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{HBDPushAnimation.m → HBDPushAnimation.mm} +0 -0
- /package/ios/HybridNavigation/ViewController/{UINavigationController+HBD.m → UINavigationController+HBD.mm} +0 -0
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/StackNavigator.java
CHANGED
|
@@ -19,7 +19,7 @@ import com.navigation.androidx.TabBarFragment;
|
|
|
19
19
|
import com.navigation.androidx.TransitionAnimation;
|
|
20
20
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
21
21
|
import com.reactnative.hybridnavigation.Navigator;
|
|
22
|
-
import com.reactnative.hybridnavigation.
|
|
22
|
+
import com.reactnative.hybridnavigation.ReactManager;
|
|
23
23
|
import com.reactnative.hybridnavigation.ReactStackFragment;
|
|
24
24
|
|
|
25
25
|
import java.util.ArrayList;
|
|
@@ -60,7 +60,7 @@ public class StackNavigator implements Navigator {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
ReadableMap root = children.getMap(0);
|
|
63
|
-
AwesomeFragment rootFragment =
|
|
63
|
+
AwesomeFragment rootFragment = getReactManager().createFragment(root);
|
|
64
64
|
if (rootFragment == null) {
|
|
65
65
|
throw new IllegalArgumentException("can't create stack component with " + layout);
|
|
66
66
|
}
|
|
@@ -73,15 +73,14 @@ public class StackNavigator implements Navigator {
|
|
|
73
73
|
@Nullable
|
|
74
74
|
@Override
|
|
75
75
|
public Bundle buildRouteGraph(@NonNull AwesomeFragment fragment) {
|
|
76
|
-
if (!(fragment instanceof StackFragment) || !fragment.isAdded()) {
|
|
76
|
+
if (!(fragment instanceof StackFragment stackFragment) || !fragment.isAdded()) {
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
ArrayList<Bundle> children = buildChildrenGraph(stack);
|
|
80
|
+
ArrayList<Bundle> children = buildChildrenGraph(stackFragment);
|
|
82
81
|
Bundle graph = new Bundle();
|
|
83
82
|
graph.putString("layout", name());
|
|
84
|
-
graph.putString("sceneId",
|
|
83
|
+
graph.putString("sceneId", stackFragment.getSceneId());
|
|
85
84
|
graph.putParcelableArrayList("children", children);
|
|
86
85
|
graph.putString("mode", Navigator.Util.getMode(fragment));
|
|
87
86
|
return graph;
|
|
@@ -93,7 +92,7 @@ public class StackNavigator implements Navigator {
|
|
|
93
92
|
List<AwesomeFragment> fragments = stack.getChildAwesomeFragments();
|
|
94
93
|
for (int i = 0; i < fragments.size(); i++) {
|
|
95
94
|
AwesomeFragment child = fragments.get(i);
|
|
96
|
-
Bundle graph =
|
|
95
|
+
Bundle graph = getReactManager().buildRouteGraph(child);
|
|
97
96
|
if (graph != null) {
|
|
98
97
|
children.add(graph);
|
|
99
98
|
}
|
|
@@ -103,13 +102,12 @@ public class StackNavigator implements Navigator {
|
|
|
103
102
|
|
|
104
103
|
@Override
|
|
105
104
|
public HybridFragment primaryFragment(@NonNull AwesomeFragment fragment) {
|
|
106
|
-
if (!(fragment instanceof StackFragment) || !fragment.isAdded()) {
|
|
105
|
+
if (!(fragment instanceof StackFragment stackFragment) || !fragment.isAdded()) {
|
|
107
106
|
return null;
|
|
108
107
|
}
|
|
109
|
-
|
|
110
|
-
return getReactBridgeManager().primaryFragment(stack.getTopFragment());
|
|
108
|
+
return getReactManager().primaryFragment(stackFragment.getTopFragment());
|
|
111
109
|
}
|
|
112
|
-
|
|
110
|
+
|
|
113
111
|
@Override
|
|
114
112
|
public void handleNavigation(@NonNull AwesomeFragment target, @NonNull String action, @NonNull ReadableMap extras, @NonNull Callback callback) {
|
|
115
113
|
StackFragment stackFragment = getStackFragment(target);
|
|
@@ -142,7 +140,7 @@ public class StackNavigator implements Navigator {
|
|
|
142
140
|
|
|
143
141
|
private void handlePushLayout(@NonNull StackFragment stackFragment, @NonNull ReadableMap extras, @NonNull Callback callback) {
|
|
144
142
|
ReadableMap layout = extras.getMap("layout");
|
|
145
|
-
AwesomeFragment fragment =
|
|
143
|
+
AwesomeFragment fragment = getReactManager().createFragment(layout);
|
|
146
144
|
if (fragment == null) {
|
|
147
145
|
callback.invoke(null, false);
|
|
148
146
|
return;
|
|
@@ -165,7 +163,7 @@ public class StackNavigator implements Navigator {
|
|
|
165
163
|
callback.invoke(null, false);
|
|
166
164
|
return;
|
|
167
165
|
}
|
|
168
|
-
|
|
166
|
+
|
|
169
167
|
FragmentManager fragmentManager = stackFragment.getChildFragmentManager();
|
|
170
168
|
AwesomeFragment fragment = findFragmentForPopTo(moduleName, inclusive(extras), fragmentManager);
|
|
171
169
|
if (fragment == null) {
|
|
@@ -175,7 +173,7 @@ public class StackNavigator implements Navigator {
|
|
|
175
173
|
|
|
176
174
|
stackFragment.popToFragment(fragment, () -> callback.invoke(null, true));
|
|
177
175
|
}
|
|
178
|
-
|
|
176
|
+
|
|
179
177
|
private boolean inclusive(@NonNull ReadableMap extras) {
|
|
180
178
|
if (extras.hasKey("inclusive")) {
|
|
181
179
|
return extras.getBoolean("inclusive");
|
|
@@ -193,12 +191,11 @@ public class StackNavigator implements Navigator {
|
|
|
193
191
|
}
|
|
194
192
|
|
|
195
193
|
Fragment fragment = fragmentManager.findFragmentByTag(entry.getName());
|
|
196
|
-
if (!(fragment instanceof HybridFragment)) {
|
|
194
|
+
if (!(fragment instanceof HybridFragment hybridFragment)) {
|
|
197
195
|
continue;
|
|
198
196
|
}
|
|
199
197
|
|
|
200
|
-
|
|
201
|
-
boolean match = moduleName.equals(hybridFragment.getModuleName()) || moduleName.equals(hybridFragment.getSceneId());
|
|
198
|
+
boolean match = moduleName.equals(hybridFragment.getModuleName()) || moduleName.equals(hybridFragment.getSceneId());
|
|
202
199
|
if (!match) {
|
|
203
200
|
continue;
|
|
204
201
|
}
|
|
@@ -234,7 +231,7 @@ public class StackNavigator implements Navigator {
|
|
|
234
231
|
|
|
235
232
|
Bundle props = buildProps(extras);
|
|
236
233
|
Bundle options = buildOptions(extras);
|
|
237
|
-
return
|
|
234
|
+
return getReactManager().createFragment(moduleName, props, options);
|
|
238
235
|
}
|
|
239
236
|
|
|
240
237
|
@Nullable
|
|
@@ -281,7 +278,7 @@ public class StackNavigator implements Navigator {
|
|
|
281
278
|
return drawerFragment.requireContentFragment().getStackFragment();
|
|
282
279
|
}
|
|
283
280
|
|
|
284
|
-
private
|
|
285
|
-
return
|
|
281
|
+
private ReactManager getReactManager() {
|
|
282
|
+
return ReactManager.get();
|
|
286
283
|
}
|
|
287
284
|
}
|
|
@@ -14,7 +14,7 @@ import com.navigation.androidx.TabBarFragment;
|
|
|
14
14
|
import com.navigation.androidx.TransitionAnimation;
|
|
15
15
|
import com.reactnative.hybridnavigation.HybridFragment;
|
|
16
16
|
import com.reactnative.hybridnavigation.Navigator;
|
|
17
|
-
import com.reactnative.hybridnavigation.
|
|
17
|
+
import com.reactnative.hybridnavigation.ReactManager;
|
|
18
18
|
import com.reactnative.hybridnavigation.ReactTabBarFragment;
|
|
19
19
|
|
|
20
20
|
import java.util.ArrayList;
|
|
@@ -56,7 +56,7 @@ public class TabNavigator implements Navigator {
|
|
|
56
56
|
|
|
57
57
|
List<AwesomeFragment> fragments = createChildrenFragment(children);
|
|
58
58
|
|
|
59
|
-
if (fragments.
|
|
59
|
+
if (fragments.isEmpty()) {
|
|
60
60
|
throw new IllegalArgumentException("tabs layout should has a child at least");
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -82,16 +82,6 @@ public class TabNavigator implements Navigator {
|
|
|
82
82
|
bundle.putInt("selectedIndex", selectedIndex);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
if (options.hasKey("tabBarModuleName")) {
|
|
86
|
-
String tabBarModuleName = options.getString("tabBarModuleName");
|
|
87
|
-
bundle.putString("tabBarModuleName", tabBarModuleName);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (options.hasKey("sizeIndeterminate")) {
|
|
91
|
-
boolean sizeIndeterminate = options.getBoolean("sizeIndeterminate");
|
|
92
|
-
bundle.putBoolean("sizeIndeterminate", sizeIndeterminate);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
85
|
tabBarFragment.setOptions(bundle);
|
|
96
86
|
}
|
|
97
87
|
|
|
@@ -100,7 +90,7 @@ public class TabNavigator implements Navigator {
|
|
|
100
90
|
List<AwesomeFragment> fragments = new ArrayList<>();
|
|
101
91
|
for (int i = 0, size = children.size(); i < size; i++) {
|
|
102
92
|
ReadableMap child = children.getMap(i);
|
|
103
|
-
AwesomeFragment awesomeFragment =
|
|
93
|
+
AwesomeFragment awesomeFragment = getReactManager().createFragment(child);
|
|
104
94
|
if (awesomeFragment != null) {
|
|
105
95
|
fragments.add(awesomeFragment);
|
|
106
96
|
}
|
|
@@ -111,18 +101,17 @@ public class TabNavigator implements Navigator {
|
|
|
111
101
|
@Nullable
|
|
112
102
|
@Override
|
|
113
103
|
public Bundle buildRouteGraph(@NonNull AwesomeFragment fragment) {
|
|
114
|
-
if (!(fragment instanceof TabBarFragment) || !fragment.isAdded()) {
|
|
104
|
+
if (!(fragment instanceof TabBarFragment tabBarFragment) || !fragment.isAdded()) {
|
|
115
105
|
return null;
|
|
116
106
|
}
|
|
117
107
|
|
|
118
|
-
|
|
119
|
-
ArrayList<Bundle> children = buildChildrenGraph(tabs);
|
|
108
|
+
ArrayList<Bundle> children = buildChildrenGraph(tabBarFragment);
|
|
120
109
|
Bundle graph = new Bundle();
|
|
121
110
|
graph.putString("layout", name());
|
|
122
111
|
graph.putString("sceneId", fragment.getSceneId());
|
|
123
112
|
graph.putParcelableArrayList("children", children);
|
|
124
113
|
graph.putString("mode", Navigator.Util.getMode(fragment));
|
|
125
|
-
graph.putInt("selectedIndex",
|
|
114
|
+
graph.putInt("selectedIndex", tabBarFragment.getSelectedIndex());
|
|
126
115
|
return graph;
|
|
127
116
|
}
|
|
128
117
|
|
|
@@ -132,7 +121,7 @@ public class TabNavigator implements Navigator {
|
|
|
132
121
|
List<AwesomeFragment> fragments = tabs.getChildAwesomeFragments();
|
|
133
122
|
for (int i = 0; i < fragments.size(); i++) {
|
|
134
123
|
AwesomeFragment child = fragments.get(i);
|
|
135
|
-
Bundle graph =
|
|
124
|
+
Bundle graph = getReactManager().buildRouteGraph(child);
|
|
136
125
|
if (graph != null) {
|
|
137
126
|
children.add(graph);
|
|
138
127
|
}
|
|
@@ -142,12 +131,11 @@ public class TabNavigator implements Navigator {
|
|
|
142
131
|
|
|
143
132
|
@Override
|
|
144
133
|
public HybridFragment primaryFragment(@NonNull AwesomeFragment fragment) {
|
|
145
|
-
if (!(fragment instanceof TabBarFragment) || !fragment.isAdded()) {
|
|
134
|
+
if (!(fragment instanceof TabBarFragment tabBarFragment) || !fragment.isAdded()) {
|
|
146
135
|
return null;
|
|
147
136
|
}
|
|
148
137
|
|
|
149
|
-
|
|
150
|
-
return getReactBridgeManager().primaryFragment(tabs.getSelectedFragment());
|
|
138
|
+
return getReactManager().primaryFragment(tabBarFragment.getSelectedFragment());
|
|
151
139
|
}
|
|
152
140
|
|
|
153
141
|
@Override
|
|
@@ -172,13 +160,12 @@ public class TabNavigator implements Navigator {
|
|
|
172
160
|
|
|
173
161
|
popToStackRootIfNeeded(extras, tabBarFragment);
|
|
174
162
|
|
|
175
|
-
if (!(tabBarFragment instanceof ReactTabBarFragment)) {
|
|
163
|
+
if (!(tabBarFragment instanceof ReactTabBarFragment reactTabBarFragment)) {
|
|
176
164
|
tabBarFragment.setSelectedIndex(to, () -> callback.invoke(null, true));
|
|
177
165
|
return;
|
|
178
166
|
}
|
|
179
167
|
|
|
180
|
-
|
|
181
|
-
reactTabBarFragment.setIntercepted(false);
|
|
168
|
+
reactTabBarFragment.setIntercepted(false);
|
|
182
169
|
reactTabBarFragment.setSelectedIndex(to, () -> callback.invoke(null, true));
|
|
183
170
|
reactTabBarFragment.setIntercepted(true);
|
|
184
171
|
}
|
|
@@ -204,8 +191,8 @@ public class TabNavigator implements Navigator {
|
|
|
204
191
|
}
|
|
205
192
|
}
|
|
206
193
|
|
|
207
|
-
private
|
|
208
|
-
return
|
|
194
|
+
private ReactManager getReactManager() {
|
|
195
|
+
return ReactManager.get();
|
|
209
196
|
}
|
|
210
197
|
|
|
211
198
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CodegenTypes, TurboModule } from 'react-native';
|
|
2
|
+
export type ComponentAppearEvent = {
|
|
3
|
+
sceneId: string;
|
|
4
|
+
};
|
|
5
|
+
export type ComponentDisappearEvent = {
|
|
6
|
+
sceneId: string;
|
|
7
|
+
};
|
|
8
|
+
export type BarButtonItemClickEvent = {
|
|
9
|
+
sceneId: string;
|
|
10
|
+
action: string;
|
|
11
|
+
};
|
|
12
|
+
export type ResultEvent = {
|
|
13
|
+
sceneId: string;
|
|
14
|
+
requestCode: number;
|
|
15
|
+
resultCode: number;
|
|
16
|
+
resultData: {};
|
|
17
|
+
};
|
|
18
|
+
export type SwitchTabEvent = {
|
|
19
|
+
sceneId: string;
|
|
20
|
+
from: number;
|
|
21
|
+
to: number;
|
|
22
|
+
};
|
|
23
|
+
export interface Spec extends TurboModule {
|
|
24
|
+
readonly onResult: CodegenTypes.EventEmitter<ResultEvent>;
|
|
25
|
+
readonly willSetRoot: CodegenTypes.EventEmitter<void>;
|
|
26
|
+
readonly didSetRoot: CodegenTypes.EventEmitter<void>;
|
|
27
|
+
readonly onSwitchTab: CodegenTypes.EventEmitter<SwitchTabEvent>;
|
|
28
|
+
readonly onBarButtonItemClick: CodegenTypes.EventEmitter<BarButtonItemClickEvent>;
|
|
29
|
+
readonly onComponentAppear: CodegenTypes.EventEmitter<ComponentAppearEvent>;
|
|
30
|
+
readonly onComponentDisappear: CodegenTypes.EventEmitter<ComponentDisappearEvent>;
|
|
31
|
+
}
|
|
32
|
+
declare const _default: Spec;
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CodegenTypes, TurboModule } from 'react-native';
|
|
2
|
+
export interface Spec extends TurboModule {
|
|
3
|
+
getConstants: () => {
|
|
4
|
+
TOOLBAR_HEIGHT: number;
|
|
5
|
+
};
|
|
6
|
+
setStyle: (style: CodegenTypes.UnsafeObject) => void;
|
|
7
|
+
setTitleItem: (sceneId: string, item: CodegenTypes.UnsafeObject) => void;
|
|
8
|
+
setLeftBarButtonItem: (sceneId: string, item: CodegenTypes.UnsafeObject | null) => void;
|
|
9
|
+
setRightBarButtonItem: (sceneId: string, item: CodegenTypes.UnsafeObject | null) => void;
|
|
10
|
+
setLeftBarButtonItems: (sceneId: string, items: Array<CodegenTypes.UnsafeObject> | null) => void;
|
|
11
|
+
setRightBarButtonItems: (sceneId: string, items: Array<CodegenTypes.UnsafeObject> | null) => void;
|
|
12
|
+
updateOptions: (sceneId: string, options: CodegenTypes.UnsafeObject) => void;
|
|
13
|
+
updateTabBar: (sceneId: string, item: CodegenTypes.UnsafeObject) => void;
|
|
14
|
+
setTabItem: (sceneId: string, item: Array<CodegenTypes.UnsafeObject>) => void;
|
|
15
|
+
setMenuInteractive: (sceneId: string, enabled: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: Spec;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CodegenTypes, TurboModule } from 'react-native';
|
|
2
|
+
type Error = {
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
export type LayoutMode = 'modal' | 'present' | 'normal';
|
|
7
|
+
export interface Route {
|
|
8
|
+
sceneId: string;
|
|
9
|
+
moduleName: string;
|
|
10
|
+
mode: LayoutMode;
|
|
11
|
+
presentingId: string | null;
|
|
12
|
+
requestCode: number;
|
|
13
|
+
}
|
|
14
|
+
export interface RouteGraph {
|
|
15
|
+
layout: string;
|
|
16
|
+
sceneId: string;
|
|
17
|
+
mode: LayoutMode;
|
|
18
|
+
children?: RouteGraph[];
|
|
19
|
+
}
|
|
20
|
+
export type RouteMode = 'modal' | 'present' | 'push';
|
|
21
|
+
export interface RouteConfig {
|
|
22
|
+
path?: string;
|
|
23
|
+
dependency?: string;
|
|
24
|
+
mode?: RouteMode;
|
|
25
|
+
}
|
|
26
|
+
export type ResultType = {} | null;
|
|
27
|
+
export interface Spec extends TurboModule {
|
|
28
|
+
getConstants: () => {
|
|
29
|
+
RESULT_OK: number;
|
|
30
|
+
RESULT_CANCEL: number;
|
|
31
|
+
RESULT_BLOCK: number;
|
|
32
|
+
};
|
|
33
|
+
startRegisterReactComponent: () => void;
|
|
34
|
+
endRegisterReactComponent: () => void;
|
|
35
|
+
registerReactComponent: (appKey: string, options: CodegenTypes.UnsafeObject) => void;
|
|
36
|
+
signalFirstRenderComplete: (sceneId: string) => void;
|
|
37
|
+
setRoot: (layout: CodegenTypes.UnsafeObject, sticky: boolean, callback: (error: Error | null, result: boolean) => void) => void;
|
|
38
|
+
setResult: (sceneId: string, resultCode: number, data: CodegenTypes.UnsafeObject) => void;
|
|
39
|
+
dispatch: (sceneId: string, action: string, params: CodegenTypes.UnsafeObject, callback: (error: Error | null, result: boolean) => void) => void;
|
|
40
|
+
currentTab: (sceneId: string, callback: (error: Error | null, index: number) => void) => void;
|
|
41
|
+
isStackRoot: (sceneId: string, callback: (error: Error | null, result: boolean) => void) => void;
|
|
42
|
+
findSceneIdByModuleName: (moduleName: string, callback: (error: Error | null, sceneId: string | null) => void) => void;
|
|
43
|
+
currentRoute: (callback: (error: Error | null, route: Route) => void) => void;
|
|
44
|
+
routeGraph: (callback: (error: Error | null, graph: RouteGraph[]) => void) => void;
|
|
45
|
+
}
|
|
46
|
+
declare const _default: Spec;
|
|
47
|
+
export default _default;
|
package/dist/Navigation.js
CHANGED
|
@@ -4,9 +4,9 @@ import LayoutCommandHandler from './handler/LayoutCommandHandler';
|
|
|
4
4
|
import DispatchCommandHandler from './handler/DispatchCommandHandler';
|
|
5
5
|
import ResultEventHandler from './handler/ResultEventHandler';
|
|
6
6
|
import VisibilityEventHandler from './handler/VisibilityEventHandler';
|
|
7
|
-
import
|
|
8
|
-
import GardenModule from './GardenModule';
|
|
7
|
+
import NativeEvent from './NativeEvent';
|
|
9
8
|
import NavigationModule from './NavigationModule';
|
|
9
|
+
import GardenModule from './NativeGarden';
|
|
10
10
|
export const { RESULT_CANCEL, RESULT_OK, RESULT_BLOCK } = NavigationModule.getConstants();
|
|
11
11
|
class NavigationImpl {
|
|
12
12
|
dispatchHandler = new DispatchCommandHandler();
|
|
@@ -77,7 +77,7 @@ class NavigationImpl {
|
|
|
77
77
|
return this.dispatchHandler.dispatch(sceneId, action, params);
|
|
78
78
|
}
|
|
79
79
|
handleTabSwitch() {
|
|
80
|
-
|
|
80
|
+
NativeEvent.onSwitchTab(({ sceneId, from, to }) => {
|
|
81
81
|
this.dispatch(sceneId, 'switchTab', { from, to });
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Route, RouteGraph } from './
|
|
1
|
+
import type { Route, RouteGraph, RouteConfig, ResultType } from './NativeNavigation';
|
|
2
2
|
declare function getConstants(): {
|
|
3
3
|
RESULT_OK: number;
|
|
4
4
|
RESULT_CANCEL: number;
|
|
@@ -6,9 +6,9 @@ declare function getConstants(): {
|
|
|
6
6
|
};
|
|
7
7
|
declare function startRegisterReactComponent(): void;
|
|
8
8
|
declare function endRegisterReactComponent(): void;
|
|
9
|
-
declare function registerReactComponent(appKey: string, options:
|
|
9
|
+
declare function registerReactComponent(appKey: string, options: RouteConfig): void;
|
|
10
10
|
declare function signalFirstRenderComplete(sceneId: string): void;
|
|
11
|
-
declare function setResult(sceneId: string, resultCode: number, data:
|
|
11
|
+
declare function setResult<T extends ResultType>(sceneId: string, resultCode: number, data: T): void;
|
|
12
12
|
declare function setRoot(layout: object, sticky: boolean): Promise<boolean>;
|
|
13
13
|
declare function dispatch(sceneId: string, action: string, params: object): Promise<boolean>;
|
|
14
14
|
declare function currentTab(sceneId: string): Promise<number>;
|
package/dist/NavigationModule.js
CHANGED
|
@@ -1,69 +1,68 @@
|
|
|
1
|
-
import
|
|
2
|
-
const NavigationModule = NativeModules.NavigationModule;
|
|
1
|
+
import NativeNavigation from './NativeNavigation';
|
|
3
2
|
function getConstants() {
|
|
4
|
-
return
|
|
3
|
+
return NativeNavigation.getConstants();
|
|
5
4
|
}
|
|
6
5
|
function startRegisterReactComponent() {
|
|
7
|
-
|
|
6
|
+
NativeNavigation.startRegisterReactComponent();
|
|
8
7
|
}
|
|
9
8
|
function endRegisterReactComponent() {
|
|
10
|
-
|
|
9
|
+
NativeNavigation.endRegisterReactComponent();
|
|
11
10
|
}
|
|
12
11
|
function registerReactComponent(appKey, options) {
|
|
13
|
-
|
|
12
|
+
NativeNavigation.registerReactComponent(appKey, options);
|
|
14
13
|
}
|
|
15
14
|
function signalFirstRenderComplete(sceneId) {
|
|
16
|
-
|
|
15
|
+
NativeNavigation.signalFirstRenderComplete(sceneId);
|
|
17
16
|
}
|
|
18
17
|
function setResult(sceneId, resultCode, data) {
|
|
19
|
-
|
|
18
|
+
NativeNavigation.setResult(sceneId, resultCode, data);
|
|
20
19
|
}
|
|
21
20
|
function setRoot(layout, sticky) {
|
|
22
21
|
return new Promise(resolve => {
|
|
23
|
-
|
|
22
|
+
NativeNavigation.setRoot(layout, sticky, (_, success) => {
|
|
24
23
|
resolve(success);
|
|
25
24
|
});
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
function dispatch(sceneId, action, params) {
|
|
29
28
|
return new Promise(resolve => {
|
|
30
|
-
|
|
29
|
+
NativeNavigation.dispatch(sceneId, action, params, (_, result) => {
|
|
31
30
|
resolve(result);
|
|
32
31
|
});
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
function currentTab(sceneId) {
|
|
36
35
|
return new Promise(resolve => {
|
|
37
|
-
|
|
38
|
-
resolve(
|
|
36
|
+
NativeNavigation.currentTab(sceneId, (_, index) => {
|
|
37
|
+
resolve(index);
|
|
39
38
|
});
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
function isStackRoot(sceneId) {
|
|
43
42
|
return new Promise(resolve => {
|
|
44
|
-
|
|
43
|
+
NativeNavigation.isStackRoot(sceneId, (_, result) => {
|
|
45
44
|
resolve(result);
|
|
46
45
|
});
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
function findSceneIdByModuleName(moduleName) {
|
|
50
49
|
return new Promise(resolve => {
|
|
51
|
-
|
|
52
|
-
resolve(
|
|
50
|
+
NativeNavigation.findSceneIdByModuleName(moduleName, (_, sceneId) => {
|
|
51
|
+
resolve(sceneId);
|
|
53
52
|
});
|
|
54
53
|
});
|
|
55
54
|
}
|
|
56
55
|
function currentRoute() {
|
|
57
56
|
return new Promise(resolve => {
|
|
58
|
-
|
|
59
|
-
resolve(
|
|
57
|
+
NativeNavigation.currentRoute((_, route) => {
|
|
58
|
+
resolve(route);
|
|
60
59
|
});
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
62
|
function routeGraph() {
|
|
64
63
|
return new Promise(resolve => {
|
|
65
|
-
|
|
66
|
-
resolve(
|
|
64
|
+
NativeNavigation.routeGraph((_, graph) => {
|
|
65
|
+
resolve(graph);
|
|
67
66
|
});
|
|
68
67
|
});
|
|
69
68
|
}
|
package/dist/Navigator.js
CHANGED
|
@@ -13,7 +13,7 @@ Navigation.setBarButtonClickEventListener((sceneId, value) => {
|
|
|
13
13
|
const navigator = Navigator.of(sceneId);
|
|
14
14
|
value(navigator);
|
|
15
15
|
});
|
|
16
|
-
class Navigator {
|
|
16
|
+
export class Navigator {
|
|
17
17
|
sceneId;
|
|
18
18
|
moduleName;
|
|
19
19
|
static of(sceneId) {
|
|
@@ -163,4 +163,3 @@ class Navigator {
|
|
|
163
163
|
closeMenu = () => Navigation.dispatch(this.sceneId, 'closeMenu', { from: this.moduleName });
|
|
164
164
|
isStackRoot = () => Navigation.isStackRoot(this.sceneId);
|
|
165
165
|
}
|
|
166
|
-
export { Navigator };
|
package/dist/Options.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Insets } from 'react-native';
|
|
2
1
|
import type { Navigator } from './Navigator';
|
|
3
2
|
export type Color = string;
|
|
4
3
|
export type ImageSource = {
|
|
@@ -53,13 +52,11 @@ export interface NavigationItem extends NavigationOption {
|
|
|
53
52
|
rightBarButtonItem?: BarButtonItem;
|
|
54
53
|
leftBarButtonItems?: BarButtonItem[];
|
|
55
54
|
rightBarButtonItems?: BarButtonItem[];
|
|
56
|
-
backItemIOS?: BackItem;
|
|
57
55
|
tabItem?: TabItem;
|
|
58
56
|
}
|
|
59
57
|
export interface BarButtonItem {
|
|
60
58
|
title?: string;
|
|
61
59
|
icon?: ImageSource;
|
|
62
|
-
insetsIOS?: Insets;
|
|
63
60
|
action?: (navigator: Navigator) => void;
|
|
64
61
|
enabled?: boolean;
|
|
65
62
|
tintColor?: Color;
|
|
@@ -109,13 +106,13 @@ export interface DefaultOptions {
|
|
|
109
106
|
scrimAlphaAndroid?: number;
|
|
110
107
|
fitsOpaqueNavigationBarAndroid?: boolean;
|
|
111
108
|
displayCutoutWhenLandscapeAndroid?: boolean;
|
|
112
|
-
|
|
109
|
+
tabBarBackgroundColor?: Color;
|
|
113
110
|
tabBarShadowImage?: ShadowImage;
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
tabBarItemSelectedColor?: Color;
|
|
112
|
+
tabBarItemNormalColor?: Color;
|
|
116
113
|
tabBarBadgeColor?: Color;
|
|
117
114
|
}
|
|
118
|
-
export type TabBarStyle = Pick<DefaultOptions, '
|
|
115
|
+
export type TabBarStyle = Pick<DefaultOptions, 'tabBarBackgroundColor' | 'tabBarShadowImage' | 'tabBarItemSelectedColor' | 'tabBarItemNormalColor'>;
|
|
119
116
|
export interface TabItemInfo {
|
|
120
117
|
index: number;
|
|
121
118
|
title?: string;
|
package/dist/Route.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import NativeEvent from '../NativeEvent';
|
|
2
2
|
export default class BarButtonEventHandler {
|
|
3
3
|
actions = {};
|
|
4
4
|
keyPairs = {};
|
|
@@ -28,7 +28,7 @@ export default class BarButtonEventHandler {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
setBarButtonClickEventListener(handler) {
|
|
31
|
-
|
|
31
|
+
NativeEvent.onBarButtonItemClick(({ sceneId, action }) => {
|
|
32
32
|
const listeners = this.actions;
|
|
33
33
|
if (listeners[action]) {
|
|
34
34
|
handler(sceneId, listeners[action]);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import Event from '../Event';
|
|
2
1
|
import NavigationModule from '../NavigationModule';
|
|
2
|
+
import NativeEvent from '../NativeEvent';
|
|
3
3
|
export default class LayoutCommandHandler {
|
|
4
4
|
willSetRoot = () => { };
|
|
5
5
|
didSetRoot = () => { };
|
|
6
6
|
constructor() { }
|
|
7
7
|
handleRootLayoutChange() {
|
|
8
|
-
|
|
8
|
+
NativeEvent.willSetRoot(() => {
|
|
9
9
|
this.willSetRoot();
|
|
10
10
|
});
|
|
11
|
-
|
|
11
|
+
NativeEvent.didSetRoot(() => {
|
|
12
12
|
this.didSetRoot();
|
|
13
13
|
});
|
|
14
14
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import NativeEvent from '../NativeEvent';
|
|
2
2
|
export default class ResultEventHandler {
|
|
3
3
|
listenerRecords = {};
|
|
4
4
|
constructor() { }
|
|
5
5
|
handleComponentResult() {
|
|
6
|
-
|
|
6
|
+
NativeEvent.onResult(({ sceneId, requestCode, resultCode, resultData }) => {
|
|
7
7
|
const listeners = this.listenerRecords[sceneId]?.[requestCode];
|
|
8
8
|
if (listeners) {
|
|
9
9
|
delete this.listenerRecords[sceneId][requestCode];
|
|
10
|
-
listeners.forEach(l => l(resultCode,
|
|
10
|
+
listeners.forEach(l => l(resultCode, resultData));
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
}
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import NativeEvent from '../NativeEvent';
|
|
2
2
|
export default class VisibilityEventHandler {
|
|
3
3
|
listeners = {};
|
|
4
4
|
globalListeners = [];
|
|
5
5
|
constructor() { }
|
|
6
6
|
handleComponentVisibility() {
|
|
7
|
-
|
|
7
|
+
NativeEvent.onComponentAppear(({ sceneId }) => {
|
|
8
8
|
const listeners = this.listeners[sceneId];
|
|
9
9
|
if (listeners) {
|
|
10
|
-
listeners.forEach(listener => listener(
|
|
10
|
+
listeners.forEach(listener => listener('visible'));
|
|
11
11
|
}
|
|
12
|
-
this.globalListeners.forEach(listener => listener(sceneId,
|
|
12
|
+
this.globalListeners.forEach(listener => listener(sceneId, 'visible'));
|
|
13
|
+
});
|
|
14
|
+
NativeEvent.onComponentDisappear(({ sceneId }) => {
|
|
15
|
+
const listeners = this.listeners[sceneId];
|
|
16
|
+
if (listeners) {
|
|
17
|
+
listeners.forEach(listener => listener('invisible'));
|
|
18
|
+
}
|
|
19
|
+
this.globalListeners.forEach(listener => listener(sceneId, 'invisible'));
|
|
13
20
|
});
|
|
14
21
|
}
|
|
15
22
|
addGlobalVisibilityEventListener(listener) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
declare const Navigation: import("./Navigation").Navigation;
|
|
2
2
|
export default Navigation;
|
|
3
3
|
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation';
|
|
4
|
-
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule';
|
|
5
4
|
export { withNavigationItem } from './NavigationComponentWrap';
|
|
6
5
|
export type { NavigationProps } from './NavigationComponentWrap';
|
|
7
6
|
export * from './Navigator';
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ navigation.setNavigationComponentWrap(withNavigation);
|
|
|
4
4
|
const Navigation = navigation;
|
|
5
5
|
export default Navigation;
|
|
6
6
|
export { RESULT_OK, RESULT_CANCEL, RESULT_BLOCK } from './Navigation';
|
|
7
|
-
export { statusBarHeight, toolbarHeight, topBarHeight } from './GardenModule';
|
|
8
7
|
export { withNavigationItem } from './NavigationComponentWrap';
|
|
9
8
|
export * from './Navigator';
|
|
10
9
|
export * from './hooks';
|
|
@@ -7,13 +7,7 @@
|
|
|
7
7
|
+ (GlobalStyle *)globalStyle;
|
|
8
8
|
|
|
9
9
|
@property(nonatomic, strong, readonly) UIColor *screenBackgroundColor;
|
|
10
|
-
|
|
11
10
|
@property(nonatomic, assign, readonly, getter=isBackTitleHidden) BOOL backTitleHidden;
|
|
12
|
-
|
|
13
|
-
@property(nonatomic, copy) NSString *badgeColorHexString;
|
|
14
|
-
@property(nonatomic, copy) NSString *tabBarItemColorHexString;
|
|
15
|
-
@property(nonatomic, copy) NSString *tabBarUnselectedItemColorHexString;
|
|
16
|
-
@property(nonatomic, strong, readonly) UIColor *tabBarBackgroundColor;
|
|
17
11
|
@property(nonatomic, assign, readonly) BOOL alwaysSplitNavigationBarTransition;
|
|
18
12
|
@property(nonatomic, assign) UIInterfaceOrientationMask interfaceOrientation;
|
|
19
13
|
|