hybrid-navigation 5.3.0 → 5.4.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.
@@ -59,13 +59,22 @@ public class ReactFragment extends HybridFragment implements ReactManager.ReactB
59
59
  return false;
60
60
  }
61
61
 
62
+ @SuppressWarnings("deprecation")
63
+ private boolean shouldPrewarmPush() {
64
+ Object value = getOptions().get("prewarmPush");
65
+ if (value instanceof Boolean) {
66
+ return (Boolean) value;
67
+ }
68
+ return getReactManager().getGlobalStyle().isPrewarmPush();
69
+ }
70
+
62
71
  public boolean prepareForAnimatedPush(
63
72
  @NonNull StackFragment stackFragment,
64
73
  @NonNull View container,
65
74
  long timeoutMs,
66
75
  @NonNull Runnable onReady
67
76
  ) {
68
- if (!getReactManager().getGlobalStyle().isPrewarmPush()
77
+ if (!shouldPrewarmPush()
69
78
  || !isReactModuleRegisterCompleted()
70
79
  || !shouldAnimatedTransition()
71
80
  || reactSurface != null) {
package/dist/Options.d.ts CHANGED
@@ -24,6 +24,7 @@ export interface NavigationOption {
24
24
  }
25
25
  export interface NavigationItem extends NavigationOption {
26
26
  animatedTransition?: boolean;
27
+ prewarmPush?: boolean;
27
28
  tabItem?: TabItem;
28
29
  }
29
30
  export interface TabItem {
@@ -147,8 +147,8 @@ static const NSTimeInterval HBDPushPrewarmTimeoutSeconds = 0.18;
147
147
 
148
148
  NSString *sceneId = vc.hbd_sceneId;
149
149
  if (animated) {
150
- BOOL canPrewarm = [HBDReactBridgeManager get].globalStyle.prewarmPush &&
151
- [vc isKindOfClass:[HBDReactViewController class]] &&
150
+ BOOL canPrewarm = [vc isKindOfClass:[HBDReactViewController class]] &&
151
+ [(HBDReactViewController *)vc shouldPrewarmPush] &&
152
152
  nav.tabBarController == nil &&
153
153
  nav.presentingViewController == nil &&
154
154
  nav.view.window != nil &&
@@ -6,6 +6,8 @@ NS_ASSUME_NONNULL_BEGIN
6
6
 
7
7
  - (void)signalFirstRenderComplete;
8
8
 
9
+ - (BOOL)shouldPrewarmPush;
10
+
9
11
  - (BOOL)prepareForAnimatedPushInView:(UIView *)hostView timeout:(NSTimeInterval)timeout completion:(dispatch_block_t)completion;
10
12
 
11
13
  @end
@@ -247,8 +247,16 @@
247
247
  }
248
248
  }
249
249
 
250
+ - (BOOL)shouldPrewarmPush {
251
+ id value = self.options[@"prewarmPush"];
252
+ if ([value isKindOfClass:[NSNumber class]]) {
253
+ return [value boolValue];
254
+ }
255
+ return [self hbd_globalStyle].prewarmPush;
256
+ }
257
+
250
258
  - (BOOL)prepareForAnimatedPushInView:(UIView *)hostView timeout:(NSTimeInterval)timeout completion:(dispatch_block_t)completion {
251
- if (![self hbd_globalStyle].prewarmPush || !completion || !hostView.window || CGRectIsEmpty(hostView.bounds) || ![self canUseCurrentWindowGeometry]) {
259
+ if (![self shouldPrewarmPush] || !completion || !hostView.window || CGRectIsEmpty(hostView.bounds) || ![self canUseCurrentWindowGeometry]) {
252
260
  return NO;
253
261
  }
254
262
 
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": "5.3.0",
4
+ "version": "5.4.0",
5
5
  "main": "./dist/index",
6
6
  "module": "./dist/index",
7
7
  "types": "./dist/index.d.ts",
package/src/Options.ts CHANGED
@@ -27,6 +27,7 @@ export interface NavigationOption {
27
27
 
28
28
  export interface NavigationItem extends NavigationOption {
29
29
  animatedTransition?: boolean;
30
+ prewarmPush?: boolean; // 是否对当前页面的有动画同向全屏主栈 push 启用离屏首帧预热,未设置时继承 DefaultOptions.prewarmPush
30
31
  tabItem?: TabItem;
31
32
  }
32
33