Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/devtools UI #4141

Merged
merged 10 commits into from
Dec 2, 2024
43 changes: 22 additions & 21 deletions renderer/native/ios/renderer/component/view/HippyViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,29 @@ - (void)measureInAppWindow:(NSNumber *)componentTag
HIPPY_EXPORT_METHOD(getViewTagByLocation:(nonnull NSNumber *)componentTag
params:(NSDictionary *__nonnull)params
callback:(HippyPromiseResolveBlock)callback) {
[self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
NSMutableDictionary *locationDict = [NSMutableDictionary dictionaryWithDictionary:@{
HippyTagKey: @(InvalidTag),
[self.bridge.uiManager addUIBlock:^(__unused HippyUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
NSMutableDictionary *locationDict = [NSMutableDictionary dictionaryWithDictionary:@{
HippyTagKey: @(InvalidTag),
}];
UIView *view = viewRegistry[componentTag];
if (view == nil) {
callback(locationDict);
return;
}
UIView *rootView = viewRegistry[view.rootTag];
if (rootView == nil) {
callback(locationDict);
return;
}
double locationX = [params[HippyXOnScreenKey] doubleValue];
double locationY = [params[HippyYOnScreenKey] doubleValue];
UIView* hitView = [rootView hitTest:{locationX, locationY} withEvent:nil];
// TODO: The hitView may not a hippy view (such as a sub native view). Should trace to hippy view.
if (hitView.hippyTag) {
[locationDict setObject:hitView.hippyTag forKey:HippyTagKey];
}
callback(@[locationDict]);
}];
UIView *view = viewRegistry[componentTag];
if (view == nil) {
callback(locationDict);
return;
}
UIView *rootView = viewRegistry[view.rootTag];
if (rootView == nil) {
callback(locationDict);
return;
}
double locationX = [params[HippyXOnScreenKey] doubleValue];
double locationY = [params[HippyYOnScreenKey] doubleValue];
UIView* hitView = [rootView hitTest:{locationX, locationY} withEvent:nil];
if (hitView != nil && [hitView respondsToSelector:@selector(hippyTag)]) {
[locationDict setObject:hitView.hippyTag forKey:HippyTagKey];
}
callback(@[locationDict]);
}];
}

HIPPY_EXPORT_METHOD(getLocationOnScreen:(nonnull NSNumber *)componentTag
Expand Down
Loading