hybrid-navigation 3.0.1 → 3.0.2

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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  #import "HBDReactBridgeManager.h"
4
4
  #import "HBDTitleView.h"
5
- #import "HBDRootView.h"
6
5
  #import "HBDUtils.h"
7
6
  #import "HBDNativeEvent.h"
8
7
 
@@ -47,8 +46,10 @@
47
46
  BOOL passThroughTouches = [self.options[@"passThroughTouches"] boolValue];
48
47
  rootView.passThroughTouches = passThroughTouches;
49
48
  rootView.backgroundColor = UIColor.clearColor;
50
- rootView.translatesAutoresizingMaskIntoConstraints = NO;
51
- self.view = [[HBDRootView alloc] initWithRootView:rootView];
49
+ rootView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
50
+
51
+ self.view = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds];
52
+ [rootView setFrame:self.view.frame];
52
53
  [self.view addSubview:rootView];
53
54
  [self updateReactViewConstraints];
54
55
  RCTLogInfo(@"[Navigation] 加载页面 %@", self.moduleName);
@@ -70,7 +71,7 @@
70
71
  } else {
71
72
  size = UILayoutFittingCompressedSize;
72
73
  }
73
-
74
+
74
75
  RCTHost *host = [HBDReactBridgeManager get].rctHost;
75
76
  RCTFabricSurface *surface = [host createSurfaceWithModuleName:moduleName initialProperties:[self propsWithSceneId]];
76
77
  RCTSurfaceHostingProxyRootView *titleRootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:(id)surface];
@@ -87,20 +88,18 @@
87
88
 
88
89
  - (void)updateReactViewConstraints {
89
90
  if (self.isViewLoaded && self.rootView) {
90
- [NSLayoutConstraint deactivateConstraints:_reactViewConstraints];
91
- _reactViewConstraints = @[
92
- [self.rootView.topAnchor
93
- constraintEqualToAnchor:self.shouldFitWindowInsetTop ? self.view.topAnchor : self.view.safeAreaLayoutGuide.topAnchor],
94
- [self.rootView.bottomAnchor
95
- constraintEqualToAnchor:self.view.bottomAnchor],
96
- [self.rootView.leftAnchor constraintEqualToAnchor:self.view.leftAnchor],
97
- [self.rootView.rightAnchor constraintEqualToAnchor:self.view.rightAnchor]
98
- ];
99
- [NSLayoutConstraint activateConstraints:_reactViewConstraints];
91
+ CGFloat bottomInset = self.shouldFitWindowInsetsBottom ? 0: self.view.safeAreaInsets.bottom;
92
+ CGFloat topInset = self.shouldFitWindowInsetsTop ? 0 : self.view.safeAreaInsets.top;
93
+ [self.rootView setFrame:CGRectMake(
94
+ 0,
95
+ topInset,
96
+ self.view.frame.size.width,
97
+ self.view.frame.size.height - topInset - bottomInset
98
+ )];
100
99
  }
101
100
  }
102
101
 
103
- - (BOOL)shouldFitWindowInsetTop {
102
+ - (BOOL)shouldFitWindowInsetsTop {
104
103
  if (![self.parentViewController isKindOfClass:UINavigationController.class]) {
105
104
  return YES;
106
105
  }
@@ -108,11 +107,11 @@
108
107
  return isTranslucent || self.extendedLayoutIncludesOpaqueBars;
109
108
  }
110
109
 
111
- - (BOOL)shouldFitSafeAreaLayoutBottom {
110
+ - (BOOL)shouldFitWindowInsetsBottom {
112
111
  if (self.navigationController && self.tabBarController) {
113
- return self == [self.navigationController.viewControllers firstObject];
112
+ return self != [self.navigationController.viewControllers firstObject];
114
113
  }
115
- return NO;
114
+ return YES;
116
115
  }
117
116
 
118
117
  - (NSDictionary *)propsWithSceneId {
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.0.1",
4
+ "version": "3.0.2",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",
7
7
  "react-native": "src/index",