hybrid-navigation 2.13.2 → 2.13.5
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/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 +31 -36
- 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/Navigator/HBDStackNavigator.m +5 -5
- 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/GardenModule.d.ts +4 -0
- package/lib/GardenModule.js +19 -1
- package/lib/Navigation.d.ts +1 -1
- package/lib/NavigationModule.d.ts +1 -1
- package/lib/NavigationModule.js +6 -2
- package/lib/Navigator.js +10 -8
- package/lib/handler/DispatchCommandHandler.d.ts +1 -0
- package/lib/handler/DispatchCommandHandler.js +17 -16
- package/lib/handler/LayoutCommandHandler.d.ts +1 -3
- package/lib/handler/LayoutCommandHandler.js +2 -19
- package/lib/index.d.ts +1 -4
- package/lib/index.js +1 -20
- package/lib/router/index.d.ts +2 -1
- package/lib/router/index.js +13 -6
- package/package.json +1 -1
- package/src/Event.ts +0 -11
- package/src/GardenModule.ts +27 -1
- package/src/NavigationModule.ts +7 -3
- package/src/Navigator.ts +10 -8
- package/src/handler/DispatchCommandHandler.ts +18 -15
- package/src/handler/LayoutCommandHandler.ts +2 -22
- package/src/index.ts +1 -24
- package/src/router/index.ts +14 -6
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
|
## 文档
|
|
@@ -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) {
|
|
@@ -46,7 +46,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
46
46
|
clearFragments();
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
private void clearFragments() {
|
|
51
51
|
AwesomeActivity activity = getActiveActivity();
|
|
52
52
|
if (activity != null) {
|
|
@@ -96,7 +96,7 @@ 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()) {
|
|
@@ -104,23 +104,22 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
if (bridgeManager.getPendingCallback() != null) {
|
|
108
|
+
bridgeManager.getPendingCallback().invoke(null, false);
|
|
109
|
+
}
|
|
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
118
|
|
|
115
|
-
AwesomeFragment fragment = bridgeManager.createFragment(layout);
|
|
116
|
-
if (fragment == null) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
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
|
}
|
|
@@ -158,7 +157,7 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
158
157
|
callback.invoke(null, -1);
|
|
159
158
|
return;
|
|
160
159
|
}
|
|
161
|
-
|
|
160
|
+
|
|
162
161
|
callback.invoke(null, tabs.getSelectedIndex());
|
|
163
162
|
});
|
|
164
163
|
}
|
|
@@ -257,21 +256,19 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
257
256
|
UiThreadUtil.runOnUiThread(this, 16);
|
|
258
257
|
return;
|
|
259
258
|
}
|
|
259
|
+
|
|
260
|
+
FragmentManager fragmentManager = activity.getSupportFragmentManager();
|
|
261
|
+
HybridFragment current = bridgeManager.primaryFragment(fragmentManager);
|
|
262
|
+
if (current == null) {
|
|
263
|
+
UiThreadUtil.runOnUiThread(this, 16);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
260
266
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
Bundle bundle = new Bundle();
|
|
270
|
-
bundle.putString("moduleName", current.getModuleName());
|
|
271
|
-
bundle.putString("sceneId", current.getSceneId());
|
|
272
|
-
bundle.putString("mode", Navigator.Util.getMode(current));
|
|
273
|
-
callback.invoke(null, Arguments.fromBundle(bundle));
|
|
274
|
-
});
|
|
267
|
+
Bundle bundle = new Bundle();
|
|
268
|
+
bundle.putString("moduleName", current.getModuleName());
|
|
269
|
+
bundle.putString("sceneId", current.getSceneId());
|
|
270
|
+
bundle.putString("mode", Navigator.Util.getMode(current));
|
|
271
|
+
callback.invoke(null, Arguments.fromBundle(bundle));
|
|
275
272
|
}
|
|
276
273
|
};
|
|
277
274
|
|
|
@@ -288,17 +285,15 @@ public class NavigationModule extends ReactContextBaseJavaModule {
|
|
|
288
285
|
UiThreadUtil.runOnUiThread(this, 16);
|
|
289
286
|
return;
|
|
290
287
|
}
|
|
288
|
+
|
|
289
|
+
FragmentManager fragmentManager = activity.getSupportFragmentManager();
|
|
290
|
+
ArrayList<Bundle> graph = bridgeManager.buildRouteGraph(fragmentManager);
|
|
291
|
+
if (graph.size() == 0) {
|
|
292
|
+
UiThreadUtil.runOnUiThread(this, 16);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
291
295
|
|
|
292
|
-
|
|
293
|
-
FragmentManager fragmentManager = activity.getSupportFragmentManager();
|
|
294
|
-
ArrayList<Bundle> graph = bridgeManager.buildRouteGraph(fragmentManager);
|
|
295
|
-
if (graph.size() == 0) {
|
|
296
|
-
UiThreadUtil.runOnUiThread(this, 16);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
callback.invoke(null, Arguments.fromList(graph));
|
|
301
|
-
});
|
|
296
|
+
callback.invoke(null, Arguments.fromList(graph));
|
|
302
297
|
}
|
|
303
298
|
};
|
|
304
299
|
|
|
@@ -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
|
|
|
@@ -238,18 +238,18 @@
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
if ([drawer.contentController isKindOfClass:[UITabBarController class]]) {
|
|
241
|
-
UITabBarController *
|
|
242
|
-
if ([
|
|
243
|
-
return (UINavigationController *)
|
|
241
|
+
UITabBarController *tabs = (UITabBarController *)drawer.contentController;
|
|
242
|
+
if ([tabs.selectedViewController isKindOfClass:[UINavigationController class]]) {
|
|
243
|
+
return (UINavigationController *)tabs.selectedViewController;
|
|
244
244
|
}
|
|
245
245
|
return nil;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
if ([drawer.contentController isKindOfClass:[UINavigationController class]]) {
|
|
249
|
-
return (UINavigationController *)
|
|
249
|
+
return (UINavigationController *)drawer.contentController;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
return
|
|
252
|
+
return drawer.contentController.navigationController;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
-(void)handleNavigation:(NSDictionary *)params {
|
|
@@ -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
|
}
|