mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
refactor: use same rectangle spec for DebuggingOverlay native commands (#41742)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41742 Changelog: [Internal] TSIA Reviewed By: sammy-SC Differential Revision: D51708055 fbshipit-source-id: 9173f7742af0a89f43f83611d8cb15d9bad77eb4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1b9310e4b2
commit
128ff5024a
+1
-1
@@ -21,7 +21,7 @@ type NativeProps = $ReadOnly<{|
|
||||
|}>;
|
||||
export type DebuggingOverlayNativeComponentType = HostComponent<NativeProps>;
|
||||
export type Overlay = {
|
||||
rect: {left: number, top: number, width: number, height: number},
|
||||
rect: ElementRectangle,
|
||||
color: ?ProcessedColorValue,
|
||||
};
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class DebuggingOverlayRegistry {
|
||||
// TODO(T171095283): We should refactor this to use `getBoundingClientRect` when Paper is no longer supported.
|
||||
publicInstance.measure((x, y, width, height, left, top) => {
|
||||
resolve({
|
||||
rect: {left, top, width, height},
|
||||
rect: {x: left, y: top, width, height},
|
||||
color: processColor(color),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4770,7 +4770,7 @@ exports[`public API should not change unintentionally Libraries/Debugging/Debugg
|
||||
|}>;
|
||||
export type DebuggingOverlayNativeComponentType = HostComponent<NativeProps>;
|
||||
export type Overlay = {
|
||||
rect: { left: number, top: number, width: number, height: number },
|
||||
rect: ElementRectangle,
|
||||
color: ?ProcessedColorValue,
|
||||
};
|
||||
export type ElementRectangle = {
|
||||
|
||||
@@ -38,12 +38,7 @@
|
||||
NSDictionary *nodeRectangle = node[@"rect"];
|
||||
NSNumber *nodeColor = node[@"color"];
|
||||
|
||||
NSNumber *x = nodeRectangle[@"left"];
|
||||
NSNumber *y = nodeRectangle[@"top"];
|
||||
NSNumber *width = nodeRectangle[@"width"];
|
||||
NSNumber *height = nodeRectangle[@"height"];
|
||||
|
||||
CGRect rect = CGRectMake(x.doubleValue, y.doubleValue, width.doubleValue, height.doubleValue);
|
||||
CGRect rect = [RCTConvert CGRect:nodeRectangle];
|
||||
|
||||
UIView *box = [[UIView alloc] initWithFrame:rect];
|
||||
box.backgroundColor = [UIColor clearColor];
|
||||
|
||||
+2
-2
@@ -50,8 +50,8 @@ public class DebuggingOverlayManager extends SimpleViewManager<DebuggingOverlay>
|
||||
for (int i = 0; i < overlaysArr.length(); i++) {
|
||||
JSONObject overlay = overlaysArr.getJSONObject(i);
|
||||
JSONObject rectObj = overlay.getJSONObject("rect");
|
||||
float left = (float) rectObj.getDouble("left");
|
||||
float top = (float) rectObj.getDouble("top");
|
||||
float left = (float) rectObj.getDouble("x");
|
||||
float top = (float) rectObj.getDouble("y");
|
||||
float right = (float) (left + rectObj.getDouble("width"));
|
||||
float bottom = (float) (top + rectObj.getDouble("height"));
|
||||
RectF rect = new RectF(left, top, right, bottom);
|
||||
|
||||
Reference in New Issue
Block a user