hybrid-navigation 2.18.13 → 2.20.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.
@@ -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.4'
36
+ api 'io.github.listenzz:AndroidNavigation:13.10.0'
37
37
  }
@@ -64,7 +64,7 @@ public class Garden {
64
64
  boolean extendedLayoutIncludesTopBar;
65
65
 
66
66
  boolean forceTransparentDialogWindow;
67
-
67
+
68
68
  Garden(@NonNull HybridFragment fragment, Style style) {
69
69
  // 构造 garden 实例时,Toolbar 还没有被创建
70
70
 
@@ -79,12 +79,12 @@ public class Garden {
79
79
  Bundle tabItem = options.getBundle("tabItem");
80
80
  this.hidesBottomBarWhenPushed = tabItem == null || tabItem.getBoolean("hideTabBarWhenPush", true);
81
81
  this.extendedLayoutIncludesTopBar = options.getBoolean("extendedLayoutIncludesTopBar", false);
82
-
82
+
83
83
  if (options.get("fitsOpaqueNavigationBarAndroid") != null) {
84
84
  boolean fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid");
85
85
  style.setFitsOpaqueNavigationBar(fitsOpaqueNavigationBar);
86
86
  }
87
-
87
+
88
88
  String screenColor = options.getString("screenBackgroundColor");
89
89
  if (!TextUtils.isEmpty(screenColor)) {
90
90
  style.setScreenBackgroundColor(Color.parseColor(screenColor));
@@ -217,11 +217,6 @@ public class Garden {
217
217
  }
218
218
  }
219
219
 
220
- String statusBarColor = options.getString("statusBarColorAndroid");
221
- if (!TextUtils.isEmpty(statusBarColor)) {
222
- style.setStatusBarColor(Color.parseColor(statusBarColor));
223
- }
224
-
225
220
  String navigationBarColor = options.getString("navigationBarColorAndroid");
226
221
  if (!TextUtils.isEmpty(navigationBarColor)) {
227
222
  style.setNavigationBarColor(Color.parseColor(navigationBarColor));
@@ -329,7 +324,7 @@ public class Garden {
329
324
  }
330
325
 
331
326
  private boolean shouldUpdateStatusBar(@NonNull ReadableMap readableMap) {
332
- String[] keys = new String[]{"topBarStyle", "statusBarColorAndroid", "statusBarHidden", "topBarColor", "displayCutoutWhenLandscapeAndroid"};
327
+ String[] keys = new String[]{"topBarStyle", "statusBarHidden", "topBarColor", "displayCutoutWhenLandscapeAndroid"};
333
328
  for (String key : keys) {
334
329
  if (readableMap.hasKey(key)) {
335
330
  return true;
@@ -31,7 +31,7 @@ public class GlobalStyle {
31
31
  public GlobalStyle(Bundle options) {
32
32
  this.options = options;
33
33
  }
34
-
34
+
35
35
  public void inflateStyle(Context context, Style style) {
36
36
  if (options == null) {
37
37
  FLog.w(TAG, "Style options is null");
@@ -80,15 +80,7 @@ public class GlobalStyle {
80
80
  style.setToolbarBackgroundColorLightContent(Color.parseColor(topBarColorLightContent));
81
81
  }
82
82
 
83
- // statusBarColor
84
- String statusBarColor = options.getString("statusBarColorAndroid");
85
- if (statusBarColor != null) {
86
- style.setStatusBarColor(Color.parseColor(statusBarColor));
87
- } else {
88
- style.setStatusBarColor(Color.TRANSPARENT);
89
- }
90
-
91
- //
83
+ //
92
84
  boolean displayCutout = options.getBoolean("displayCutoutWhenLandscapeAndroid", true);
93
85
  style.setDisplayCutoutWhenLandscape(displayCutout);
94
86
 
@@ -210,11 +202,11 @@ public class GlobalStyle {
210
202
  if (scrimAlpha != -1) {
211
203
  style.setScrimAlpha((int) scrimAlpha);
212
204
  }
213
-
205
+
214
206
  // fitsOpaqueNavigationBarAndroid
215
207
  boolean fitsOpaqueNavigationBar = options.getBoolean("fitsOpaqueNavigationBarAndroid", true);
216
208
  style.setFitsOpaqueNavigationBar(fitsOpaqueNavigationBar);
217
-
209
+
218
210
  }
219
211
 
220
212
  private void setBarBarShadowImage(@NonNull Context context, @NonNull Style style, @NonNull Bundle shadowImage) {
@@ -13,8 +13,8 @@ import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_DISA
13
13
  import static com.reactnative.hybridnavigation.HBDEventEmitter.ON_COMPONENT_RESULT;
14
14
 
15
15
  import android.annotation.SuppressLint;
16
- import android.app.Activity;
17
16
  import android.content.pm.ActivityInfo;
17
+ import android.content.res.Configuration;
18
18
  import android.graphics.Color;
19
19
  import android.os.Bundle;
20
20
  import android.view.Gravity;
@@ -61,6 +61,14 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
61
61
  initReactTitleView();
62
62
  }
63
63
 
64
+ @Override
65
+ public void onStop() {
66
+ super.onStop();
67
+ if (isRemoving() && forceScreenLandscape()) {
68
+ unmountReactView();
69
+ }
70
+ }
71
+
64
72
  @Override
65
73
  protected boolean extendedLayoutIncludesToolbar() {
66
74
  int color = mStyle.getToolbarBackgroundColor();
@@ -93,7 +101,6 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
93
101
  }
94
102
 
95
103
  if (forceScreenLandscape()) {
96
- requireView().clearAnimation();
97
104
  requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
98
105
  }
99
106
  }
@@ -107,23 +114,10 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
107
114
  }
108
115
 
109
116
  @Override
110
- public void onStart() {
111
- super.onStart();
112
- if (forceScreenLandscape()) {
113
- requireView().clearAnimation();
114
- requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
115
- }
116
- }
117
-
118
- @SuppressLint("SourceLockedOrientationActivity")
119
- @Override
120
- public void onStop() {
121
- if (isRemoving() && forceScreenLandscape()) {
122
- Activity activity = requireActivity();
123
- activity.getWindow().getDecorView().postDelayed(() ->
124
- activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT), 16);
125
- }
126
- super.onStop();
117
+ public void onConfigurationChanged(@NonNull Configuration newConfig) {
118
+ super.onConfigurationChanged(newConfig);
119
+ // 避免屏幕旋转时状态栏样式不更新的问题
120
+ setNeedsStatusBarAppearanceUpdate();
127
121
  }
128
122
 
129
123
  private boolean isViewReady() {
package/dist/Options.d.ts CHANGED
@@ -25,7 +25,6 @@ export type LayoutFitting = LayoutFittingExpanded | LayoutFittingCompressed;
25
25
  export interface NavigationOption {
26
26
  screenBackgroundColor?: Color;
27
27
  statusBarHidden?: boolean;
28
- statusBarColorAndroid?: Color;
29
28
  topBarStyle?: BarStyle;
30
29
  topBarColor?: Color;
31
30
  topBarShadowHidden?: boolean;
@@ -91,7 +90,6 @@ export interface DefaultOptions {
91
90
  topBarColor?: Color;
92
91
  topBarColorDarkContent?: Color;
93
92
  topBarColorLightContent?: Color;
94
- statusBarColorAndroid?: Color;
95
93
  navigationBarColorAndroid?: Color;
96
94
  hideBackTitleIOS?: boolean;
97
95
  elevationAndroid?: number;
@@ -123,7 +123,7 @@
123
123
  - (void)adjustScreenOrientation {
124
124
  if (@available(iOS 15.0, *)) {
125
125
  UIWindowScene *windowScene = [self getWindowScene];
126
- if (!self.forceScreenLandscape && windowScene != nil && windowScene.interfaceOrientation != UIInterfaceOrientationPortrait && ![[self hbd_mode] isEqual:@"modal"]) {
126
+ if (!self.forceScreenLandscape && windowScene != nil && windowScene.interfaceOrientation != UIInterfaceOrientationPortrait && ![[self hbd_mode] isEqual:@"modal"]) {
127
127
  [self setScreenOrientation:UIInterfaceOrientationPortrait usingMask:UIInterfaceOrientationMaskPortrait];
128
128
  }
129
129
 
@@ -133,16 +133,6 @@
133
133
  }
134
134
  }
135
135
 
136
- - (void)willMoveToParentViewController:(UIViewController *)parent {
137
- if (self.forceScreenLandscape) {
138
- if (parent) {
139
- [self setScreenOrientation:UIInterfaceOrientationLandscapeRight usingMask:UIInterfaceOrientationMaskLandscape];
140
- } else {
141
- [self setScreenOrientation:UIInterfaceOrientationPortrait usingMask:UIInterfaceOrientationMaskPortrait];
142
- }
143
- }
144
- }
145
-
146
136
  - (void)setScreenOrientation:(UIInterfaceOrientation) orientation usingMask:(UIInterfaceOrientationMask) mask {
147
137
  [GlobalStyle globalStyle].interfaceOrientation = mask;
148
138
  if (@available(iOS 16.0, *)) {
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.13",
4
+ "version": "2.20.0",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
7
7
  "react-native": "src/index",
package/src/Options.ts CHANGED
@@ -29,7 +29,6 @@ export type LayoutFitting = LayoutFittingExpanded | LayoutFittingCompressed;
29
29
  export interface NavigationOption {
30
30
  screenBackgroundColor?: Color; // 页面背景,默认是白色
31
31
  statusBarHidden?: boolean; // 是否隐藏状态栏
32
- statusBarColorAndroid?: Color; // 状态栏背景颜色
33
32
  topBarStyle?: BarStyle; // TopBar 样式,决定了状态栏的颜色,可选项有 `BarStyleLightContent` 和 `BarStyleDarkContent`
34
33
  topBarColor?: Color; // TopBar 背景颜色
35
34
  topBarShadowHidden?: boolean; // 是否隐藏 TopBar 的阴影
@@ -103,7 +102,6 @@ export interface DefaultOptions {
103
102
  topBarColor?: Color; // TopBar 背景颜色,默认根据 topBarStyle 来计算
104
103
  topBarColorDarkContent?: Color; // TopBar 背景颜色,当 topBarStyle 的值为 BarStyleDarkContent 时生效,覆盖 topBarColor 的值
105
104
  topBarColorLightContent?: Color; // TopBar 背景颜色,当 topBarStyle 的值为 BarStyleLightContent 时生效,覆盖 topBarColor 的值
106
- statusBarColorAndroid?: Color; // 状态栏背景颜色,默认取 topBarColor 的值
107
105
  navigationBarColorAndroid?: Color; // 底部虚拟键背景颜色,仅对 Android 8.0 以上版本生效
108
106
  hideBackTitleIOS?: boolean; // 是否隐藏返回按钮旁边的文字,默认是 false, 仅对 iOS 生效
109
107
  elevationAndroid?: number; // TopBar 阴影高度,默认值为 4 dp
@@ -133,10 +131,7 @@ export interface DefaultOptions {
133
131
 
134
132
  export type TabBarStyle = Pick<
135
133
  DefaultOptions,
136
- | 'tabBarColor'
137
- | 'tabBarShadowImage'
138
- | 'tabBarItemColor'
139
- | 'tabBarUnselectedItemColor'
134
+ 'tabBarColor' | 'tabBarShadowImage' | 'tabBarItemColor' | 'tabBarUnselectedItemColor'
140
135
  >;
141
136
 
142
137
  export interface TabItemInfo {