hybrid-navigation 4.0.5 → 4.0.7

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.
@@ -50,9 +50,6 @@ public class ReactFragment extends HybridFragment implements ReactManager.ReactB
50
50
  public void onStop() {
51
51
  super.onStop();
52
52
  if (FragmentHelper.isRemoving(this) && forceScreenLandscape()) {
53
- if (requireActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
54
- requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
55
- }
56
53
  unmountReactView();
57
54
  }
58
55
  }
@@ -73,10 +70,20 @@ public class ReactFragment extends HybridFragment implements ReactManager.ReactB
73
70
  }
74
71
 
75
72
  if (forceScreenLandscape()) {
76
- requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
73
+ if (!isRequestedOrientationLandscape()) {
74
+ requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
75
+ }
77
76
  }
78
77
  }
79
78
 
79
+ private boolean isRequestedOrientationLandscape() {
80
+ int requestedOrientation = requireActivity().getRequestedOrientation();
81
+ return requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE ||
82
+ requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE ||
83
+ requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE ||
84
+ requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE;
85
+ }
86
+
80
87
  @Override
81
88
  public void onPause() {
82
89
  super.onPause();
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <resources>
3
3
  <dimen name="nav_tab_item_min_width">120dp</dimen>
4
- <dimen name="nav_tab_item_width_padding">12dp</dimen>
4
+ <dimen name="nav_tab_item_width_padding">4dp</dimen>
5
5
  <dimen name="nav_tab_item_title_size">12dp</dimen>
6
6
  <dimen name="nav_tab_item_icon_grid">24dp</dimen>
7
7
  <dimen name="nav_tab_item_icon_grid_margin_top">2dp</dimen>
@@ -1,6 +1,6 @@
1
1
  #import "HBDNativeEvent.h"
2
2
  #import "HBDReactBridgeManager.h"
3
- #import <React-RuntimeApple/ReactCommon/RCTHost.h>
3
+ #import <ReactCommon/RCTHost.h>
4
4
  #import <React/RCTLog.h>
5
5
 
6
6
  @implementation HBDNativeEvent
@@ -1,6 +1,6 @@
1
1
  #import <React/RCTBridge.h>
2
2
  #import "HBDNavigator.h"
3
- #import <React-RuntimeApple/ReactCommon/RCTHost.h>
3
+ #import <ReactCommon/RCTHost.h>
4
4
 
5
5
  extern NSString *const ReactModuleRegistryDidCompletedNotification;
6
6
  extern const NSInteger ResultOK;
@@ -1,11 +1,11 @@
1
1
  #import "HBDRootView.h"
2
2
 
3
- #import "RCTConstants.h"
4
- #import "RCTDefines.h"
5
- #import "RCTSurface.h"
6
- #import "RCTSurfaceDelegate.h"
7
- #import "RCTSurfaceView.h"
8
- #import "RCTUtils.h"
3
+ #import <React/RCTConstants.h>
4
+ #import <React/RCTDefines.h>
5
+ #import <React/RCTSurface.h>
6
+ #import <React/RCTSurfaceDelegate.h>
7
+ #import <React/RCTSurfaceView.h>
8
+ #import <React/RCTUtils.h>
9
9
 
10
10
  @interface HBDRootView ()
11
11
 
@@ -12,6 +12,9 @@
12
12
 
13
13
  @property(nonatomic, assign) BOOL firstRenderCompleted;
14
14
  @property(nonatomic, assign) BOOL viewAppeared;
15
+ @property(nonatomic, assign) BOOL appearanceEventSent;
16
+ @property(nonatomic, assign) BOOL appearanceEventScheduled;
17
+ @property(nonatomic, assign) NSUInteger appearanceEventGeneration;
15
18
  @property(nonatomic, strong, readwrite) HBDRootView *rootView;
16
19
 
17
20
  @end
@@ -44,6 +47,9 @@
44
47
 
45
48
  - (void)handleReload {
46
49
  self.firstRenderCompleted = NO;
50
+ self.appearanceEventGeneration += 1;
51
+ self.appearanceEventScheduled = NO;
52
+ self.appearanceEventSent = NO;
47
53
  }
48
54
 
49
55
  - (void)loadView {
@@ -69,6 +75,7 @@
69
75
  - (void)viewDidLayoutSubviews {
70
76
  [super viewDidLayoutSubviews];
71
77
  [self updateReactViewFrame];
78
+ [self scheduleAppearEventAfterLayout];
72
79
  }
73
80
 
74
81
  - (void)updateReactViewFrame {
@@ -98,57 +105,88 @@
98
105
  }
99
106
  }
100
107
 
108
+ // Appearance can start before UIKit has attached and laid out the new scene.
109
+ // Flush that layout first, then notify JS on the next main-queue turn so child
110
+ // safe-area measurements are enqueued before visibility-dependent content.
111
+ - (void)scheduleAppearEventAfterLayout {
112
+ if (!self.firstRenderCompleted || !self.viewAppeared || self.appearanceEventSent ||
113
+ self.appearanceEventScheduled || !self.isViewLoaded || !self.view.window ||
114
+ self.view.bounds.size.width <= 0 || self.view.bounds.size.height <= 0) {
115
+ return;
116
+ }
117
+ self.appearanceEventScheduled = YES;
118
+ NSUInteger generation = self.appearanceEventGeneration;
119
+ __weak HBDReactViewController *weakSelf = self;
120
+ dispatch_async(dispatch_get_main_queue(), ^{
121
+ HBDReactViewController *controller = weakSelf;
122
+ if (!controller || controller.appearanceEventGeneration != generation) {
123
+ return;
124
+ }
125
+ [controller.view.window layoutIfNeeded];
126
+ [controller.view layoutIfNeeded];
127
+ [controller.rootView layoutIfNeeded];
128
+ dispatch_async(dispatch_get_main_queue(), ^{
129
+ HBDReactViewController *current = weakSelf;
130
+ if (!current || current.appearanceEventGeneration != generation) {
131
+ return;
132
+ }
133
+ current.appearanceEventScheduled = NO;
134
+ if (!current.firstRenderCompleted || !current.viewAppeared ||
135
+ current.appearanceEventSent || !current.view.window ||
136
+ current.view.bounds.size.width <= 0 || current.view.bounds.size.height <= 0) {
137
+ return;
138
+ }
139
+ current.appearanceEventSent = YES;
140
+ [current emitAppearEvent];
141
+ });
142
+ });
143
+ }
144
+
145
+ - (void)emitAppearEvent {
146
+ [[HBDNativeEvent getInstance] emitOnComponentAppear:@{@"sceneId": self.sceneId}];
147
+ }
148
+
149
+ - (void)emitDisappearEvent {
150
+ [[HBDNativeEvent getInstance] emitOnComponentDisappear:@{@"sceneId": self.sceneId}];
151
+ }
152
+
153
+ - (void)finishAppearance {
154
+ self.viewAppeared = NO;
155
+ self.appearanceEventGeneration += 1;
156
+ self.appearanceEventScheduled = NO;
157
+ if (self.appearanceEventSent) {
158
+ self.appearanceEventSent = NO;
159
+ [self emitDisappearEvent];
160
+ }
161
+ }
162
+
101
163
  - (void)viewWillAppear:(BOOL)animated {
102
164
  [super viewWillAppear:animated];
103
165
  id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
104
166
  if (coordinator && !coordinator.interactive) {
105
- if (!self.viewAppeared) {
106
- self.viewAppeared = YES;
107
- if (self.firstRenderCompleted) {
108
- [[HBDNativeEvent getInstance] emitOnComponentAppear:@{
109
- @"sceneId": self.sceneId,
110
- }];
111
- }
112
- }
167
+ self.viewAppeared = YES;
168
+ [self scheduleAppearEventAfterLayout];
113
169
  }
114
170
  }
115
171
 
116
172
  - (void)viewDidAppear:(BOOL)animated {
117
173
  [super viewDidAppear:animated];
118
- if (!self.viewAppeared) {
119
- self.viewAppeared = YES;
120
- if (self.firstRenderCompleted) {
121
- [[HBDNativeEvent getInstance] emitOnComponentAppear:@{
122
- @"sceneId": self.sceneId,
123
- }];
124
- }
125
- }
174
+ self.viewAppeared = YES;
175
+ [self scheduleAppearEventAfterLayout];
126
176
  }
127
177
 
128
178
  - (void)viewWillDisappear:(BOOL)animated {
129
179
  [super viewWillDisappear:animated];
130
180
  id <UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
131
- if (coordinator && !coordinator.interactive) {
132
- if (self.viewAppeared) {
133
- self.viewAppeared = NO;
134
- if (self.firstRenderCompleted) {
135
- [[HBDNativeEvent getInstance] emitOnComponentDisappear:@{
136
- @"sceneId": self.sceneId,
137
- }];
138
- }
139
- }
181
+ if (coordinator && !coordinator.interactive && self.viewAppeared) {
182
+ [self finishAppearance];
140
183
  }
141
184
  }
142
185
 
143
186
  - (void)viewDidDisappear:(BOOL)animated {
144
187
  [super viewDidDisappear:animated];
145
188
  if (self.viewAppeared) {
146
- self.viewAppeared = NO;
147
- if (self.firstRenderCompleted) {
148
- [[HBDNativeEvent getInstance] emitOnComponentDisappear:@{
149
- @"sceneId": self.sceneId,
150
- }];
151
- }
189
+ [self finishAppearance];
152
190
  }
153
191
  }
154
192
 
@@ -157,13 +195,7 @@
157
195
  return;
158
196
  }
159
197
  self.firstRenderCompleted = YES;
160
- if (self.viewAppeared) {
161
- if (self.firstRenderCompleted) {
162
- [[HBDNativeEvent getInstance] emitOnComponentAppear:@{
163
- @"sceneId": self.sceneId,
164
- }];
165
- }
166
- }
198
+ [self scheduleAppearEventAfterLayout];
167
199
  }
168
200
 
169
201
  - (void)didReceiveResultCode:(NSInteger)resultCode resultData:(NSDictionary *)data requestCode:(NSInteger)requestCode {
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": "4.0.5",
4
+ "version": "4.0.7",
5
5
  "main": "./dist/index",
6
6
  "module": "./dist/index",
7
7
  "types": "./dist/index.d.ts",