hybrid-navigation 2.18.14 → 2.20.1

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,7 +13,6 @@ 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;
18
17
  import android.content.res.Configuration;
19
18
  import android.graphics.Color;
@@ -62,6 +61,14 @@ public class ReactFragment extends HybridFragment implements ReactBridgeManager.
62
61
  initReactTitleView();
63
62
  }
64
63
 
64
+ @Override
65
+ public void onStop() {
66
+ super.onStop();
67
+ if (isRemoving() && forceScreenLandscape()) {
68
+ unmountReactView();
69
+ }
70
+ }
71
+
65
72
  @Override
66
73
  protected boolean extendedLayoutIncludesToolbar() {
67
74
  int color = mStyle.getToolbarBackgroundColor();
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;
@@ -36,20 +36,28 @@
36
36
  @implementation HBDBarButtonItem
37
37
 
38
38
  - (instancetype)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style {
39
- HBDImageBarButton *button = [HBDImageBarButton buttonWithType:UIButtonTypeSystem];
40
- button.translatesAutoresizingMaskIntoConstraints = NO;
41
- [button setFrame:CGRectMake(0, 0, 32, 32)];
42
- [button setImage:image forState:UIControlStateNormal];
43
- [button addTarget:self action:@selector(didButtonClick) forControlEvents:UIControlEventTouchUpInside];
44
- return [super initWithCustomView:button];
39
+ if (@available(iOS 26.0, *)) {
40
+ return [super initWithImage:image style:style target:self action:@selector(didButtonClick)];
41
+ } else {
42
+ HBDImageBarButton *button = [HBDImageBarButton buttonWithType:UIButtonTypeSystem];
43
+ button.translatesAutoresizingMaskIntoConstraints = NO;
44
+ [button setFrame:CGRectMake(0, 0, 32, 32)];
45
+ [button setImage:image forState:UIControlStateNormal];
46
+ [button addTarget:self action:@selector(didButtonClick) forControlEvents:UIControlEventTouchUpInside];
47
+ return [super initWithCustomView:button];
48
+ }
45
49
  }
46
50
 
47
51
  - (instancetype)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style {
48
- UIButton *button = [HBDTextBarButton buttonWithType:UIButtonTypeSystem];
49
- button.translatesAutoresizingMaskIntoConstraints = NO;
50
- [button setTitle:title forState:UIControlStateNormal];
51
- [button addTarget:self action:@selector(didButtonClick) forControlEvents:UIControlEventTouchUpInside];
52
- return [super initWithCustomView:button];
52
+ if (@available(iOS 26.0, *)) {
53
+ return [super initWithTitle:title style:style target:self action:@selector(didButtonClick)];
54
+ } else {
55
+ UIButton *button = [HBDTextBarButton buttonWithType:UIButtonTypeSystem];
56
+ button.translatesAutoresizingMaskIntoConstraints = NO;
57
+ [button setTitle:title forState:UIControlStateNormal];
58
+ [button addTarget:self action:@selector(didButtonClick) forControlEvents:UIControlEventTouchUpInside];
59
+ return [super initWithCustomView:button];
60
+ }
53
61
  }
54
62
 
55
63
  - (void)didButtonClick {
@@ -24,7 +24,7 @@
24
24
  if (view && [viewName isEqualToString:@"HBDNavigationBar"]) {
25
25
  for (UIView *subview in self.subviews) {
26
26
  NSString *viewName = [[[subview classForCoder] description] stringByReplacingOccurrencesOfString:@"_" withString:@""];
27
- NSArray *array = @[@"UINavigationItemButtonView"];
27
+ NSArray *array = @[@"UINavigationItemButtonView", @"UIKit.NavigationBarContentView", @"UIButtonBarButton"];
28
28
  if ([array containsObject:viewName]) {
29
29
  CGPoint convertedPoint = [self convertPoint:point toView:subview];
30
30
  CGRect bounds = subview.bounds;
@@ -38,7 +38,7 @@
38
38
  }
39
39
  }
40
40
 
41
- NSArray *array = @[@"UINavigationBarContentView", @"UIButtonBarStackView", @"HBDNavigationBar"];
41
+ NSArray *array = @[@"UINavigationBarContentView", @"UIButtonBarStackView", @"UIKit.NavigationBarContentView", @"UIButtonBarButton", NSStringFromClass([self class])];
42
42
  if ([array containsObject:viewName]) {
43
43
  if (self.fakeBackgroundView.alpha < 0.01) {
44
44
  return nil;
@@ -119,11 +119,11 @@
119
119
  }
120
120
 
121
121
  - (UILabel *)backButtonLabel {
122
- UIView *navigationBarContentView = [self valueForKeyPath:@"visualProvider.contentView"];
122
+ UIView *navigationBarContentView = [self getViewFromContext:self withKeyPath:@"visualProvider.contentView"];
123
123
  __block UILabel *backButtonLabel = nil;
124
124
  [navigationBarContentView.subviews enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIView *_Nonnull subview, NSUInteger idx, BOOL *_Nonnull stop) {
125
125
  if ([subview isKindOfClass:NSClassFromString(@"_UIButtonBarButton")]) {
126
- UIButton *titleButton = [subview valueForKeyPath:@"visualProvider.titleButton"];
126
+ UIButton *titleButton = (UIButton *)[self getViewFromContext:subview withKeyPath:@"visualProvider.titleButton"];
127
127
  backButtonLabel = titleButton.titleLabel;
128
128
  *stop = YES;
129
129
  }
@@ -131,6 +131,70 @@
131
131
  return backButtonLabel;
132
132
  }
133
133
 
134
+ // 兼容 iOS26
135
+ - (UIView *)getViewFromContext:(id)context withKeyPath:(NSString *)keyPath {
136
+ if (!context || !keyPath) {
137
+ return nil;
138
+ }
139
+
140
+ if (@available(iOS 26.0, *)) {
141
+ // 如果 context 是 UIView,先尝试通过遍历 subviews 查找包含 "ContentView" 的视图
142
+ if ([context isKindOfClass:[UIView class]]) {
143
+ UIView *view = (UIView *)context;
144
+ __block UIView *contentView = nil;
145
+
146
+ // 使用标准的 enumerateObjectsUsingBlock 替代 qmui_firstMatchWithBlock
147
+ [view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull item, NSUInteger idx, BOOL * _Nonnull stop) {
148
+ if ([NSStringFromClass(item.class) containsString:@"ContentView"]) {
149
+ contentView = item;
150
+ *stop = YES;
151
+ }
152
+ }];
153
+
154
+ if (contentView) return contentView;
155
+ }
156
+
157
+ // Xcode 26 编译在 iOS 26 上时,无法用以前的 KVC 方式获取 contentView,所以改为通过 Ivar 获取
158
+ // 解析 keyPath,获取 provider key(例如从 "visualProvider.contentView" 中获取 "visualProvider")
159
+ NSArray *components = [keyPath componentsSeparatedByString:@"."];
160
+ if (components.count > 0) {
161
+ NSString *providerKey = components.firstObject;
162
+ NSObject *provider = [context valueForKey:providerKey];
163
+
164
+ if (provider && components.count > 1) {
165
+ NSString *targetKey = components.lastObject;
166
+ __block UIView *result = nil;
167
+
168
+ // 使用 Runtime API 直接获取 Ivar 列表,替代 qmui_enumrateIvarsUsingBlock
169
+ unsigned int ivarCount = 0;
170
+ Ivar *ivars = class_copyIvarList([provider class], &ivarCount);
171
+
172
+ if (ivars) {
173
+ for (unsigned int i = 0; i < ivarCount && !result; i++) {
174
+ Ivar ivar = ivars[i];
175
+ const char *ivarName = ivar_getName(ivar);
176
+
177
+ if (ivarName) {
178
+ NSString *ivarNameString = [NSString stringWithUTF8String:ivarName];
179
+ // 检查 ivar 名称是否包含 targetKey
180
+ if ([ivarNameString containsString:targetKey]) {
181
+ // 直接使用 object_getIvar 获取 Ivar 值,替代 getObjectIvarValue
182
+ result = object_getIvar(provider, ivar);
183
+ }
184
+ }
185
+ }
186
+ free(ivars);
187
+ }
188
+
189
+ return result;
190
+ }
191
+ }
192
+ }
193
+
194
+ // 在 iOS 26.0 以下,直接通过 KVC 获取
195
+ return [context valueForKeyPath:keyPath];
196
+ }
197
+
134
198
  @end
135
199
 
136
200
  @implementation UILabel (NavigationBarTransition)
@@ -160,5 +224,4 @@
160
224
  [self hbd_setAttributedText:attributedText];
161
225
  }
162
226
 
163
-
164
227
  @end
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.14",
4
+ "version": "2.20.1",
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 {