Fabric: UIManagerBinding::getRelativeLayoutMetrics

Summary: Exposing the getRelativeLayoutMetrics method to JS.

Reviewed By: mdvacca

Differential Revision: D13036552

fbshipit-source-id: de825dfde8e64163168510aea1eda77370753b29
This commit is contained in:
Valentin Shergin
2018-11-27 18:01:01 -08:00
committed by Facebook Github Bot
parent 7b2e3f8159
commit d594d5a4e5

View File

@@ -281,6 +281,29 @@ jsi::Value UIManagerBinding::get(
});
}
if (methodName == "getRelativeLayoutMetrics") {
return jsi::Function::createFromHostFunction(
runtime,
name,
2,
[&uiManager](
jsi::Runtime &runtime,
const jsi::Value &thisValue,
const jsi::Value *arguments,
size_t count) -> jsi::Value {
auto layoutMetrics = uiManager.getRelativeLayoutMetrics(
*shadowNodeFromValue(runtime, arguments[0]),
shadowNodeFromValue(runtime, arguments[1]).get());
auto frame = layoutMetrics.frame;
auto result = jsi::Object(runtime);
result.setProperty(runtime, "left", frame.origin.x);
result.setProperty(runtime, "top", frame.origin.y);
result.setProperty(runtime, "width", frame.size.width);
result.setProperty(runtime, "height", frame.size.height);
return result;
});
}
return jsi::Value::undefined();
}