Init using create-nitro-module

This commit is contained in:
2026-04-06 12:53:56 +02:00
commit b5a15a41e9
97 changed files with 6648 additions and 0 deletions
@@ -0,0 +1,56 @@
///
/// JHybridOmniStateUpdater.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#include "JHybridOmniStateUpdater.hpp"
#include "views/HybridOmniComponent.hpp"
#include <NitroModules/NitroDefines.hpp>
#include <react/fabric/StateWrapperImpl.h>
namespace margelo::nitro::omni::views {
using namespace facebook;
using ConcreteStateData = react::ConcreteState<HybridOmniState>;
void JHybridOmniStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
jni::alias_ref<JHybridOmniSpec::JavaPart> javaView,
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
std::shared_ptr<JHybridOmniSpec> hybridView = javaView->getJHybridOmniSpec();
// Get concrete StateWrapperImpl from passed StateWrapper interface object
jobject rawStateWrapper = stateWrapperInterface.get();
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
}
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
const HybridOmniState& data = concreteState->getData();
const std::shared_ptr<HybridOmniProps>& props = data.getProps();
if (props == nullptr) [[unlikely]] {
// Props aren't set yet!
throw std::runtime_error("HybridOmniState's data doesn't contain any props!");
}
// Update all props if they are dirty
if (props->isRed.isDirty) {
hybridView->setIsRed(props->isRed.value);
props->isRed.isDirty = false;
}
// Update hybridRef if it changed
if (props->hybridRef.isDirty) {
// hybridRef changed - call it with new this
const auto& maybeFunc = props->hybridRef.value;
if (maybeFunc.has_value()) {
maybeFunc.value()(hybridView);
}
props->hybridRef.isDirty = false;
}
}
} // namespace margelo::nitro::omni::views
@@ -0,0 +1,49 @@
///
/// JHybridOmniStateUpdater.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#pragma once
#ifndef RN_SERIALIZABLE_STATE
#error Omni was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists!
#endif
#include <fbjni/fbjni.h>
#include <react/fabric/CoreComponentsRegistry.h>
#include <react/fabric/StateWrapperImpl.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/JStateWrapper.hpp>
#include "JHybridOmniSpec.hpp"
#include "views/HybridOmniComponent.hpp"
namespace margelo::nitro::omni::views {
using namespace facebook;
class JHybridOmniStateUpdater final: public jni::JavaClass<JHybridOmniStateUpdater> {
public:
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/views/HybridOmniStateUpdater;";
public:
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
jni::alias_ref<JHybridOmniSpec::JavaPart> view,
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
public:
static void registerNatives() {
// Register JNI calls
javaClassStatic()->registerNatives({
makeNativeMethod("updateViewProps", JHybridOmniStateUpdater::updateViewProps),
});
// Register React Native view component descriptor
auto provider = react::concreteComponentDescriptorProvider<HybridOmniComponentDescriptor>();
auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry();
providerRegistry->add(provider);
}
};
} // namespace margelo::nitro::omni::views