hybrid-navigation 2.7.8 → 2.7.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 2.7.11 (2022-04-13)
2
+
3
+ ### Android specific
4
+
5
+ - 确保在 Activity 处于 start 状态时,才获取 `currentRoute` 和 `routeGraph`
6
+
7
+ ## 2.7.10 (2022-04-12)
8
+
9
+ - 使用 `CompanentType<any>` 代替 `React.ComponentType<any>`
10
+
11
+ ## 2.7.9 (2022-03-23)
12
+
13
+ ### Android specific
14
+
15
+ - 修复 `Fragment is not an active fragment of FragmentManager`
16
+
1
17
  ## 2.7.8 (2022-03-03)
2
18
 
3
19
  ### ios specific
@@ -5,7 +21,7 @@
5
21
  - 修复因 NSUInteger 导致的问题
6
22
 
7
23
  ```objc
8
- for (NSUInteger i = count - 1; i > -1; i--) {
24
+ for (NSUInteger i = count - 1; i > -1; i--) {
9
25
  // 无法进入此区间
10
26
  }
11
27
  ```
@@ -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.0.7'
36
+ api 'io.github.listenzz:AndroidNavigation:12.0.8'
37
37
  }
@@ -198,17 +198,20 @@ public class NavigationModule extends ReactContextBaseJavaModule {
198
198
  }
199
199
 
200
200
  ReactAppCompatActivity reactAppCompatActivity = (ReactAppCompatActivity) activity;
201
- FragmentManager fragmentManager = reactAppCompatActivity.getSupportFragmentManager();
202
- Fragment fragment = fragmentManager.findFragmentById(android.R.id.content);
203
- if (fragment instanceof AwesomeFragment) {
204
- String sceneId = findSceneIdByModuleName(moduleName, (AwesomeFragment) fragment);
205
- FLog.i(TAG, "The sceneId found by " + moduleName + " : " + sceneId);
206
- promise.resolve(sceneId);
207
- } else {
208
- promise.resolve(null);
209
- }
201
+ reactAppCompatActivity.scheduleTaskAtStarted(() -> {
202
+ FragmentManager fragmentManager = reactAppCompatActivity.getSupportFragmentManager();
203
+ Fragment fragment = fragmentManager.findFragmentById(android.R.id.content);
204
+ if (fragment instanceof AwesomeFragment) {
205
+ String sceneId = findSceneIdByModuleName(moduleName, (AwesomeFragment) fragment);
206
+ FLog.i(TAG, "The sceneId found by " + moduleName + " : " + sceneId);
207
+ promise.resolve(sceneId);
208
+ } else {
209
+ promise.resolve(null);
210
+ }
211
+ }, true);
210
212
  }
211
213
  };
214
+
212
215
  UiThreadUtil.runOnUiThread(task);
213
216
  }
214
217
 
@@ -252,18 +255,20 @@ public class NavigationModule extends ReactContextBaseJavaModule {
252
255
  }
253
256
 
254
257
  ReactAppCompatActivity reactAppCompatActivity = (ReactAppCompatActivity) activity;
255
- FragmentManager fragmentManager = reactAppCompatActivity.getSupportFragmentManager();
256
- HybridFragment current = bridgeManager.primaryFragment(fragmentManager);
257
-
258
- if (current != null) {
259
- Bundle bundle = new Bundle();
260
- bundle.putString("moduleName", current.getModuleName());
261
- bundle.putString("sceneId", current.getSceneId());
262
- bundle.putString("mode", Navigator.Util.getMode(current));
263
- promise.resolve(Arguments.fromBundle(bundle));
264
- } else {
265
- UiThreadUtil.runOnUiThread(this, 16);
266
- }
258
+ reactAppCompatActivity.scheduleTaskAtStarted(() -> {
259
+ FragmentManager fragmentManager = reactAppCompatActivity.getSupportFragmentManager();
260
+ HybridFragment current = bridgeManager.primaryFragment(fragmentManager);
261
+
262
+ if (current != null) {
263
+ Bundle bundle = new Bundle();
264
+ bundle.putString("moduleName", current.getModuleName());
265
+ bundle.putString("sceneId", current.getSceneId());
266
+ bundle.putString("mode", Navigator.Util.getMode(current));
267
+ promise.resolve(Arguments.fromBundle(bundle));
268
+ } else {
269
+ UiThreadUtil.runOnUiThread(this, 16);
270
+ }
271
+ }, true);
267
272
  }
