mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
04782ff57a
Summary: The `measure` API receives LocalData and Props, it should also receive State. This will also be used in future diffs. Reviewed By: mdvacca Differential Revision: D15325182 fbshipit-source-id: 6cb46dd603ce7d46673def16f0ddb517e2cf0c4f
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "SliderMeasurementsManager.h"
|
|
|
|
#include <fb/fbjni.h>
|
|
#include <react/core/conversions.h>
|
|
#include <react/jni/ReadableNativeMap.h>
|
|
|
|
using namespace facebook::jni;
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
Size SliderMeasurementsManager::measure(
|
|
LayoutConstraints layoutConstraints) const {
|
|
{
|
|
std::lock_guard<std::mutex> lock(mutex_);
|
|
if (hasBeenMeasured_) {
|
|
return cachedMeasurement_;
|
|
}
|
|
}
|
|
|
|
const jni::global_ref<jobject> &fabricUIManager =
|
|
contextContainer_->getInstance<jni::global_ref<jobject>>(
|
|
"FabricUIManager");
|
|
|
|
static auto measure =
|
|
jni::findClassStatic("com/facebook/react/fabric/FabricUIManager")
|
|
->getMethod<jlong(
|
|
jstring,
|
|
ReadableMap::javaobject,
|
|
ReadableMap::javaobject,
|
|
ReadableMap::javaobject,
|
|
jfloat,
|
|
jfloat,
|
|
jfloat,
|
|
jfloat)>("measure");
|
|
|
|
auto minimumSize = layoutConstraints.minimumSize;
|
|
auto maximumSize = layoutConstraints.maximumSize;
|
|
|
|
local_ref<JString> componentName = make_jstring("RCTSlider");
|
|
|
|
auto measurement = yogaMeassureToSize(measure(
|
|
fabricUIManager,
|
|
componentName.get(),
|
|
nullptr,
|
|
nullptr,
|
|
nullptr,
|
|
minimumSize.width,
|
|
maximumSize.width,
|
|
minimumSize.height,
|
|
maximumSize.height));
|
|
|
|
std::lock_guard<std::mutex> lock(mutex_);
|
|
cachedMeasurement_ = measurement;
|
|
return measurement;
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|