first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
file(GLOB rrc_progressbar_SRC CONFIGURE_DEPENDS android/react/renderer/components/progressbar/*.cpp)
add_library(rrc_progressbar OBJECT ${rrc_progressbar_SRC})
target_include_directories(rrc_progressbar
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/android/
)
target_link_libraries(rrc_progressbar
glog
fbjni
folly_runtime
glog_init
react_codegen_rncore
react_debug
react_renderer_componentregistry
react_renderer_core
react_renderer_debug
react_renderer_graphics
react_renderer_uimanager
reactnativejni
rrc_view
yoga
)
target_compile_reactnative_options(rrc_progressbar PRIVATE)
target_compile_options(rrc_progressbar PRIVATE -Wpedantic)

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include "AndroidProgressBarMeasurementsManager.h"
#include "AndroidProgressBarShadowNode.h"
namespace facebook::react {
/*
* Descriptor for <AndroidProgressBar> component.
*/
class AndroidProgressBarComponentDescriptor final : public ConcreteComponentDescriptor<AndroidProgressBarShadowNode> {
public:
AndroidProgressBarComponentDescriptor(const ComponentDescriptorParameters &parameters)
: ConcreteComponentDescriptor(parameters),
measurementsManager_(std::make_shared<AndroidProgressBarMeasurementsManager>(contextContainer_))
{
}
void adopt(ShadowNode &shadowNode) const override
{
ConcreteComponentDescriptor::adopt(shadowNode);
auto &androidProgressBarShadowNode = static_cast<AndroidProgressBarShadowNode &>(shadowNode);
// `AndroidProgressBarShadowNode` uses
// `AndroidProgressBarMeasurementsManager` to provide measurements to Yoga.
androidProgressBarShadowNode.setAndroidProgressBarMeasurementsManager(measurementsManager_);
}
private:
const std::shared_ptr<AndroidProgressBarMeasurementsManager> measurementsManager_;
};
} // namespace facebook::react

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "AndroidProgressBarMeasurementsManager.h"
#include <fbjni/fbjni.h>
#include <react/jni/ReadableNativeMap.h>
#include <react/renderer/components/progressbar/conversions.h>
#include <react/renderer/core/conversions.h>
using namespace facebook::jni;
namespace facebook::react {
Size AndroidProgressBarMeasurementsManager::measure(
SurfaceId surfaceId,
const AndroidProgressBarProps& props,
LayoutConstraints layoutConstraints) const {
const jni::global_ref<jobject>& fabricUIManager =
contextContainer_->at<jni::global_ref<jobject>>("FabricUIManager");
static auto measure = facebook::jni::findClassStatic(
"com/facebook/react/fabric/FabricUIManager")
->getMethod<jlong(
jint,
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("AndroidProgressBar");
auto serialiazedProps = toDynamic(props);
local_ref<ReadableNativeMap::javaobject> propsRNM =
ReadableNativeMap::newObjectCxxArgs(serialiazedProps);
local_ref<ReadableMap::javaobject> propsRM =
make_local(reinterpret_cast<ReadableMap::javaobject>(propsRNM.get()));
return yogaMeassureToSize(measure(
fabricUIManager,
surfaceId,
componentName.get(),
nullptr,
propsRM.get(),
nullptr,
minimumSize.width,
maximumSize.width,
minimumSize.height,
maximumSize.height));
}
} // namespace facebook::react

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <react/renderer/components/FBReactNativeSpec/Props.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/LayoutConstraints.h>
#include <react/utils/ContextContainer.h>
namespace facebook::react {
class AndroidProgressBarMeasurementsManager {
public:
AndroidProgressBarMeasurementsManager(const std::shared_ptr<const ContextContainer> &contextContainer)
: contextContainer_(contextContainer)
{
}
Size measure(SurfaceId surfaceId, const AndroidProgressBarProps &props, LayoutConstraints layoutConstraints) const;
private:
const std::shared_ptr<const ContextContainer> contextContainer_;
};
} // namespace facebook::react

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "AndroidProgressBarShadowNode.h"
#include <react/renderer/components/progressbar/AndroidProgressBarShadowNode.h>
#include <react/renderer/core/LayoutContext.h>
namespace facebook::react {
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
extern const char AndroidProgressBarComponentName[] = "AndroidProgressBar";
void AndroidProgressBarShadowNode::setAndroidProgressBarMeasurementsManager(
const std::shared_ptr<AndroidProgressBarMeasurementsManager>&
measurementsManager) {
ensureUnsealed();
measurementsManager_ = measurementsManager;
}
#pragma mark - LayoutableShadowNode
Size AndroidProgressBarShadowNode::measureContent(
const LayoutContext& /*layoutContext*/,
const LayoutConstraints& layoutConstraints) const {
return measurementsManager_->measure(
getSurfaceId(), getConcreteProps(), layoutConstraints);
}
} // namespace facebook::react

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <react/renderer/components/FBReactNativeSpec/EventEmitters.h>
#include <react/renderer/components/FBReactNativeSpec/Props.h>
#include <react/renderer/components/progressbar/AndroidProgressBarMeasurementsManager.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
namespace facebook::react {
extern const char AndroidProgressBarComponentName[];
/*
* `ShadowNode` for <AndroidProgressBar> component.
*/
class AndroidProgressBarShadowNode final : public ConcreteViewShadowNode<
AndroidProgressBarComponentName,
AndroidProgressBarProps,
AndroidProgressBarEventEmitter> {
public:
using ConcreteViewShadowNode::ConcreteViewShadowNode;
static ShadowNodeTraits BaseTraits()
{
auto traits = ConcreteViewShadowNode::BaseTraits();
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode);
return traits;
}
// Associates a shared `AndroidProgressBarMeasurementsManager` with the node.
void setAndroidProgressBarMeasurementsManager(
const std::shared_ptr<AndroidProgressBarMeasurementsManager> &measurementsManager);
#pragma mark - LayoutableShadowNode
Size measureContent(const LayoutContext &layoutContext, const LayoutConstraints &layoutConstraints) const override;
private:
std::shared_ptr<AndroidProgressBarMeasurementsManager> measurementsManager_;
};
} // namespace facebook::react

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <folly/dynamic.h>
#include <react/renderer/components/FBReactNativeSpec/Props.h>
#include <react/renderer/core/propsConversions.h>
namespace facebook::react {
#ifdef RN_SERIALIZABLE_STATE
inline folly::dynamic toDynamic(const AndroidProgressBarProps &props)
{
folly::dynamic serializedProps = folly::dynamic::object();
serializedProps["styleAttr"] = props.styleAttr;
serializedProps["typeAttr"] = props.typeAttr;
serializedProps["indeterminate"] = props.indeterminate;
serializedProps["progress"] = props.progress;
serializedProps["animating"] = props.animating;
serializedProps["color"] = toAndroidRepr(props.color);
serializedProps["testID"] = props.testID;
return serializedProps;
}
#endif
} // namespace facebook::react