-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Generate Kotlin/JNI code for this
- Loading branch information
Showing
9 changed files
with
270 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...t-native-nitro-image/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/// | ||
/// JHybridTestViewStateUpdater.cpp | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2025 Marc Rousavy @ Margelo | ||
/// | ||
|
||
#if REACT_NATIVE_VERSION >= 78 | ||
|
||
#include "JHybridTestViewStateUpdater.hpp" | ||
#include "views/HybridTestViewComponent.hpp" | ||
|
||
namespace margelo::nitro::image::views { | ||
|
||
using namespace facebook; | ||
using ConcreteStateData = react::ConcreteState<HybridTestViewState>; | ||
|
||
void JHybridTestViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass>, | ||
jni::alias_ref<JHybridTestViewSpec::javaobject> javaView, | ||
jni::alias_ref<react::StateWrapperImpl::javaobject> stateWrapper) { | ||
JHybridTestViewSpec* view = javaView->cthis(); | ||
const react::State& state = stateWrapper->cthis(); | ||
// TODO: Can this be a static_cast? | ||
const auto& concreteState = dynamic_cast<const ConcreteStateData&>(state); | ||
const HybridTestViewState& data = concreteState.getData(); | ||
const std::optional<HybridTestViewProps>& maybeProps = data.getProps(); | ||
if (!maybeProps.has_value()) { | ||
// Props aren't set yet! | ||
throw std::runtime_error("HybridTestViewState's data doesn't contain any props!"); | ||
} | ||
const HybridTestViewProps& props = maybeProps.value(); | ||
if (props.someProp.isDirty) { | ||
view->setSomeProp(props.someProp.value); | ||
} | ||
if (props.someCallback.isDirty) { | ||
view->setSomeCallback(props.someCallback.value); | ||
} | ||
} | ||
|
||
} // namespace margelo::nitro::image::views | ||
|
||
#endif |
39 changes: 39 additions & 0 deletions
39
...t-native-nitro-image/nitrogen/generated/android/c++/views/JHybridTestViewStateUpdater.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/// | ||
/// JHybridTestViewStateUpdater.hpp | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2025 Marc Rousavy @ Margelo | ||
/// | ||
|
||
#pragma once | ||
|
||
#if REACT_NATIVE_VERSION >= 78 | ||
|
||
#include <fbjni/fbjni.h> | ||
#include <react/fabric/StateWrapperImpl.h> | ||
#include "JHybridTestViewSpec.hpp" | ||
|
||
namespace margelo::nitro::image::views { | ||
|
||
using namespace facebook; | ||
|
||
class JHybridTestViewStateUpdater: jni::HybridClass<JHybridTestViewStateUpdater> { | ||
public: | ||
static constexpr auto kJavaDescriptor = "Lcom.margelo.nitro.image.views.HybridTestViewStateUpdater;"; | ||
|
||
public: | ||
static void updateViewProps(jni::alias_ref<jni::JClass>, | ||
jni::alias_ref<JHybridTestViewSpec::javaobject> view, | ||
jni::alias_ref<react::StateWrapperImpl::javaobject> stateWrapper); | ||
|
||
public: | ||
static void registerNatives() { | ||
registerHybrid({ | ||
makeNativeMethod("updateViewProps", JHybridTestViewStateUpdater::updateViewProps), | ||
}); | ||
} | ||
}; | ||
|
||
} // namespace margelo::nitro::image::views | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ogen/generated/android/kotlin/com/margelo/nitro/image/views/HybridTestViewStateUpdater.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/// | ||
/// HybridTestViewStateUpdater.kt | ||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. | ||
/// https://github.com/mrousavy/nitro | ||
/// Copyright © 2025 Marc Rousavy @ Margelo | ||
/// | ||
|
||
package com.margelo.nitro.image.views | ||
|
||
import com.facebook.react.fabric.StateWrapperImpl | ||
import com.margelo.nitro.image.* | ||
|
||
class HybridTestViewStateUpdater { | ||
companion object { | ||
/** | ||
* Updates the props for [view] through C++. | ||
* The [state] prop is expected to contain [view]'s props as wrapped Fabric state. | ||
*/ | ||
@Suppress("KotlinJniMissingFunction") | ||
@JvmStatic | ||
external fun updateViewProps(view: HybridTestView, state: StateWrapperImpl) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters