hybrid-navigation 2.18.12 → 2.18.14

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.
@@ -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:13.8.3'
36
+ api 'io.github.listenzz:AndroidNavigation:13.8.4'
37
37
  }
@@ -15,6 +15,7 @@ import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_RESU
15
15
  import android.annotation.SuppressLint;
16
16
  import android.app.Activity;
17
17
  import android.content.pm.ActivityInfo;
18
+ import android.content.res.Configuration;
18
19
  import android.graphics.Color;
19
20
  import android.os.Bundle;
20
21
  import android.view.Gravity;
@@ -88,8 +89,13 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
88
89
  if (!forceScreenLandscape() &&
89
90
  !Navigator.MODE_MODAL.equals(Navigator.Util.getMode(this)) &&
90
91
  requireActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
92
+ requireView().clearAnimation();
91
93
  requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
92
94
  }
95
+
96
+ if (forceScreenLandscape()) {
97
+ requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
98
+ }
93
99
  }
94
100
 
95
101
  @Override
@@ -101,22 +107,10 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
101
107
  }
102
108
 
103
109
  @Override
104
- public void onStart() {
105
- super.onStart();
106
- if (forceScreenLandscape()) {
107
- requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
108
- }
109
- }
110
-
111
- @SuppressLint("SourceLockedOrientationActivity")
112
- @Override
113
- public void onStop() {
114
- if (isRemoving() && forceScreenLandscape()) {
115
- Activity activity = requireActivity();
116
- activity.getWindow().getDecorView().postDelayed(() ->
117
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT), 16);
118
- }
119
- super.onStop();
110
+ public void onConfigurationChanged(@NonNull Configuration newConfig) {
111
+ super.onConfigurationChanged(newConfig);
112
+ // 避免屏幕旋转时状态栏样式不更新的问题
113
+ setNeedsStatusBarAppearanceUpdate();
120
114
  }
121
115
 
122
116
  private boolean isViewReady() {
package/dist/Navigator.js CHANGED
@@ -77,6 +77,7 @@ class Navigator {
77
77
  moduleName,
78
78
  inclusive,
79
79
  from: this.moduleName,
80
+ to: moduleName,
80
81
  });
81
82
  popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot', { from: this.moduleName });
82
83
  redirectTo = (moduleName, props = {}, options = {}) => Navigation.dispatch(this.sceneId, 'redirectTo', {
@@ -96,6 +96,13 @@
96
96
  return NO;
97
97
  }
98
98
 
99
+ - (void)viewWillAppear:(BOOL)animated {
100
+ [super viewWillAppear:animated];
101
+ if (!self.navigationController.transitionCoordinator.interactive) {
102
+ [self adjustScreenOrientation];
103
+ }
104
+ }
105
+
99
106
  - (void)viewDidAppear:(BOOL)animated {
100
107
  [super viewDidAppear:animated];
101
108
  [[HBDAnimationObserver sharedObserver] endAnimation];
@@ -103,16 +110,7 @@
103
110
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
104
111
  }
105
112
 
106
- if (@available(iOS 15.0, *)) {
107
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.016 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
108
- UIWindowScene *windowScene = [self getWindowScene];
109
- if (windowScene != nil) {
110
- if (!self.forceScreenLandscape && windowScene.interfaceOrientation != UIInterfaceOrientationPortrait && ![[self hbd_mode] isEqual:@"modal"]) {
111
- [self setScreenOrientation:UIInterfaceOrientationPortrait usingMask:UIInterfaceOrientationMaskPortrait];
112
- }
113
- }
114
- });
115
- }
113
+ [self adjustScreenOrientation];
116
114
  }
117
115
 
118
116
  - (void)viewDidDisappear:(BOOL)animated {
@@ -122,14 +120,17 @@
122
120
  }
123
121
  }
124
122
 
125
- - (void)willMoveToParentViewController:(UIViewController *)parent {
126
- if (self.forceScreenLandscape) {
127
- if (parent) {
128
- [self setScreenOrientation:UIInterfaceOrientationLandscapeRight usingMask:UIInterfaceOrientationMaskLandscape];
129
- } else {
130
- [self setScreenOrientation:UIInterfaceOrientationPortrait usingMask:UIInterfaceOrientationMaskPortrait];
131
- }
132
- }
123
+ - (void)adjustScreenOrientation {
124
+ if (@available(iOS 15.0, *)) {
125
+ UIWindowScene *windowScene = [self getWindowScene];
126
+ if (!self.forceScreenLandscape && windowScene != nil && windowScene.interfaceOrientation != UIInterfaceOrientationPortrait && ![[self hbd_mode] isEqual:@"modal"]) {
127
+ [self setScreenOrientation:UIInterfaceOrientationPortrait usingMask:UIInterfaceOrientationMaskPortrait];
128
+ }
129
+
130
+ if (self.forceScreenLandscape) {
131
+ [self setScreenOrientation:UIInterfaceOrientationLandscapeRight usingMask:UIInterfaceOrientationMaskLandscape];
132
+ }
133
+ }
133
134
  }
134
135
 
135
136
  - (void)setScreenOrientation:(UIInterfaceOrientation) orientation usingMask:(UIInterfaceOrientationMask) mask {
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.18.12",
4
+ "version": "2.18.14",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
7
7
  "react-native": "src/index",
package/src/Navigator.ts CHANGED
@@ -106,6 +106,7 @@ export class Navigator implements Navigator {
106
106
  moduleName,
107
107
  inclusive,
108
108
  from: this.moduleName,
109
+ to: moduleName,
109
110
  });
110
111
 
111
112
  popToRoot = () => Navigation.dispatch(this.sceneId, 'popToRoot', {from: this.moduleName});