@onekeyfe/react-native-native-overlay 6.7.0-alpha.392 → 6.7.0-alpha.394
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.
- package/docs/SPEC.md +4 -1
- package/ios/RCTNativeOverlayComponentView.mm +42 -15
- package/package.json +1 -1
package/docs/SPEC.md
CHANGED
|
@@ -420,7 +420,10 @@ the correction:
|
|
|
420
420
|
- `windowOffsetRequest` (a counter) and `onWindowOffset({ x, y })`. Each new
|
|
421
421
|
non-zero value makes iOS report the host's on-screen origin once, after the
|
|
422
422
|
commit settles; JS measures a plain sibling probe at the same spot and
|
|
423
|
-
reports `native - measured`. It is `{0, 0}` outside modals.
|
|
423
|
+
reports `native - measured`. It is `{0, 0}` outside modals. A request that
|
|
424
|
+
arrives before window attachment or event-emitter setup stays pending and
|
|
425
|
+
retries after those dependencies attach. It is consumed only after emitting;
|
|
426
|
+
zero cancels a pending request, and a newer value supersedes it.
|
|
424
427
|
- The host's own shadow node reports the content origin, so the probe is a
|
|
425
428
|
separate view.
|
|
426
429
|
- The overlay must be mounted to report, so callers keep it mounted
|
|
@@ -64,6 +64,8 @@ static NSString *RNCNativeOverlayPresentationString(RNCNativeOverlayPresentation
|
|
|
64
64
|
RNCNativeOverlayShadowNode::ConcreteState::Shared _state;
|
|
65
65
|
CGPoint _contentOffset;
|
|
66
66
|
int32_t _hostOriginRequest;
|
|
67
|
+
int32_t _reportedHostOriginRequest;
|
|
68
|
+
BOOL _hostOriginReportScheduled;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
@@ -165,25 +167,48 @@ static NSString *RNCNativeOverlayPresentationString(RNCNativeOverlayPresentation
|
|
|
165
167
|
_containerView.visible = newProps.visible;
|
|
166
168
|
[_containerView commitConfiguration];
|
|
167
169
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
__weak auto weakSelf = self;
|
|
172
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
173
|
-
auto strongSelf = weakSelf;
|
|
174
|
-
if (!strongSelf || !strongSelf.window) return;
|
|
175
|
-
CGPoint origin = [strongSelf convertPoint:CGPointZero toView:nil];
|
|
176
|
-
origin.x += strongSelf.window.frame.origin.x;
|
|
177
|
-
origin.y += strongSelf.window.frame.origin.y;
|
|
178
|
-
auto emitter = std::static_pointer_cast<const RNCNativeOverlayEventEmitter>(strongSelf->_eventEmitter);
|
|
179
|
-
if (!emitter) return;
|
|
180
|
-
emitter->onHostWindowOrigin({.x = origin.x, .y = origin.y});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
170
|
+
_hostOriginRequest = newProps.hostOriginRequest;
|
|
171
|
+
if (_hostOriginRequest == 0) _reportedHostOriginRequest = 0;
|
|
172
|
+
[self scheduleHostWindowOrigin];
|
|
183
173
|
|
|
184
174
|
[super updateProps:props oldProps:oldProps];
|
|
185
175
|
}
|
|
186
176
|
|
|
177
|
+
- (void)didMoveToWindow
|
|
178
|
+
{
|
|
179
|
+
[super didMoveToWindow];
|
|
180
|
+
[self scheduleHostWindowOrigin];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
- (void)updateEventEmitter:(EventEmitter::Shared const &)eventEmitter
|
|
184
|
+
{
|
|
185
|
+
[super updateEventEmitter:eventEmitter];
|
|
186
|
+
[self scheduleHostWindowOrigin];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
- (void)scheduleHostWindowOrigin
|
|
190
|
+
{
|
|
191
|
+
if (_hostOriginRequest == 0 || _hostOriginRequest == _reportedHostOriginRequest || _hostOriginReportScheduled) return;
|
|
192
|
+
_hostOriginReportScheduled = YES;
|
|
193
|
+
__weak auto weakSelf = self;
|
|
194
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
195
|
+
auto strongSelf = weakSelf;
|
|
196
|
+
if (!strongSelf) return;
|
|
197
|
+
strongSelf->_hostOriginReportScheduled = NO;
|
|
198
|
+
const auto request = strongSelf->_hostOriginRequest;
|
|
199
|
+
// Mounting can deliver props before the window or event emitter. Keep
|
|
200
|
+
// the request pending until both are ready; attachment retries it.
|
|
201
|
+
if (request == 0 || request == strongSelf->_reportedHostOriginRequest || !strongSelf.window) return;
|
|
202
|
+
auto emitter = std::static_pointer_cast<const RNCNativeOverlayEventEmitter>(strongSelf->_eventEmitter);
|
|
203
|
+
if (!emitter) return;
|
|
204
|
+
CGPoint origin = [strongSelf convertPoint:CGPointZero toView:nil];
|
|
205
|
+
origin.x += strongSelf.window.frame.origin.x;
|
|
206
|
+
origin.y += strongSelf.window.frame.origin.y;
|
|
207
|
+
strongSelf->_reportedHostOriginRequest = request;
|
|
208
|
+
emitter->onHostWindowOrigin({.x = origin.x, .y = origin.y});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
187
212
|
- (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState
|
|
188
213
|
{
|
|
189
214
|
_state = std::static_pointer_cast<RNCNativeOverlayShadowNode::ConcreteState const>(state);
|
|
@@ -205,6 +230,8 @@ static NSString *RNCNativeOverlayPresentationString(RNCNativeOverlayPresentation
|
|
|
205
230
|
|
|
206
231
|
- (void)invalidate
|
|
207
232
|
{
|
|
233
|
+
_hostOriginRequest = 0;
|
|
234
|
+
_reportedHostOriginRequest = 0;
|
|
208
235
|
[_containerView invalidate];
|
|
209
236
|
[super invalidate];
|
|
210
237
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-overlay",
|
|
3
|
-
"version": "6.7.0-alpha.
|
|
3
|
+
"version": "6.7.0-alpha.394",
|
|
4
4
|
"description": "Native and Web overlay hosts with ordered levels, page scope and Fabric measurement",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|