From f07f197dc13b10d2ad2af8a773feb15b004f2a51 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Wed, 15 Jan 2025 17:28:11 +0100 Subject: [PATCH] feat: More docs --- .../nitrogen/src/views/ViewComponentShadowNode.ts | 15 ++++++++++++++- .../shared/c++/views/TestViewComponent.cpp | 6 ++++++ .../shared/c++/views/TestViewComponent.hpp | 9 ++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/nitrogen/src/views/ViewComponentShadowNode.ts b/packages/nitrogen/src/views/ViewComponentShadowNode.ts index 398dc2876..5fe076fc0 100644 --- a/packages/nitrogen/src/views/ViewComponentShadowNode.ts +++ b/packages/nitrogen/src/views/ViewComponentShadowNode.ts @@ -105,14 +105,21 @@ namespace ${namespace} { public: explicit ${stateClassName}() = default; }; + + /** + * The Shadow Node for the "${spec.name}" View. + */ using ${shadowNodeClassName} = react::ConcreteViewShadowNode<${nameVariable}, ${propsClassName}, react::ViewEventEmitter, ${stateClassName}>; /** - * The Shadow Node descriptor for the "${spec.name}" View. + * The Component Descriptor for the "${spec.name}" View. */ class ${descriptorClassName}: public react::ConcreteComponentDescriptor<${shadowNodeClassName}> { public: ${descriptorClassName}(const react::ComponentDescriptorParameters& parameters); + + public: + void adopt(react::ShadowNode& shadowNode) const override; }; /* The actual view for "${spec.name}" needs to be implemented in platform-specific code. */ @@ -158,6 +165,12 @@ namespace ${namespace} { : ConcreteComponentDescriptor(parameters, std::make_unique(/* enableJsiParser */ true)) {} + void ${descriptorClassName}::adopt(react::ShadowNode& shadowNode) const { + // This is called immediately after \`ShadowNode\` is created, cloned or in progress. + auto& concreteShadowNode = static_cast<${shadowNodeClassName}&>(shadowNode); + const ${propsClassName}& props = concreteShadowNode.getConcreteProps(); + } + } // namespace ${namespace} #endif diff --git a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.cpp b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.cpp index 96d78a248..46a5fc12e 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.cpp +++ b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.cpp @@ -35,6 +35,12 @@ namespace margelo::nitro::image::views { : ConcreteComponentDescriptor(parameters, std::make_unique(/* enableJsiParser */ true)) {} + void HybridTestViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const { + // This is called immediately after `ShadowNode` is created, cloned or in progress. + auto& concreteShadowNode = static_cast(shadowNode); + const HybridTestViewProps& props = concreteShadowNode.getConcreteProps(); + } + } // namespace margelo::nitro::image::views #endif diff --git a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.hpp b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.hpp index e084b98b5..670835768 100644 --- a/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.hpp +++ b/packages/react-native-nitro-image/nitrogen/generated/shared/c++/views/TestViewComponent.hpp @@ -51,14 +51,21 @@ namespace margelo::nitro::image::views { public: explicit HybridTestViewState() = default; }; + + /** + * The Shadow Node for the "TestView" View. + */ using HybridTestViewShadowNode = react::ConcreteViewShadowNode; /** - * The Shadow Node descriptor for the "TestView" View. + * The Component Descriptor for the "TestView" View. */ class HybridTestViewComponentDescriptor: public react::ConcreteComponentDescriptor { public: HybridTestViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters); + + public: + void adopt(react::ShadowNode& shadowNode) const override; }; /* The actual view for "TestView" needs to be implemented in platform-specific code. */