268
273
  };
269
274
 
@@ -287,13 +292,15 @@ public class NavigationModule extends ReactContextBaseJavaModule {
287
292
  }
288
293
 
289
294
  ReactAppCompatActivity reactAppCompatActivity = (ReactAppCompatActivity) activity;
290
- FragmentManager fragmentManager = reactAppCompatActivity.getSupportFragmentManager();
291
- ArrayList<Bundle> graph = bridgeManager.buildRouteGraph(fragmentManager);
292
- if (graph.size() > 0) {
293
- promise.resolve(Arguments.fromList(graph));
294
- } else {
295
- UiThreadUtil.runOnUiThread(this, 16);
296
- }
295
+ reactAppCompatActivity.scheduleTaskAtStarted(() -> {
296
+ FragmentManager fragmentManager = reactAppCompatActivity.getSupportFragmentManager();
297
+ ArrayList<Bundle> graph = bridgeManager.buildRouteGraph(fragmentManager);
298
+ if (graph.size() > 0) {
299
+ promise.resolve(Arguments.fromList(graph));
300
+ } else {
301
+ UiThreadUtil.runOnUiThread(this, 16);
302
+ }
303
+ }, true);
297
304
  }
298
305
  };
299
306
 
package/docs/qa.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  请参考 [ContextDemo](https://github.com/listenzz/MultiContextDemo)。
8
8
 
9
+ ⚠️ 推荐使用 [zustand](https://github.com/pmndrs/zustand)
10
+
9
11
  ## 为什么在 Android 平台,push 到下一个页面时,当前页面的图片会消失?
10
12
 
11
13
  细心的同学,可能会注意到,在 Android 平台,push 到下一个页面时,当前页面的图片会消失。这是怎么回事呢?
@@ -10,7 +10,7 @@ export interface InjectedProps {
10
10
  sceneId: string;
11
11
  }
12
12
  export declare const NavigationContext: React.Context<any>;
13
- export declare type HOC = (WrappedComponent: React.ComponentType<any>) => React.ComponentType<any>;
13
+ export declare type HOC = (WrappedComponent: ComponentType<any>) => ComponentType<any>;
14
14
  export declare class ReactRegistry {
15
15
  static registerEnded: boolean;
16
16
  static startRegisterComponent(hoc?: HOC): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hybrid-navigation",
3
3
  "description": "React Native Navigation that supports seamless navigation between Native and React.",
4
- "version": "2.7.8",
4
+ "version": "2.7.11",
5
5
  "keywords": [
6
6
  "react-native",
7
7
  "navigation",
@@ -54,7 +54,7 @@
54
54
  "jest": "^27.2.0",
55
55
  "metro-react-native-babel-preset": "^0.68.0",
56
56
  "react": "17.0.2",
57
- "react-native": "^0.67.2",
57
+ "react-native": "^0.67.4",
58
58
  "react-native-fast-image": "^8.5.11",
59
59
  "react-native-iphone-x-helper": "^1.2.0",
60
60
  "react-native-keyboard-aware-scroll-view": "^0.9.5",
@@ -63,7 +63,8 @@
63
63
  "react-test-renderer": "17.0.2",
64
64
  "redux": "^4.1.1",
65
65
  "typescript": "^4.4.3",
66
- "vuepress": "^2.0.0-beta.26"
66
+ "vuepress": "^2.0.0-beta.26",
67
+ "zustand": "^3.7.1"
67
68
  },
68
69
  "jest": {
69
70
  "preset": "react-native",