react-native-nitro-list 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NitroList.podspec +31 -0
- package/README.md +29 -0
- package/android/CMakeLists.txt +32 -0
- package/android/build.gradle +148 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/nitrolist/HybridNitroList.kt +27 -0
- package/android/src/main/java/com/nitrolist/NitroListPackage.kt +29 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridNitroList.swift +21 -0
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/nitro-list.nitro.js +6 -0
- package/lib/commonjs/specs/nitro-list.nitro.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/nitro-list.nitro.js +4 -0
- package/lib/module/specs/nitro-list.nitro.js.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-list.nitro.d.ts +11 -0
- package/lib/typescript/src/specs/nitro-list.nitro.d.ts.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroList+autolinking.cmake +83 -0
- package/nitrogen/generated/android/NitroList+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroListOnLoad.cpp +46 -0
- package/nitrogen/generated/android/NitroListOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JHybridNitroListSpec.cpp +56 -0
- package/nitrogen/generated/android/c++/JHybridNitroListSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroListStateUpdater.cpp +56 -0
- package/nitrogen/generated/android/c++/views/JHybridNitroListStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/HybridNitroListSpec.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/NitroListOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/views/HybridNitroListManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrolist/views/HybridNitroListStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroList+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp +40 -0
- package/nitrogen/generated/ios/NitroList-Swift-Cxx-Umbrella.hpp +41 -0
- package/nitrogen/generated/ios/NitroListAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroListAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridNitroListSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroListSpecSwift.hpp +74 -0
- package/nitrogen/generated/ios/c++/views/HybridNitroListComponent.mm +96 -0
- package/nitrogen/generated/ios/swift/HybridNitroListSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroListSpec_cxx.swift +140 -0
- package/nitrogen/generated/shared/c++/HybridNitroListSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroListSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroListComponent.cpp +88 -0
- package/nitrogen/generated/shared/c++/views/HybridNitroListComponent.hpp +107 -0
- package/nitrogen/generated/shared/json/NitroListConfig.json +10 -0
- package/package.json +122 -0
- package/src/index.ts +14 -0
- package/src/specs/nitro-list.nitro.ts +13 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroListOnLoad.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#ifndef BUILDING_NITROLIST_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error NitroListOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "NitroListOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridNitroListSpec.hpp"
|
|
19
|
+
#include "views/JHybridNitroListStateUpdater.hpp"
|
|
20
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::nitrolist {
|
|
23
|
+
|
|
24
|
+
int initialize(JavaVM* vm) {
|
|
25
|
+
using namespace margelo::nitro;
|
|
26
|
+
using namespace margelo::nitro::nitrolist;
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
|
|
29
|
+
return facebook::jni::initialize(vm, [] {
|
|
30
|
+
// Register native JNI methods
|
|
31
|
+
margelo::nitro::nitrolist::JHybridNitroListSpec::registerNatives();
|
|
32
|
+
margelo::nitro::nitrolist::views::JHybridNitroListStateUpdater::registerNatives();
|
|
33
|
+
|
|
34
|
+
// Register Nitro Hybrid Objects
|
|
35
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
36
|
+
"NitroList",
|
|
37
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
38
|
+
static DefaultConstructableObject<JHybridNitroListSpec::javaobject> object("com/nitrolist/HybridNitroList");
|
|
39
|
+
auto instance = object.create();
|
|
40
|
+
return instance->cthis()->shared();
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::nitrolist
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroListOnLoad.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include <jni.h>
|
|
9
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
10
|
+
|
|
11
|
+
namespace margelo::nitro::nitrolist {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the native (C++) part of NitroList, and autolinks all Hybrid Objects.
|
|
15
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
|
|
16
|
+
* Example:
|
|
17
|
+
* ```cpp (cpp-adapter.cpp)
|
|
18
|
+
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
+
* return margelo::nitro::nitrolist::initialize(vm);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
int initialize(JavaVM* vm);
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::nitrolist
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNitroListSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridNitroListSpec.hpp"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
namespace margelo::nitro::nitrolist {
|
|
15
|
+
|
|
16
|
+
jni::local_ref<JHybridNitroListSpec::jhybriddata> JHybridNitroListSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
17
|
+
return makeCxxInstance(jThis);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void JHybridNitroListSpec::registerNatives() {
|
|
21
|
+
registerHybrid({
|
|
22
|
+
makeNativeMethod("initHybrid", JHybridNitroListSpec::initHybrid),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
size_t JHybridNitroListSpec::getExternalMemorySize() noexcept {
|
|
27
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
28
|
+
return method(_javaPart);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
void JHybridNitroListSpec::dispose() noexcept {
|
|
32
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
33
|
+
method(_javaPart);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
std::string JHybridNitroListSpec::toString() {
|
|
37
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
38
|
+
auto javaString = method(_javaPart);
|
|
39
|
+
return javaString->toStdString();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Properties
|
|
43
|
+
bool JHybridNitroListSpec::getIsRed() {
|
|
44
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("isRed");
|
|
45
|
+
auto __result = method(_javaPart);
|
|
46
|
+
return static_cast<bool>(__result);
|
|
47
|
+
}
|
|
48
|
+
void JHybridNitroListSpec::setIsRed(bool isRed) {
|
|
49
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* isRed */)>("setRed");
|
|
50
|
+
method(_javaPart, isRed);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Methods
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::nitrolist
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroListSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridNitroListSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitrolist {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridNitroListSpec: public jni::HybridClass<JHybridNitroListSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridNitroListSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrolist/HybridNitroListSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridNitroListSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridNitroListSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridNitroListSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
void dispose() noexcept override;
|
|
44
|
+
std::string toString() override;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridNitroListSpec::javaobject>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
bool getIsRed() override;
|
|
54
|
+
void setIsRed(bool isRed) override;
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Methods
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
private:
|
|
61
|
+
friend HybridBase;
|
|
62
|
+
using HybridBase::HybridBase;
|
|
63
|
+
jni::global_ref<JHybridNitroListSpec::javaobject> _javaPart;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
} // namespace margelo::nitro::nitrolist
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNitroListStateUpdater.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridNitroListStateUpdater.hpp"
|
|
9
|
+
#include "views/HybridNitroListComponent.hpp"
|
|
10
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
11
|
+
|
|
12
|
+
namespace margelo::nitro::nitrolist::views {
|
|
13
|
+
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
using ConcreteStateData = react::ConcreteState<HybridNitroListState>;
|
|
16
|
+
|
|
17
|
+
void JHybridNitroListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
18
|
+
jni::alias_ref<JHybridNitroListSpec::javaobject> javaView,
|
|
19
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface) {
|
|
20
|
+
JHybridNitroListSpec* view = javaView->cthis();
|
|
21
|
+
|
|
22
|
+
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
23
|
+
jobject rawStateWrapper = stateWrapperInterface.get();
|
|
24
|
+
if (!stateWrapperInterface->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) {
|
|
25
|
+
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
26
|
+
}
|
|
27
|
+
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
28
|
+
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
29
|
+
|
|
30
|
+
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
|
+
auto concreteState = std::dynamic_pointer_cast<const ConcreteStateData>(state);
|
|
32
|
+
const HybridNitroListState& data = concreteState->getData();
|
|
33
|
+
const std::optional<HybridNitroListProps>& maybeProps = data.getProps();
|
|
34
|
+
if (!maybeProps.has_value()) {
|
|
35
|
+
// Props aren't set yet!
|
|
36
|
+
throw std::runtime_error("HybridNitroListState's data doesn't contain any props!");
|
|
37
|
+
}
|
|
38
|
+
const HybridNitroListProps& props = maybeProps.value();
|
|
39
|
+
if (props.isRed.isDirty) {
|
|
40
|
+
view->setIsRed(props.isRed.value);
|
|
41
|
+
// TODO: Set isDirty = false
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Update hybridRef if it changed
|
|
45
|
+
if (props.hybridRef.isDirty) {
|
|
46
|
+
// hybridRef changed - call it with new this
|
|
47
|
+
const auto& maybeFunc = props.hybridRef.value;
|
|
48
|
+
if (maybeFunc.has_value()) {
|
|
49
|
+
std::shared_ptr<JHybridNitroListSpec> shared = javaView->cthis()->shared_cast<JHybridNitroListSpec>();
|
|
50
|
+
maybeFunc.value()(shared);
|
|
51
|
+
}
|
|
52
|
+
// TODO: Set isDirty = false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::nitrolist::views
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNitroListStateUpdater.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#ifndef RN_SERIALIZABLE_STATE
|
|
11
|
+
#error NitroList was compiled without the 'RN_SERIALIZABLE_STATE' flag. This flag is required for Nitro Views - set it in your CMakeLists!
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#include <fbjni/fbjni.h>
|
|
15
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
16
|
+
#include <react/fabric/CoreComponentsRegistry.h>
|
|
17
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
18
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
19
|
+
#include <NitroModules/JStateWrapper.hpp>
|
|
20
|
+
#include "JHybridNitroListSpec.hpp"
|
|
21
|
+
#include "views/HybridNitroListComponent.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::nitrolist::views {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
class JHybridNitroListStateUpdater: public jni::JavaClass<JHybridNitroListStateUpdater> {
|
|
28
|
+
public:
|
|
29
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrolist/views/HybridNitroListStateUpdater;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
|
+
jni::alias_ref<JHybridNitroListSpec::javaobject> view,
|
|
34
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapperInterface);
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
static void registerNatives() {
|
|
38
|
+
// Register JNI calls
|
|
39
|
+
javaClassStatic()->registerNatives({
|
|
40
|
+
makeNativeMethod("updateViewProps", JHybridNitroListStateUpdater::updateViewProps),
|
|
41
|
+
});
|
|
42
|
+
// Register React Native view component descriptor
|
|
43
|
+
auto provider = react::concreteComponentDescriptorProvider<HybridNitroListComponentDescriptor>();
|
|
44
|
+
auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry();
|
|
45
|
+
providerRegistry->add(provider);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
} // namespace margelo::nitro::nitrolist::views
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroListSpec.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrolist
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.views.HybridView
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Kotlin class representing the NitroList HybridObject.
|
|
17
|
+
* Implement this abstract class to create Kotlin-based instances of NitroList.
|
|
18
|
+
*/
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
@Keep
|
|
21
|
+
@Suppress(
|
|
22
|
+
"KotlinJniMissingFunction", "unused",
|
|
23
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
24
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
|
+
)
|
|
26
|
+
abstract class HybridNitroListSpec: HybridView() {
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
private var mHybridData: HybridData = initHybrid()
|
|
29
|
+
|
|
30
|
+
init {
|
|
31
|
+
super.updateNative(mHybridData)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun updateNative(hybridData: HybridData) {
|
|
35
|
+
mHybridData = hybridData
|
|
36
|
+
super.updateNative(hybridData)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Default implementation of `HybridObject.toString()`
|
|
40
|
+
override fun toString(): String {
|
|
41
|
+
return "[HybridObject NitroList]"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Properties
|
|
45
|
+
@get:DoNotStrip
|
|
46
|
+
@get:Keep
|
|
47
|
+
@set:DoNotStrip
|
|
48
|
+
@set:Keep
|
|
49
|
+
abstract var isRed: Boolean
|
|
50
|
+
|
|
51
|
+
// Methods
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
private external fun initHybrid(): HybridData
|
|
55
|
+
|
|
56
|
+
companion object {
|
|
57
|
+
protected const val TAG = "HybridNitroListSpec"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroListOnLoad.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrolist
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class NitroListOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "NitroListOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "NitroList".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading NitroList C++ library...")
|
|
25
|
+
System.loadLibrary("NitroList")
|
|
26
|
+
Log.i(TAG, "Successfully loaded NitroList C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load NitroList C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroListManager.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrolist.views
|
|
9
|
+
|
|
10
|
+
import android.view.View
|
|
11
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
12
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
13
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
14
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
|
+
import com.nitrolist.*
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents the React Native `ViewManager` for the "NitroList" Nitro HybridView.
|
|
19
|
+
*/
|
|
20
|
+
open class HybridNitroListManager: SimpleViewManager<View>() {
|
|
21
|
+
private val views = hashMapOf<View, HybridNitroList>()
|
|
22
|
+
|
|
23
|
+
override fun getName(): String {
|
|
24
|
+
return "NitroList"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
28
|
+
val hybridView = HybridNitroList(reactContext)
|
|
29
|
+
val view = hybridView.view
|
|
30
|
+
views[view] = hybridView
|
|
31
|
+
return view
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun onDropViewInstance(view: View) {
|
|
35
|
+
super.onDropViewInstance(view)
|
|
36
|
+
views.remove(view)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
40
|
+
val hybridView = views[view] ?: throw Error("Couldn't find view $view in local views table!")
|
|
41
|
+
|
|
42
|
+
// 1. Update each prop individually
|
|
43
|
+
hybridView.beforeUpdate()
|
|
44
|
+
HybridNitroListStateUpdater.updateViewProps(hybridView, stateWrapper)
|
|
45
|
+
hybridView.afterUpdate()
|
|
46
|
+
|
|
47
|
+
// 2. Continue in base View props
|
|
48
|
+
return super.updateState(view, props, stateWrapper)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroListStateUpdater.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitrolist.views
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
11
|
+
import com.margelo.nitro.nitrolist.*
|
|
12
|
+
|
|
13
|
+
internal class HybridNitroListStateUpdater {
|
|
14
|
+
companion object {
|
|
15
|
+
/**
|
|
16
|
+
* Updates the props for [view] through C++.
|
|
17
|
+
* The [state] prop is expected to contain [view]'s props as wrapped Fabric state.
|
|
18
|
+
*/
|
|
19
|
+
@Suppress("KotlinJniMissingFunction")
|
|
20
|
+
@JvmStatic
|
|
21
|
+
external fun updateViewProps(view: HybridNitroListSpec, state: StateWrapper)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NitroList+autolinking.rb
|
|
3
|
+
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
# https://github.com/mrousavy/nitro
|
|
5
|
+
# Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/NitroList+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 NitroList is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/NitroList-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
})
|
|
60
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroList-Swift-Cxx-Bridge.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "NitroList-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridNitroListSpecSwift.hpp"
|
|
12
|
+
#include "NitroList-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitrolist::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::shared_ptr<HybridNitroListSpec>
|
|
18
|
+
std::shared_ptr<HybridNitroListSpec> create_std__shared_ptr_HybridNitroListSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
19
|
+
NitroList::HybridNitroListSpec_cxx swiftPart = NitroList::HybridNitroListSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
20
|
+
return std::make_shared<margelo::nitro::nitrolist::HybridNitroListSpecSwift>(swiftPart);
|
|
21
|
+
}
|
|
22
|
+
void* NON_NULL get_std__shared_ptr_HybridNitroListSpec_(std__shared_ptr_HybridNitroListSpec_ cppType) {
|
|
23
|
+
std::shared_ptr<margelo::nitro::nitrolist::HybridNitroListSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrolist::HybridNitroListSpecSwift>(cppType);
|
|
24
|
+
#ifdef NITRO_DEBUG
|
|
25
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("Class \"HybridNitroListSpec\" is not implemented in Swift!");
|
|
27
|
+
}
|
|
28
|
+
#endif
|
|
29
|
+
NitroList::HybridNitroListSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
30
|
+
return swiftPart.toUnsafe();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} // namespace margelo::nitro::nitrolist::bridge::swift
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroList-Swift-Cxx-Bridge.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridNitroListSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::nitrolist { class HybridNitroListSpec; }
|
|
13
|
+
|
|
14
|
+
// Forward declarations of Swift defined types
|
|
15
|
+
// Forward declaration of `HybridNitroListSpec_cxx` to properly resolve imports.
|
|
16
|
+
namespace NitroList { class HybridNitroListSpec_cxx; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridNitroListSpec.hpp"
|
|
20
|
+
#include <memory>
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
24
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
25
|
+
*/
|
|
26
|
+
namespace margelo::nitro::nitrolist::bridge::swift {
|
|
27
|
+
|
|
28
|
+
// pragma MARK: std::shared_ptr<HybridNitroListSpec>
|
|
29
|
+
/**
|
|
30
|
+
* Specialized version of `std::shared_ptr<HybridNitroListSpec>`.
|
|
31
|
+
*/
|
|
32
|
+
using std__shared_ptr_HybridNitroListSpec_ = std::shared_ptr<HybridNitroListSpec>;
|
|
33
|
+
std::shared_ptr<HybridNitroListSpec> create_std__shared_ptr_HybridNitroListSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
34
|
+
void* NON_NULL get_std__shared_ptr_HybridNitroListSpec_(std__shared_ptr_HybridNitroListSpec_ cppType);
|
|
35
|
+
|
|
36
|
+
// pragma MARK: std::weak_ptr<HybridNitroListSpec>
|
|
37
|
+
using std__weak_ptr_HybridNitroListSpec_ = std::weak_ptr<HybridNitroListSpec>;
|
|
38
|
+
inline std__weak_ptr_HybridNitroListSpec_ weakify_std__shared_ptr_HybridNitroListSpec_(const std::shared_ptr<HybridNitroListSpec>& strong) noexcept { return strong; }
|
|
39
|
+
|
|
40
|
+
} // namespace margelo::nitro::nitrolist::bridge::swift
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroList-Swift-Cxx-Umbrella.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridNitroListSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::nitrolist { class HybridNitroListSpec; }
|
|
13
|
+
|
|
14
|
+
// Include C++ defined types
|
|
15
|
+
#include "HybridNitroListSpec.hpp"
|
|
16
|
+
#include <memory>
|
|
17
|
+
|
|
18
|
+
// C++ helpers for Swift
|
|
19
|
+
#include "NitroList-Swift-Cxx-Bridge.hpp"
|
|
20
|
+
|
|
21
|
+
// Common C++ types used in Swift
|
|
22
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
23
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
24
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
25
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
26
|
+
|
|
27
|
+
// Forward declarations of Swift defined types
|
|
28
|
+
// Forward declaration of `HybridNitroListSpec_cxx` to properly resolve imports.
|
|
29
|
+
namespace NitroList { class HybridNitroListSpec_cxx; }
|
|
30
|
+
|
|
31
|
+
// Include Swift defined types
|
|
32
|
+
#if __has_include("NitroList-Swift.h")
|
|
33
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
34
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroList".
|
|
35
|
+
#include "NitroList-Swift.h"
|
|
36
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
37
|
+
#elif __has_include(<NitroList/NitroList-Swift.h>)
|
|
38
|
+
#include <NitroList/NitroList-Swift.h>
|
|
39
|
+
#else
|
|
40
|
+
#error NitroList's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroList", and try building the app first.
|
|
41
|
+
#endif
|