hybrid-navigation 3.1.0 → 3.1.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.
@@ -379,22 +379,26 @@
379
379
 
380
380
  // Fake bar: hide real bar (alpha=0) and add fromFakeBar/toFakeBar on each VC's view for smooth bar color change.
381
381
  - (BOOL)shouldShowFakeBarFrom:(UIViewController *)from to:(UIViewController *)to viewController:(UIViewController *_Nonnull)viewController {
382
+ if ([GlobalStyle globalStyle].topBarHidden) {
383
+ return NO;
384
+ }
385
+
386
+ if ([GlobalStyle globalStyle].alwaysSplitNavigationBarTransition && to == viewController) {
387
+ return YES;
388
+ }
389
+
382
390
  if (to != viewController) {
383
391
  return NO;
384
392
  }
385
- // toVC 的 bar 为 hidden 时直接隐藏 UINavigationBar,不使用 fake bar
386
- if (to.hbd_barHidden) {
387
- return NO;
388
- }
389
- if ([GlobalStyle globalStyle].alwaysSplitNavigationBarTransition && to == viewController) {
390
- return YES;
391
- }
392
-
393
+
393
394
  if (![from.hbd_barTintColor.description isEqual:to.hbd_barTintColor.description]) {
395
+ RCTLogInfo(@"from:%@, to:%@",
396
+ from.hbd_barTintColor.description,
397
+ to.hbd_barTintColor.description);
394
398
  return YES;
395
399
  }
396
400
 
397
- return from.hbd_barAlpha < 1.0 || to.hbd_barAlpha < 1.0;
401
+ return from.hbd_barAlpha < 1.0 || to.hbd_barAlpha < 1.0;
398
402
  }
399
403
 
400
404
  @end
@@ -482,6 +486,8 @@
482
486
  }
483
487
  }
484
488
 
489
+ /// 修正非 iPhone X 机型在 iOS 13+ 上,随 hbd_statusBarHidden 切换时系统 safe area 不准确的问题。
490
+ /// 刘海屏由系统处理即可;非刘海屏状态栏高度 20pt,系统有时报 0 或 40,需用 additionalSafeAreaInsets 补偿。
485
491
  - (void)viewSafeAreaInsetsDidChange {
486
492
  [super viewSafeAreaInsetsDidChange];
487
493
  if ([HBDUtils isIphoneX]) {
@@ -492,12 +498,14 @@
492
498
  UIEdgeInsets safeAreaInsets = self.view.safeAreaInsets;
493
499
  UIEdgeInsets additionalInsets = self.additionalSafeAreaInsets;
494
500
 
495
- BOOL statusBarHidden = RCTKeyWindow().windowScene.statusBarManager.statusBarHidden;
501
+ BOOL statusBarHidden = RCTKeyWindow().windowScene.statusBarManager.statusBarHidden;
496
502
 
503
+ // 状态栏隐藏时系统可能把 top 算成 0,补 20pt 避免内容贴顶
497
504
  if (statusBarHidden && safeAreaInsets.top == 0) {
498
505
  self.additionalSafeAreaInsets = UIEdgeInsetsMake(20, additionalInsets.left, additionalInsets.bottom, additionalInsets.right);
499
506
  }
500
507
 
508
+ // 状态栏显示时系统有时把 top 算成 40(多算 20pt),减 20pt 使有效 top 为状态栏高度
501
509
  if (!statusBarHidden && safeAreaInsets.top == 40) {
502
510
  self.additionalSafeAreaInsets = UIEdgeInsetsMake(-20, additionalInsets.left, additionalInsets.bottom, additionalInsets.right);
503
511
  }
@@ -85,7 +85,7 @@
85
85
 
86
86
  - (void)viewSafeAreaInsetsDidChange {
87
87
  [super viewSafeAreaInsetsDidChange];
88
- if (self.hbd_shouldCorrectSafeAreaTopToStatusBar) {
88
+ if (self.shouldAdjustSafeAreaTopToStatusBar) {
89
89
  CGFloat statusBarHeight = [self hbd_statusBarHeight];
90
90
  CGFloat currentEffectiveTop = self.view.safeAreaInsets.top;
91
91
  if (fabs(currentEffectiveTop - statusBarHeight) > 0.5) {
@@ -97,11 +97,6 @@
97
97
  [self updateReactViewConstraints];
98
98
  }
99
99
 
100
- - (void)viewDidLayoutSubviews {
101
- [super viewDidLayoutSubviews];
102
- [self updateReactViewConstraints];
103
- }
104
-
105
100
  - (CGFloat)hbd_statusBarHeight {
106
101
  if (@available(iOS 13.0, *)) {
107
102
  UIWindowScene *scene = self.view.window.windowScene;
@@ -113,7 +108,7 @@
113
108
  }
114
109
 
115
110
  /// 局部隐藏 topBar 或局部透明 topBar(非全局隐藏)时,需将 SafeArea 顶部修正为状态栏高度
116
- - (BOOL)hbd_shouldCorrectSafeAreaTopToStatusBar {
111
+ - (BOOL)shouldAdjustSafeAreaTopToStatusBar {
117
112
  if ([GlobalStyle globalStyle].topBarHidden) {
118
113
  return NO;
119
114
  }
@@ -123,15 +118,15 @@
123
118
  return self.hbd_barHidden || self.hbd_barAlpha < 1.0 || colorHasAlphaComponent(self.hbd_barTintColor);
124
119
  }
125
120
 
121
+ - (void)viewDidLayoutSubviews {
122
+ [super viewDidLayoutSubviews];
123
+ [self updateReactViewConstraints];
124
+ }
125
+
126
126
  - (void)updateReactViewConstraints {
127
127
  if (self.isViewLoaded && self.rootView) {
128
128
  CGFloat bottomInset = self.shouldFitWindowInsetsBottom ? 0: self.tabBarController.tabBar.frame.size.height;
129
- CGFloat topInset;
130
- if (self.shouldFitWindowInsetsTop) {
131
- topInset = self.hbd_shouldCorrectSafeAreaTopToStatusBar ? [self hbd_statusBarHeight] : 0;
132
- } else {
133
- topInset = self.view.safeAreaInsets.top;
134
- }
129
+ CGFloat topInset = self.shouldFitWindowInsetsTop ? 0 : self.view.safeAreaInsets.top;
135
130
  [self.rootView setFrame:CGRectMake(
136
131
  0,
137
132
  topInset,
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": "3.1.0",
4
+ "version": "3.1.1",
5
5
  "main": "./dist/index",
6
6
  "module": "./dist/index",
7
7
  "types": "./dist/index.d.ts",