hybrid-navigation 2.13.0 → 2.13.3
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/README.md +4 -4
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Garden.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/GardenModule.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/GlobalStyle.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/HBDReactRootView.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigationModule.java +10 -11
- package/android/src/main/java/com/reactnative/hybridnavigation/NavigatorRegistry.java +0 -2
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivity.java +32 -64
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactBridgeManager.java +8 -8
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFragment.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactFrameLayout.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/ReactTabBarProvider.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/Utils.java +1 -1
- package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java +1 -2
- package/ios/HybridNavigation/HBDUtils.m +3 -3
- package/ios/HybridNavigation/Navigator/HBDNavigatorRegistry.m +2 -2
- package/ios/HybridNavigation/ReactBridge/HBDGardenModule.m +8 -8
- package/ios/HybridNavigation/ReactBridge/HBDNavigationModule.m +22 -15
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.h +2 -3
- package/ios/HybridNavigation/ReactBridge/HBDReactBridgeManager.m +35 -29
- package/ios/HybridNavigation/ViewController/HBDNavigationController.m +2 -2
- package/ios/HybridNavigation/ViewController/HBDViewController.m +1 -1
- package/ios/HybridNavigation/ViewController/UIViewController+HBD.m +1 -1
- package/lib/Event.d.ts +0 -2
- package/lib/Event.js +0 -9
- package/lib/Garden.d.ts +3 -0
- package/lib/Garden.js +3 -0
- package/lib/GardenModule.d.ts +4 -0
- package/lib/GardenModule.js +19 -1
- package/lib/Navigation.d.ts +4 -10
- package/lib/Navigation.js +8 -28
- package/lib/NavigationComponentWrap.d.ts +1 -1
- package/lib/NavigationModule.d.ts +1 -1
- package/lib/NavigationModule.js +6 -2
- package/lib/Navigator.d.ts +5 -2
- package/lib/Navigator.js +35 -15
- package/lib/ReactRegistry.d.ts +3 -0
- package/lib/ReactRegistry.js +3 -0
- package/lib/Route.d.ts +13 -8
- package/lib/handler/DispatchCommandHandler.d.ts +2 -0
- package/lib/handler/LayoutCommandHandler.d.ts +1 -3
- package/lib/handler/LayoutCommandHandler.js +2 -19
- package/lib/hooks.d.ts +4 -0
- package/lib/hooks.js +4 -0
- package/lib/index.d.ts +2 -5
- package/lib/index.js +3 -11
- package/lib/router/drawer.d.ts +3 -1
- package/lib/router/drawer.js +17 -17
- package/lib/router/index.d.ts +19 -15
- package/lib/router/index.js +137 -125
- package/lib/router/screen.d.ts +5 -1
- package/lib/router/screen.js +29 -0
- package/lib/router/stack.d.ts +5 -1
- package/lib/router/stack.js +59 -46
- package/lib/router/tabs.d.ts +3 -1
- package/lib/router/tabs.js +18 -28
- package/package.json +1 -1
- package/src/Event.ts +0 -11
- package/src/Garden.ts +4 -0
- package/src/GardenModule.ts +27 -1
- package/src/Navigation.ts +12 -37
- package/src/NavigationComponentWrap.tsx +1 -3
- package/src/NavigationModule.ts +7 -3
- package/src/Navigator.ts +36 -16
- package/src/ReactRegistry.tsx +3 -0
- package/src/Route.ts +14 -9
- package/src/handler/DispatchCommandHandler.ts +2 -0
- package/src/handler/LayoutCommandHandler.ts +2 -22
- package/src/hooks.ts +4 -1
- package/src/index.ts +3 -29
- package/src/router/drawer.ts +20 -17
- package/src/router/index.ts +145 -131
- package/src/router/screen.ts +34 -1
- package/src/router/stack.ts +61 -48
- package/src/router/tabs.ts +19 -29
package/README.md
CHANGED
|
@@ -29,9 +29,9 @@ cd hybrid-navigation
|
|
|
29
29
|
然后在项目根目录下运行如下命令:
|
|
30
30
|
|
|
31
31
|
```shell
|
|
32
|
-
|
|
32
|
+
yarn install
|
|
33
33
|
# &
|
|
34
|
-
|
|
34
|
+
yarn start
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
### 在 Android 上运行
|
|
@@ -42,7 +42,7 @@ npm start
|
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
44
|
# 在项目根目录下运行
|
|
45
|
-
|
|
45
|
+
yarn android
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
你可能需要运行如下命令,才可以使用 Hot Reload 功能
|
|
@@ -71,7 +71,7 @@ cd -
|
|
|
71
71
|
|
|
72
72
|
```sh
|
|
73
73
|
# 在项目根目录下运行
|
|
74
|
-
|
|
74
|
+
yarn ios
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
## 文档
|
package/android/build.gradle
CHANGED
|
@@ -33,5 +33,5 @@ dependencies {
|
|
|
33
33
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
34
34
|
implementation 'com.facebook.react:react-native:+'
|
|
35
35
|
// api project(':navigation')
|
|
36
|
-
api 'io.github.listenzz:AndroidNavigation:12.5.
|
|
36
|
+
api 'io.github.listenzz:AndroidNavigation:12.5.8'
|
|
37
37
|
}
|
|
@@ -37,7 +37,7 @@ import java.util.Map;
|
|
|
37
37
|
|
|
38
38
|
public class GardenModule extends ReactContextBaseJavaModule {
|
|
39
39
|
|
|
40
|
-
private static final String TAG = "
|
|
40
|
+
private static final String TAG = "Navigation";
|
|
41
41
|
private final ReactBridgeManager bridgeManager;
|
|
42
42
|
|
|
43
43
|
public GardenModule(ReactApplicationContext reactContext, ReactBridgeManager bridgeManager) {
|
|
@@ -15,7 +15,7 @@ import java.lang.reflect.Method;
|
|
|
15
15
|
|
|
16
16
|
public class HBDReactRootView extends ReactRootView {
|
|
17
17
|
|
|
18
|
-
protected static final String TAG = "
|
|
18
|
+
protected static final String TAG = "Navigation";
|
|
19
19
|
|
|
20
20
|
public HBDReactRootView(Context context) {
|
|
21
21
|
super(context);
|
|
@@ -29,7 +29,7 @@ import java.util.Map;
|
|
|
29
29
|
|
|
30
30
|
public class NavigationModule extends ReactContextBaseJavaModule {
|
|
31
31
|
|
|
32
|
-
static final String TAG = "
|
|
32
|
+
static final String TAG = "Navigation";
|
|
33
33
|
private final ReactBridgeManager bridgeManager;
|
|
34
34
|
|
|
35
35
|
NavigationModule(ReactApplicationContext reactContext, ReactBridgeManager bridgeManager) {
|
|
@@ -96,31 +96,30 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
@ReactMethod
|
|
99
|
-
public void setRoot(final ReadableMap layout, final boolean sticky, final
|
|
99
|
+
public void setRoot(final ReadableMap layout, final boolean sticky, final Callback callback) {
|
|
100
100
|
UiThreadUtil.runOnUiThread(() -> {
|
|
101
101
|
ReactContext reactContext = getReactApplicationContext();
|
|
102
102
|
if (reactContext == null || !reactContext.hasActiveReactInstance()) {
|
|
103
103
|
FLog.w(TAG, "ReactContext hasn't active CatalystInstance, skip action `setRoot`");
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
if (bridgeManager.getPendingCallback() != null) {
|
|
108
|
+
bridgeManager.getPendingCallback().invoke(null, false);
|
|
109
|
+
}
|
|
106
110
|
|
|
107
111
|
bridgeManager.setViewHierarchyReady(false);
|
|
108
112
|
bridgeManager.setRootLayout(layout, sticky);
|
|
109
|
-
bridgeManager.setPendingLayout(layout,
|
|
113
|
+
bridgeManager.setPendingLayout(layout, callback);
|
|
110
114
|
|
|
111
115
|
if (!bridgeManager.isReactModuleRegisterCompleted()) {
|
|
112
116
|
return;
|
|
113
117
|
}
|
|
114
|
-
|
|
115
|
-
AwesomeFragment fragment = bridgeManager.createFragment(layout);
|
|
116
|
-
if (fragment == null) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
118
|
+
|
|
120
119
|
ReactAppCompatActivity activity = getActiveActivity();
|
|
121
|
-
if (activity != null) {
|
|
120
|
+
if (activity != null && !activity.getSupportFragmentManager().isStateSaved()) {
|
|
122
121
|
FLog.i(TAG, "Have active Activity and React module was registered, set root Fragment immediately.");
|
|
123
|
-
activity.setActivityRootFragment(
|
|
122
|
+
activity.setActivityRootFragment(layout);
|
|
124
123
|
}
|
|
125
124
|
});
|
|
126
125
|
}
|
|
@@ -7,8 +7,6 @@ import com.navigation.androidx.AwesomeFragment;
|
|
|
7
7
|
import com.navigation.androidx.DrawerFragment;
|
|
8
8
|
import com.navigation.androidx.StackFragment;
|
|
9
9
|
import com.navigation.androidx.TabBarFragment;
|
|
10
|
-
import com.reactnative.hybridnavigation.HybridFragment;
|
|
11
|
-
import com.reactnative.hybridnavigation.Navigator;
|
|
12
10
|
import com.reactnative.hybridnavigation.navigator.DrawerNavigator;
|
|
13
11
|
import com.reactnative.hybridnavigation.navigator.ScreenNavigator;
|
|
14
12
|
import com.reactnative.hybridnavigation.navigator.StackNavigator;
|
|
@@ -11,9 +11,9 @@ import com.facebook.common.logging.FLog;
|
|
|
11
11
|
import com.facebook.react.ReactInstanceManager;
|
|
12
12
|
import com.facebook.react.ReactNativeHost;
|
|
13
13
|
import com.facebook.react.bridge.Arguments;
|
|
14
|
+
import com.facebook.react.bridge.Callback;
|
|
14
15
|
import com.facebook.react.bridge.ReactContext;
|
|
15
16
|
import com.facebook.react.bridge.ReadableMap;
|
|
16
|
-
import com.facebook.react.bridge.WritableMap;
|
|
17
17
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
|
18
18
|
import com.facebook.react.modules.core.PermissionAwareActivity;
|
|
19
19
|
import com.facebook.react.modules.core.PermissionListener;
|
|
@@ -23,7 +23,7 @@ import com.navigation.androidx.Style;
|
|
|
23
23
|
|
|
24
24
|
public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity, ReactBridgeManager.ReactModuleRegisterListener {
|
|
25
25
|
|
|
26
|
-
protected static final String TAG = "
|
|
26
|
+
protected static final String TAG = "Navigation";
|
|
27
27
|
|
|
28
28
|
private final ReactAppCompatActivityDelegate activityDelegate;
|
|
29
29
|
|
|
@@ -85,7 +85,6 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
85
85
|
@Override
|
|
86
86
|
public void onReactModuleRegisterCompleted() {
|
|
87
87
|
FLog.i(TAG, "ReactAppCompatActivity#onReactModuleRegisterCompleted");
|
|
88
|
-
inflateStyle();
|
|
89
88
|
createMainComponent();
|
|
90
89
|
}
|
|
91
90
|
|
|
@@ -105,25 +104,19 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
105
104
|
|
|
106
105
|
if (bridgeManager.hasPendingLayout()) {
|
|
107
106
|
FLog.i(TAG, "Set root Fragment from pending layout when create main component");
|
|
108
|
-
setActivityRootFragment(bridgeManager);
|
|
107
|
+
setActivityRootFragment(bridgeManager.getPendingLayout());
|
|
109
108
|
return;
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
if (bridgeManager.hasStickyLayout()) {
|
|
113
112
|
FLog.i(TAG, "Set root Fragment from sticky layout when create main component");
|
|
114
|
-
|
|
115
|
-
if (fragment != null) {
|
|
116
|
-
setActivityRootFragment(fragment);
|
|
117
|
-
}
|
|
113
|
+
setActivityRootFragment(bridgeManager.getStickyLayout());
|
|
118
114
|
return;
|
|
119
115
|
}
|
|
120
116
|
|
|
121
117
|
if (bridgeManager.hasRootLayout()) {
|
|
122
118
|
FLog.i(TAG, "Set root Fragment from last root layout when create main component");
|
|
123
|
-
|
|
124
|
-
if (fragment != null) {
|
|
125
|
-
setActivityRootFragment(fragment);
|
|
126
|
-
}
|
|
119
|
+
setActivityRootFragment(bridgeManager.getRootLayout());
|
|
127
120
|
return;
|
|
128
121
|
}
|
|
129
122
|
|
|
@@ -134,69 +127,40 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
134
127
|
return null;
|
|
135
128
|
}
|
|
136
129
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private void setActivityRootFragment(ReactBridgeManager bridgeManager) {
|
|
143
|
-
int pendingTag = bridgeManager.getPendingTag();
|
|
144
|
-
ReadableMap pendingLayout = bridgeManager.getPendingLayout();
|
|
145
|
-
if (pendingTag == 0 || pendingLayout == null) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
AwesomeFragment fragment = bridgeManager.createFragment(pendingLayout);
|
|
130
|
+
protected void setActivityRootFragment(ReadableMap layout) {
|
|
131
|
+
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
132
|
+
AwesomeFragment fragment = bridgeManager.createFragment(layout);
|
|
150
133
|
if (fragment == null) {
|
|
151
|
-
|
|
152
|
-
return;
|
|
134
|
+
throw new IllegalArgumentException("无法创建 Fragment. " + layout);
|
|
153
135
|
}
|
|
154
|
-
setActivityRootFragment(fragment
|
|
136
|
+
setActivityRootFragment(fragment);
|
|
155
137
|
}
|
|
156
138
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (getSupportFragmentManager().isStateSaved()) {
|
|
163
|
-
FLog.i(TAG, "Schedule to set Activity root Fragment.");
|
|
164
|
-
scheduleTaskAtStarted(() -> setActivityRootFragmentSync(rootFragment, tag));
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
FLog.i(TAG, "Set Activity root Fragment immediately.");
|
|
169
|
-
setActivityRootFragmentSync(rootFragment, tag);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
protected void setActivityRootFragmentSync(AwesomeFragment fragment, int tag) {
|
|
139
|
+
@Override
|
|
140
|
+
public void setActivityRootFragment(@NonNull AwesomeFragment rootFragment) {
|
|
173
141
|
if (!styleInflated) {
|
|
174
142
|
inflateStyle();
|
|
175
143
|
if (!styleInflated) {
|
|
176
|
-
throw new IllegalStateException("Style hasn't inflated yet. Did you forgot to call `
|
|
144
|
+
throw new IllegalStateException("Style hasn't inflated yet. Did you forgot to call `Navigation.setDefaultOptions` before `Navigation.setRoot` ?");
|
|
177
145
|
}
|
|
178
146
|
}
|
|
147
|
+
super.setActivityRootFragment(rootFragment);
|
|
148
|
+
}
|
|
179
149
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// will
|
|
186
|
-
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_WILL_SET_ROOT, Arguments.createMap());
|
|
187
|
-
|
|
188
|
-
// do
|
|
150
|
+
@Override
|
|
151
|
+
protected void setActivityRootFragmentSync(AwesomeFragment fragment) {
|
|
189
152
|
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
190
|
-
|
|
191
|
-
setActivityRootFragmentSync(fragment);
|
|
153
|
+
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_WILL_SET_ROOT, Arguments.createMap());
|
|
154
|
+
super.setActivityRootFragmentSync(fragment);
|
|
192
155
|
bridgeManager.setViewHierarchyReady(true);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
156
|
+
Callback callback = bridgeManager.getPendingCallback();
|
|
157
|
+
if (callback != null) {
|
|
158
|
+
callback.invoke(null, true);
|
|
159
|
+
bridgeManager.setPendingLayout(null, null);
|
|
160
|
+
}
|
|
161
|
+
HBDEventEmitter.sendEvent(HBDEventEmitter.EVENT_DID_SET_ROOT, Arguments.createMap());
|
|
198
162
|
}
|
|
199
|
-
|
|
163
|
+
|
|
200
164
|
@Override
|
|
201
165
|
protected void onPause() {
|
|
202
166
|
activityDelegate.onPause();
|
|
@@ -206,10 +170,14 @@ public class ReactAppCompatActivity extends AwesomeActivity implements DefaultHa
|
|
|
206
170
|
@Override
|
|
207
171
|
protected void onResume() {
|
|
208
172
|
super.onResume();
|
|
209
|
-
|
|
173
|
+
ReactBridgeManager bridgeManager = getReactBridgeManager();
|
|
174
|
+
if (bridgeManager.hasPendingLayout()) {
|
|
175
|
+
FLog.i(TAG, "Set root Fragment from pending layout when resume.");
|
|
176
|
+
setActivityRootFragment(bridgeManager.getPendingLayout());
|
|
177
|
+
}
|
|
210
178
|
activityDelegate.onResume();
|
|
211
179
|
}
|
|
212
|
-
|
|
180
|
+
|
|
213
181
|
@Override
|
|
214
182
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
215
183
|
activityDelegate.onActivityResult(requestCode, resultCode, data);
|
package/android/src/main/java/com/reactnative/hybridnavigation/ReactAppCompatActivityDelegate.java
CHANGED
|
@@ -27,7 +27,7 @@ import com.facebook.react.modules.core.PermissionListener;
|
|
|
27
27
|
|
|
28
28
|
public class ReactAppCompatActivityDelegate {
|
|
29
29
|
|
|
30
|
-
private static final String TAG = "
|
|
30
|
+
private static final String TAG = "Navigation";
|
|
31
31
|
|
|
32
32
|
private final int REQUEST_OVERLAY_PERMISSION_CODE = 1111;
|
|
33
33
|
private static final String REDBOX_PERMISSION_GRANTED_MESSAGE =
|
|
@@ -35,7 +35,7 @@ public class ReactBridgeManager {
|
|
|
35
35
|
void onReload();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
private static final String TAG = "
|
|
38
|
+
private static final String TAG = "Navigation";
|
|
39
39
|
|
|
40
40
|
private final static ReactBridgeManager instance = new ReactBridgeManager();
|
|
41
41
|
|
|
@@ -52,7 +52,7 @@ public class ReactBridgeManager {
|
|
|
52
52
|
private final CopyOnWriteArrayList<ReactBridgeReloadListener> reactBridgeReloadListeners = new CopyOnWriteArrayList<>();
|
|
53
53
|
|
|
54
54
|
private ReadableMap rootLayout;
|
|
55
|
-
private
|
|
55
|
+
private Callback pendingCallback;
|
|
56
56
|
private ReadableMap stickyLayout;
|
|
57
57
|
private ReadableMap pendingLayout;
|
|
58
58
|
private boolean viewHierarchyReady;
|
|
@@ -69,7 +69,7 @@ public class ReactBridgeManager {
|
|
|
69
69
|
reactInstanceManager.addReactInstanceEventListener(context -> {
|
|
70
70
|
FLog.i(TAG, "React instance context initialized.");
|
|
71
71
|
rootLayout = null;
|
|
72
|
-
|
|
72
|
+
pendingCallback = null;
|
|
73
73
|
stickyLayout = null;
|
|
74
74
|
pendingLayout = null;
|
|
75
75
|
reactBridgeReloadListeners.clear();
|
|
@@ -178,7 +178,7 @@ public class ReactBridgeManager {
|
|
|
178
178
|
|
|
179
179
|
public void invalidate() {
|
|
180
180
|
invokeReloadListeners();
|
|
181
|
-
setPendingLayout(null,
|
|
181
|
+
setPendingLayout(null, null);
|
|
182
182
|
setReactModuleRegisterCompleted(false);
|
|
183
183
|
setViewHierarchyReady(false);
|
|
184
184
|
}
|
|
@@ -214,9 +214,9 @@ public class ReactBridgeManager {
|
|
|
214
214
|
return stickyLayout != null;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
public void setPendingLayout(@Nullable ReadableMap pendingLayout,
|
|
217
|
+
public void setPendingLayout(@Nullable ReadableMap pendingLayout, Callback callback) {
|
|
218
218
|
this.pendingLayout = pendingLayout;
|
|
219
|
-
this.
|
|
219
|
+
this.pendingCallback = callback;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
@Nullable
|
|
@@ -224,8 +224,8 @@ public class ReactBridgeManager {
|
|
|
224
224
|
return pendingLayout;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
public
|
|
228
|
-
return
|
|
227
|
+
public Callback getPendingCallback() {
|
|
228
|
+
return pendingCallback;
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
public boolean hasPendingLayout() {
|
|
@@ -31,7 +31,7 @@ import com.navigation.androidx.Style;
|
|
|
31
31
|
|
|
32
32
|
public class ReactFragment extends HybridFragment implements ReactRootViewHolder.VisibilityObserver, ReactBridgeManager.ReactBridgeReloadListener {
|
|
33
33
|
|
|
34
|
-
protected static final String TAG = "
|
|
34
|
+
protected static final String TAG = "Navigation";
|
|
35
35
|
|
|
36
36
|
private ViewGroup containerLayout;
|
|
37
37
|
private ReactRootViewHolder reactRootViewHolder;
|
|
@@ -6,7 +6,7 @@ import android.view.View;
|
|
|
6
6
|
import android.widget.FrameLayout;
|
|
7
7
|
|
|
8
8
|
public class ReactFrameLayout extends FrameLayout implements ReactRootViewHolder {
|
|
9
|
-
protected static final String TAG = "
|
|
9
|
+
protected static final String TAG = "Navigation";
|
|
10
10
|
|
|
11
11
|
private HBDReactRootView mReactRootView;
|
|
12
12
|
private VisibilityObserver mVisibilityObserver;
|
|
@@ -33,7 +33,7 @@ import java.util.List;
|
|
|
33
33
|
|
|
34
34
|
public class ReactTabBarProvider implements TabBarProvider, ReactBridgeManager.ReactBridgeReloadListener {
|
|
35
35
|
|
|
36
|
-
private static final String TAG = "
|
|
36
|
+
private static final String TAG = "Navigation";
|
|
37
37
|
|
|
38
38
|
private HBDReactRootView reactRootView;
|
|
39
39
|
private ReactTabBarFragment tabBarFragment;
|
|
@@ -19,7 +19,7 @@ import java.util.List;
|
|
|
19
19
|
|
|
20
20
|
public class Utils {
|
|
21
21
|
|
|
22
|
-
private static final String TAG = "
|
|
22
|
+
private static final String TAG = "Navigation";
|
|
23
23
|
|
|
24
24
|
public static Drawable createTabBarShadow(Context context, Bundle shadowImage) {
|
|
25
25
|
Bundle image = shadowImage.getBundle("image");
|
package/android/src/main/java/com/reactnative/hybridnavigation/navigator/ScreenNavigator.java
CHANGED
|
@@ -7,7 +7,6 @@ import androidx.annotation.Nullable;
|
|
|
7
7
|
|
|
8
8
|
import com.facebook.react.bridge.Arguments;
|
|
9
9
|
import com.facebook.react.bridge.Callback;
|
|
10
|
-
import com.facebook.react.bridge.Promise;
|
|
11
10
|
import com.facebook.react.bridge.ReadableMap;
|
|
12
11
|
import com.navigation.androidx.AwesomeFragment;
|
|
13
12
|
import com.navigation.androidx.FragmentHelper;
|
|
@@ -23,7 +22,7 @@ import java.util.List;
|
|
|
23
22
|
|
|
24
23
|
public class ScreenNavigator implements Navigator {
|
|
25
24
|
|
|
26
|
-
final static String TAG = "
|
|
25
|
+
final static String TAG = "Navigation";
|
|
27
26
|
|
|
28
27
|
private final List<String> supportActions = Arrays.asList("present", "presentLayout", "dismiss", "showModal", "showModalLayout", "hideModal");
|
|
29
28
|
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
NSString *uri = json[@"uri"];
|
|
86
86
|
if (uri && [uri hasPrefix:@"font:"]) {
|
|
87
87
|
NSString *path = [self imagePathFromFontUri:uri];
|
|
88
|
-
// RCTLogInfo(@"[
|
|
88
|
+
// RCTLogInfo(@"[Navigation] font path:%@", path);
|
|
89
89
|
UIImage *image = [UIImage imageWithContentsOfFile:path];
|
|
90
90
|
return image;
|
|
91
91
|
} else {
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
|
|
106
106
|
+ (NSString *)imagePathFromFontUri:(NSString *)uri {
|
|
107
107
|
uri = [uri substringFromIndex:7];
|
|
108
|
-
// RCTLogInfo(@"[
|
|
108
|
+
// RCTLogInfo(@"[Navigation] font uri:%@", uri);
|
|
109
109
|
NSArray *components = [uri componentsSeparatedByString:@"/"];
|
|
110
110
|
if (components.count < 3) {
|
|
111
111
|
return nil;
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
NSData *imageData = UIImagePNGRepresentation(iconImage);
|
|
146
146
|
BOOL success = [imageData writeToFile:filePath atomically:YES];
|
|
147
147
|
if (!success) {
|
|
148
|
-
RCTLogInfo(@"[
|
|
148
|
+
RCTLogInfo(@"[Navigation] can't save %@", fileName);
|
|
149
149
|
return nil;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
for (NSString *action in [navigator supportActions]) {
|
|
42
42
|
id <HBDNavigator> duplicated = self.actionNavigatorPairs[action];
|
|
43
43
|
if (duplicated) {
|
|
44
|
-
RCTLogError(@"[
|
|
44
|
+
RCTLogError(@"[Navigation] The action %@ that %@ wants to register has been registered by %@", action, [navigator class], [duplicated class]);
|
|
45
45
|
}
|
|
46
46
|
self.actionNavigatorPairs[action] = navigator;
|
|
47
47
|
}
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
id <HBDNavigator> duplicatedLayout = self.layoutNavigatorPairs[layout];
|
|
53
53
|
if (duplicatedLayout) {
|
|
54
|
-
RCTLogError(@"[
|
|
54
|
+
RCTLogError(@"[Navigation] The layout %@ that %@ wants to register has been registered by %@", layout, [navigator class], [duplicatedLayout class]);
|
|
55
55
|
}
|
|
56
56
|
self.layoutNavigatorPairs[layout] = navigator;
|
|
57
57
|
|
|
@@ -60,7 +60,7 @@ RCT_EXPORT_MODULE(GardenModule)
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
- (void)handleStatusBarFrameChange {
|
|
63
|
-
RCTLogInfo(@"[
|
|
63
|
+
RCTLogInfo(@"[Navigation] handleStatusBarFrameChange: %f", [self currentStatusBarHeight]);
|
|
64
64
|
if ([self.bridge isValid]) {
|
|
65
65
|
[self sendEventWithName:EVENT_STATUSBAR_FRAME_CHANGE body:@{
|
|
66
66
|
@"statusBarHeight": @([self currentStatusBarHeight])
|
|
@@ -108,7 +108,7 @@ RCT_EXPORT_METHOD(setRightBarButtonItems:(NSString *)sceneId item:(NSArray *__nu
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
RCT_EXPORT_METHOD(updateOptions:(NSString *)sceneId item:(NSDictionary *)options) {
|
|
111
|
-
RCTLogInfo(@"[
|
|
111
|
+
RCTLogInfo(@"[Navigation] updateNavigationBarOptions: %@", options);
|
|
112
112
|
HBDViewController *vc = [self viewControllerWithSceneId:sceneId];
|
|
113
113
|
if (vc) {
|
|
114
114
|
[vc updateNavigationBarOptions:options];
|
|
@@ -116,8 +116,8 @@ RCT_EXPORT_METHOD(updateOptions:(NSString *)sceneId item:(NSDictionary *)options
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
RCT_EXPORT_METHOD(updateTabBar:(NSString *)sceneId item:(NSDictionary *)item) {
|
|
119
|
-
RCTLogInfo(@"[
|
|
120
|
-
UIViewController *vc = [self.bridgeManager
|
|
119
|
+
RCTLogInfo(@"[Navigation] updateTabBar: %@", item);
|
|
120
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
121
121
|
UITabBarController *tabBarVC = [self tabBarControllerWithViewController:vc];
|
|
122
122
|
if (tabBarVC && [tabBarVC isKindOfClass:[HBDTabBarController class]]) {
|
|
123
123
|
[((HBDTabBarController *)tabBarVC) updateTabBar:item];
|
|
@@ -125,8 +125,8 @@ RCT_EXPORT_METHOD(updateTabBar:(NSString *)sceneId item:(NSDictionary *)item) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
RCT_EXPORT_METHOD(setTabItem:(NSString *)sceneId options:(NSArray<NSDictionary *> *)options) {
|
|
128
|
-
RCTLogInfo(@"[
|
|
129
|
-
UIViewController *vc = [self.bridgeManager
|
|
128
|
+
RCTLogInfo(@"[Navigation] setTabItem: %@", options);
|
|
129
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
130
130
|
UITabBarController *tabBarController = [self tabBarControllerWithViewController:vc];
|
|
131
131
|
if ([tabBarController isKindOfClass:[HBDTabBarController class]]) {
|
|
132
132
|
HBDTabBarController *tabBarVC = (HBDTabBarController *)tabBarController;
|
|
@@ -135,7 +135,7 @@ RCT_EXPORT_METHOD(setTabItem:(NSString *)sceneId options:(NSArray<NSDictionary *
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
RCT_EXPORT_METHOD(setMenuInteractive:(NSString *)sceneId enabled:(BOOL)enabled) {
|
|
138
|
-
UIViewController *vc = [self.bridgeManager
|
|
138
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
139
139
|
HBDDrawerController *drawer = [vc drawerController];
|
|
140
140
|
if (drawer) {
|
|
141
141
|
drawer.menuInteractive = enabled;
|
|
@@ -143,7 +143,7 @@ RCT_EXPORT_METHOD(setMenuInteractive:(NSString *)sceneId enabled:(BOOL)enabled)
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
- (HBDViewController *)viewControllerWithSceneId:(NSString *)sceneId {
|
|
146
|
-
UIViewController *vc = [self.bridgeManager
|
|
146
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
147
147
|
if ([vc isKindOfClass:[HBDViewController class]]) {
|
|
148
148
|
return (HBDViewController *)vc;
|
|
149
149
|
}
|
|
@@ -28,7 +28,7 @@ RCT_EXPORT_MODULE(NavigationModule)
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
- (void)invalidate {
|
|
31
|
-
RCTLogInfo(@"[
|
|
31
|
+
RCTLogInfo(@"[Navigation] NavigationModule#invalidate");
|
|
32
32
|
[NSObject cancelPreviousPerformRequestsWithTarget:self];
|
|
33
33
|
[[HBDAnimationObserver sharedObserver] invalidate];
|
|
34
34
|
[self.bridgeManager invalidate];
|
|
@@ -58,27 +58,34 @@ RCT_EXPORT_METHOD(registerReactComponent:(NSString *)appKey options:(NSDictionar
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
RCT_EXPORT_METHOD(signalFirstRenderComplete:(NSString *) sceneId) {
|
|
61
|
-
// RCTLogInfo(@"[
|
|
62
|
-
UIViewController *vc = [self.bridgeManager
|
|
61
|
+
// RCTLogInfo(@"[Navigation] signalFirstRenderComplete sceneId:%@", sceneId);
|
|
62
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
63
63
|
if ([vc isKindOfClass:[HBDReactViewController class]]) {
|
|
64
64
|
[(HBDReactViewController *)vc signalFirstRenderComplete];
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
RCT_EXPORT_METHOD(setRoot:(NSDictionary *)layout sticky:(BOOL)sticky
|
|
68
|
+
RCT_EXPORT_METHOD(setRoot:(NSDictionary *)layout sticky:(BOOL)sticky callback:(RCTResponseSenderBlock)callback) {
|
|
69
69
|
self.bridgeManager.viewHierarchyReady = NO;
|
|
70
70
|
UIViewController *vc = [self.bridgeManager viewControllerWithLayout:layout];
|
|
71
|
-
if (vc) {
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (!vc) {
|
|
72
|
+
@throw [[NSException alloc] initWithName:@"IllegalArgumentsException" reason:@"无法创建 ViewController" userInfo:@{ @"layout": layout }];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (self.bridgeManager.didSetRoot) {
|
|
76
|
+
self.bridgeManager.didSetRoot(@[NSNull.null, @NO]);
|
|
74
77
|
}
|
|
78
|
+
self.bridgeManager.didSetRoot = callback;
|
|
79
|
+
self.bridgeManager.hasRootLayout = YES;
|
|
80
|
+
|
|
81
|
+
[self.bridgeManager setRootViewController:vc];
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
RCT_EXPORT_METHOD(dispatch:(NSString *)sceneId action:(NSString *)action extras:(NSDictionary *)extras callback:(RCTResponseSenderBlock)callback) {
|
|
78
|
-
UIViewController *vc = [self.bridgeManager
|
|
85
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
79
86
|
if (!vc) {
|
|
80
87
|
callback(@[NSNull.null, @NO]);
|
|
81
|
-
RCTLogWarn(@"[
|
|
88
|
+
RCTLogWarn(@"[Navigation] Can't find target scene for action: %@, maybe the scene is gone. \nextras: %@", action, extras);
|
|
82
89
|
return;
|
|
83
90
|
}
|
|
84
91
|
|
|
@@ -86,7 +93,7 @@ RCT_EXPORT_METHOD(dispatch:(NSString *)sceneId action:(NSString *)action extras:
|
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
RCT_EXPORT_METHOD(currentTab:(NSString *)sceneId callback:(RCTResponseSenderBlock)callback) {
|
|
89
|
-
UIViewController *vc = [self.bridgeManager
|
|
96
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
90
97
|
UITabBarController *tabs = vc.tabBarController;
|
|
91
98
|
if (tabs) {
|
|
92
99
|
callback(@[NSNull.null, @(tabs.selectedIndex)]);
|
|
@@ -96,7 +103,7 @@ RCT_EXPORT_METHOD(currentTab:(NSString *)sceneId callback:(RCTResponseSenderBloc
|
|
|
96
103
|
}
|
|
97
104
|
|
|
98
105
|
RCT_EXPORT_METHOD(isStackRoot:(NSString *)sceneId callback:(RCTResponseSenderBlock)callback) {
|
|
99
|
-
UIViewController *vc = [self.bridgeManager
|
|
106
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
100
107
|
UINavigationController *nav = vc.navigationController;
|
|
101
108
|
if (!nav) {
|
|
102
109
|
callback(@[NSNull.null, @NO]);
|
|
@@ -119,7 +126,7 @@ RCT_EXPORT_METHOD(isStackRoot:(NSString *)sceneId callback:(RCTResponseSenderBlo
|
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
RCT_EXPORT_METHOD(setResult:(NSString *)sceneId resultCode:(NSInteger)resultCode data:(NSDictionary *)data) {
|
|
122
|
-
UIViewController *vc = [self.bridgeManager
|
|
129
|
+
UIViewController *vc = [self.bridgeManager viewControllerBySceneId:sceneId];
|
|
123
130
|
[vc setResultCode:resultCode resultData:data];
|
|
124
131
|
}
|
|
125
132
|
|
|
@@ -141,12 +148,12 @@ RCT_EXPORT_METHOD(findSceneIdByModuleName:(NSString *)moduleName callback:(RCTRe
|
|
|
141
148
|
|
|
142
149
|
NSString *sceneId = [self findSceneIdByModuleName:moduleName];
|
|
143
150
|
if (sceneId == nil) {
|
|
144
|
-
RCTLogInfo(@"[
|
|
151
|
+
RCTLogInfo(@"[Navigation] Can't find sceneId by : %@", moduleName);
|
|
145
152
|
callback(@[NSNull.null, NSNull.null]);
|
|
146
153
|
return;
|
|
147
154
|
}
|
|
148
155
|
|
|
149
|
-
RCTLogInfo(@"[
|
|
156
|
+
RCTLogInfo(@"[Navigation] The sceneId found by %@ : %@", moduleName, sceneId);
|
|
150
157
|
callback(@[[NSNull null], sceneId]);
|
|
151
158
|
}
|
|
152
159
|
|
|
@@ -158,7 +165,7 @@ RCT_EXPORT_METHOD(findSceneIdByModuleName:(NSString *)moduleName callback:(RCTRe
|
|
|
158
165
|
UIWindow *window = application.windows[i];
|
|
159
166
|
NSString *sceneId = [self findSceneIdByModuleName:moduleName withViewController:window.rootViewController];
|
|
160
167
|
if (sceneId != nil) {
|
|
161
|
-
RCTLogInfo(@"[
|
|
168
|
+
RCTLogInfo(@"[Navigation] The sceneId found by %@ : %@", moduleName, sceneId);
|
|
162
169
|
return sceneId;
|
|
163
170
|
}
|
|
164
171
|
}
|
|
@@ -23,6 +23,7 @@ extern const NSInteger ResultCancel;
|
|
|
23
23
|
@property(nonatomic, assign, readonly, getter=isReactModuleRegisterCompleted) BOOL reactModuleRegisterCompleted;
|
|
24
24
|
@property(nonatomic, assign, getter=isViewHierarchyReady) BOOL viewHierarchyReady;
|
|
25
25
|
@property(nonatomic, assign) BOOL hasRootLayout;
|
|
26
|
+
@property(nonatomic, copy) RCTResponseSenderBlock didSetRoot;
|
|
26
27
|
|
|
27
28
|
- (void)installWithBridge:(RCTBridge *)bridge;
|
|
28
29
|
|
|
@@ -46,12 +47,10 @@ extern const NSInteger ResultCancel;
|
|
|
46
47
|
|
|
47
48
|
- (UIViewController *)viewControllerWithLayout:(NSDictionary *)layout;
|
|
48
49
|
|
|
49
|
-
- (UIViewController *)
|
|
50
|
+
- (UIViewController *)viewControllerBySceneId:(NSString *)sceneId;
|
|
50
51
|
|
|
51
52
|
- (void)setRootViewController:(UIViewController *)rootViewController;
|
|
52
53
|
|
|
53
|
-
- (void)setRootViewController:(UIViewController *)rootViewController withTag:(NSNumber *)tag;
|
|
54
|
-
|
|
55
54
|
- (NSArray *)routeGraph;
|
|
56
55
|
|
|
57
56
|
- (NSDictionary *)routeGraphWithViewController:(UIViewController *)vc;
|