@onekeyfe/react-native-native-list 3.0.105
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/README.md +342 -0
- package/android/CMakeLists.txt +20 -0
- package/android/build.gradle +105 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +125 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +165 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +147 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListPackage.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRowView.kt +2939 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1794 -0
- package/common/fonts/Roobert-Bold.ttf +0 -0
- package/common/fonts/Roobert-Medium.ttf +0 -0
- package/common/fonts/Roobert-Regular.ttf +0 -0
- package/common/fonts/Roobert-SemiBold.ttf +0 -0
- package/docs/DESIGN.md +129 -0
- package/ios/HybridNativeList.swift +131 -0
- package/ios/NativeListCell.swift +2858 -0
- package/ios/NativeListDesignAssets.swift +110 -0
- package/ios/NativeListModels.swift +215 -0
- package/ios/RNCNativeListView.swift +1737 -0
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +1 -0
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +1 -0
- package/lib/module/NativeList.js +183 -0
- package/lib/module/NativeList.nitro.js +4 -0
- package/lib/module/NativeList.types.js +4 -0
- package/lib/module/NativeList.web.js +167 -0
- package/lib/module/index.js +6 -0
- package/lib/module/models.js +2 -0
- package/lib/module/package.json +1 -0
- package/lib/module/scrolling.js +121 -0
- package/lib/module/selection.js +85 -0
- package/lib/module/validation.js +562 -0
- package/lib/module/web/NativeListWebEngine.js +2238 -0
- package/lib/nitrogen/generated/.gitattributes +1 -0
- package/lib/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +201 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +84 -0
- package/lib/nitrogen/generated/android/c++/JNativeListScrollAlignment.hpp +64 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +104 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.hpp +54 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_std__string.kt +78 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +177 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollAlignment.kt +25 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/nativelistOnLoad.kt +35 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +96 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListStateUpdater.kt +23 -0
- package/lib/nitrogen/generated/android/nativelist+autolinking.cmake +83 -0
- package/lib/nitrogen/generated/android/nativelist+autolinking.gradle +27 -0
- package/lib/nitrogen/generated/android/nativelistOnLoad.cpp +58 -0
- package/lib/nitrogen/generated/android/nativelistOnLoad.hpp +34 -0
- package/lib/nitrogen/generated/ios/NativeListModule+autolinking.rb +62 -0
- package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +41 -0
- package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +91 -0
- package/lib/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +49 -0
- package/lib/nitrogen/generated/ios/NativeListModuleAutolinking.mm +33 -0
- package/lib/nitrogen/generated/ios/NativeListModuleAutolinking.swift +26 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +180 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +180 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +69 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +447 -0
- package/lib/nitrogen/generated/ios/swift/NativeListScrollAlignment.swift +48 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +87 -0
- package/lib/nitrogen/generated/shared/c++/NativeListScrollAlignment.hpp +84 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +46 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +103 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +16 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeList.d.ts +18 -0
- package/lib/typescript/src/NativeList.nitro.d.ts +29 -0
- package/lib/typescript/src/NativeList.types.d.ts +87 -0
- package/lib/typescript/src/NativeList.web.d.ts +19 -0
- package/lib/typescript/src/index.d.ts +7 -0
- package/lib/typescript/src/models.d.ts +456 -0
- package/lib/typescript/src/scrolling.d.ts +32 -0
- package/lib/typescript/src/selection.d.ts +27 -0
- package/lib/typescript/src/validation.d.ts +7 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +203 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +201 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +84 -0
- package/nitrogen/generated/android/c++/JNativeListScrollAlignment.hpp +64 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +104 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_std__string.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +177 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/NativeListScrollAlignment.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/nativelistOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/views/HybridNativeListStateUpdater.kt +23 -0
- package/nitrogen/generated/android/nativelist+autolinking.cmake +83 -0
- package/nitrogen/generated/android/nativelist+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nativelistOnLoad.cpp +58 -0
- package/nitrogen/generated/android/nativelistOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/NativeListModule+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.cpp +41 -0
- package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Bridge.hpp +91 -0
- package/nitrogen/generated/ios/NativeListModule-Swift-Cxx-Umbrella.hpp +49 -0
- package/nitrogen/generated/ios/NativeListModuleAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NativeListModuleAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +180 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +180 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +69 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +447 -0
- package/nitrogen/generated/ios/swift/NativeListScrollAlignment.swift +48 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +87 -0
- package/nitrogen/generated/shared/c++/NativeListScrollAlignment.hpp +84 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +46 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +103 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +16 -0
- package/package.json +126 -0
- package/react-native-native-list.podspec +38 -0
- package/react-native.config.js +19 -0
- package/src/NativeList.nitro.ts +48 -0
- package/src/NativeList.tsx +298 -0
- package/src/NativeList.types.ts +125 -0
- package/src/NativeList.web.tsx +258 -0
- package/src/index.ts +35 -0
- package/src/models.ts +604 -0
- package/src/scrolling.ts +189 -0
- package/src/selection.ts +159 -0
- package/src/validation.ts +877 -0
- package/src/web/NativeListWebEngine.ts +3767 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
** linguist-generated=true
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_std__string.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <NitroModules/JNICallable.hpp>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nativelist {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents the Java/Kotlin callback `(payloadJson: String) -> Unit`.
|
|
23
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
24
|
+
*/
|
|
25
|
+
struct JFunc_void_std__string: public jni::JavaClass<JFunc_void_std__string> {
|
|
26
|
+
public:
|
|
27
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/Func_void_std__string;";
|
|
28
|
+
|
|
29
|
+
public:
|
|
30
|
+
/**
|
|
31
|
+
* Invokes the function this `JFunc_void_std__string` instance holds through JNI.
|
|
32
|
+
*/
|
|
33
|
+
void invoke(const std::string& payloadJson) const {
|
|
34
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* payloadJson */)>("invoke");
|
|
35
|
+
method(self(), jni::make_jstring(payloadJson));
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* An implementation of Func_void_std__string that is backed by a C++ implementation (using `std::function<...>`)
|
|
41
|
+
*/
|
|
42
|
+
class JFunc_void_std__string_cxx final: public jni::HybridClass<JFunc_void_std__string_cxx, JFunc_void_std__string> {
|
|
43
|
+
public:
|
|
44
|
+
static jni::local_ref<JFunc_void_std__string::javaobject> fromCpp(const std::function<void(const std::string& /* payloadJson */)>& func) {
|
|
45
|
+
return JFunc_void_std__string_cxx::newObjectCxxArgs(func);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
/**
|
|
50
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_std__string_cxx` instance holds.
|
|
51
|
+
*/
|
|
52
|
+
void invoke_cxx(jni::alias_ref<jni::JString> payloadJson) {
|
|
53
|
+
_func(payloadJson->toStdString());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
[[nodiscard]]
|
|
58
|
+
inline const std::function<void(const std::string& /* payloadJson */)>& getFunction() const {
|
|
59
|
+
return _func;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/Func_void_std__string_cxx;";
|
|
64
|
+
static void registerNatives() {
|
|
65
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__string_cxx::invoke_cxx)});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private:
|
|
69
|
+
explicit JFunc_void_std__string_cxx(const std::function<void(const std::string& /* payloadJson */)>& func): _func(func) { }
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
friend HybridBase;
|
|
73
|
+
std::function<void(const std::string& /* payloadJson */)> _func;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro::nativelist
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNativeListSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridNativeListSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `NativeListScrollAlignment` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::nativelist { enum class NativeListScrollAlignment; }
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <functional>
|
|
15
|
+
#include <optional>
|
|
16
|
+
#include "JFunc_void_std__string.hpp"
|
|
17
|
+
#include <NitroModules/JNICallable.hpp>
|
|
18
|
+
#include "NativeListScrollAlignment.hpp"
|
|
19
|
+
#include "JNativeListScrollAlignment.hpp"
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::nativelist {
|
|
22
|
+
|
|
23
|
+
std::shared_ptr<JHybridNativeListSpec> JHybridNativeListSpec::JavaPart::getJHybridNativeListSpec() {
|
|
24
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
25
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridNativeListSpec>(hybridObject);
|
|
26
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
27
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridNativeListSpec!");
|
|
28
|
+
}
|
|
29
|
+
return castHybridObject;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
jni::local_ref<JHybridNativeListSpec::CxxPart::jhybriddata> JHybridNativeListSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
33
|
+
return makeCxxInstance(jThis);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
std::shared_ptr<JHybridObject> JHybridNativeListSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
37
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridNativeListSpec::JavaPart>(javaPart);
|
|
38
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
39
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridNativeListSpec::JavaPart!");
|
|
40
|
+
}
|
|
41
|
+
return std::make_shared<JHybridNativeListSpec>(castJavaPart);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void JHybridNativeListSpec::CxxPart::registerNatives() {
|
|
45
|
+
registerHybrid({
|
|
46
|
+
makeNativeMethod("initHybrid", JHybridNativeListSpec::CxxPart::initHybrid),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Properties
|
|
51
|
+
std::string JHybridNativeListSpec::getSnapshotJson() {
|
|
52
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getSnapshotJson");
|
|
53
|
+
auto __result = method(_javaPart);
|
|
54
|
+
return __result->toStdString();
|
|
55
|
+
}
|
|
56
|
+
void JHybridNativeListSpec::setSnapshotJson(const std::string& snapshotJson) {
|
|
57
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* snapshotJson */)>("setSnapshotJson");
|
|
58
|
+
method(_javaPart, jni::make_jstring(snapshotJson));
|
|
59
|
+
}
|
|
60
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnRowAction() {
|
|
61
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnRowAction_cxx");
|
|
62
|
+
auto __result = method(_javaPart);
|
|
63
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
|
|
64
|
+
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
65
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
|
|
66
|
+
return downcast->cthis()->getFunction();
|
|
67
|
+
} else {
|
|
68
|
+
auto __resultRef = jni::make_global(__result);
|
|
69
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
|
|
70
|
+
}
|
|
71
|
+
}()) : std::nullopt;
|
|
72
|
+
}
|
|
73
|
+
void JHybridNativeListSpec::setOnRowAction(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onRowAction) {
|
|
74
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onRowAction */)>("setOnRowAction_cxx");
|
|
75
|
+
method(_javaPart, onRowAction.has_value() ? JFunc_void_std__string_cxx::fromCpp(onRowAction.value()) : nullptr);
|
|
76
|
+
}
|
|
77
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnActionAnchorInvalidated() {
|
|
78
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnActionAnchorInvalidated_cxx");
|
|
79
|
+
auto __result = method(_javaPart);
|
|
80
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
|
|
81
|
+
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
82
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
|
|
83
|
+
return downcast->cthis()->getFunction();
|
|
84
|
+
} else {
|
|
85
|
+
auto __resultRef = jni::make_global(__result);
|
|
86
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
|
|
87
|
+
}
|
|
88
|
+
}()) : std::nullopt;
|
|
89
|
+
}
|
|
90
|
+
void JHybridNativeListSpec::setOnActionAnchorInvalidated(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onActionAnchorInvalidated) {
|
|
91
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onActionAnchorInvalidated */)>("setOnActionAnchorInvalidated_cxx");
|
|
92
|
+
method(_javaPart, onActionAnchorInvalidated.has_value() ? JFunc_void_std__string_cxx::fromCpp(onActionAnchorInvalidated.value()) : nullptr);
|
|
93
|
+
}
|
|
94
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnSelectionDelta() {
|
|
95
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnSelectionDelta_cxx");
|
|
96
|
+
auto __result = method(_javaPart);
|
|
97
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
|
|
98
|
+
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
99
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
|
|
100
|
+
return downcast->cthis()->getFunction();
|
|
101
|
+
} else {
|
|
102
|
+
auto __resultRef = jni::make_global(__result);
|
|
103
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
|
|
104
|
+
}
|
|
105
|
+
}()) : std::nullopt;
|
|
106
|
+
}
|
|
107
|
+
void JHybridNativeListSpec::setOnSelectionDelta(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onSelectionDelta) {
|
|
108
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onSelectionDelta */)>("setOnSelectionDelta_cxx");
|
|
109
|
+
method(_javaPart, onSelectionDelta.has_value() ? JFunc_void_std__string_cxx::fromCpp(onSelectionDelta.value()) : nullptr);
|
|
110
|
+
}
|
|
111
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnReorder() {
|
|
112
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnReorder_cxx");
|
|
113
|
+
auto __result = method(_javaPart);
|
|
114
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
|
|
115
|
+
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
116
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
|
|
117
|
+
return downcast->cthis()->getFunction();
|
|
118
|
+
} else {
|
|
119
|
+
auto __resultRef = jni::make_global(__result);
|
|
120
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
|
|
121
|
+
}
|
|
122
|
+
}()) : std::nullopt;
|
|
123
|
+
}
|
|
124
|
+
void JHybridNativeListSpec::setOnReorder(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onReorder) {
|
|
125
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onReorder */)>("setOnReorder_cxx");
|
|
126
|
+
method(_javaPart, onReorder.has_value() ? JFunc_void_std__string_cxx::fromCpp(onReorder.value()) : nullptr);
|
|
127
|
+
}
|
|
128
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnEndReached() {
|
|
129
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnEndReached_cxx");
|
|
130
|
+
auto __result = method(_javaPart);
|
|
131
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
|
|
132
|
+
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
133
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
|
|
134
|
+
return downcast->cthis()->getFunction();
|
|
135
|
+
} else {
|
|
136
|
+
auto __resultRef = jni::make_global(__result);
|
|
137
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
|
|
138
|
+
}
|
|
139
|
+
}()) : std::nullopt;
|
|
140
|
+
}
|
|
141
|
+
void JHybridNativeListSpec::setOnEndReached(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onEndReached) {
|
|
142
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onEndReached */)>("setOnEndReached_cxx");
|
|
143
|
+
method(_javaPart, onEndReached.has_value() ? JFunc_void_std__string_cxx::fromCpp(onEndReached.value()) : nullptr);
|
|
144
|
+
}
|
|
145
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> JHybridNativeListSpec::getOnVisibleRangeChanged() {
|
|
146
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void_std__string::javaobject>()>("getOnVisibleRangeChanged_cxx");
|
|
147
|
+
auto __result = method(_javaPart);
|
|
148
|
+
return __result != nullptr ? std::make_optional([&]() -> std::function<void(const std::string& /* payloadJson */)> {
|
|
149
|
+
if (__result->isInstanceOf(JFunc_void_std__string_cxx::javaClassStatic())) [[likely]] {
|
|
150
|
+
auto downcast = jni::static_ref_cast<JFunc_void_std__string_cxx::javaobject>(__result);
|
|
151
|
+
return downcast->cthis()->getFunction();
|
|
152
|
+
} else {
|
|
153
|
+
auto __resultRef = jni::make_global(__result);
|
|
154
|
+
return JNICallable<JFunc_void_std__string, void(std::string)>(std::move(__resultRef));
|
|
155
|
+
}
|
|
156
|
+
}()) : std::nullopt;
|
|
157
|
+
}
|
|
158
|
+
void JHybridNativeListSpec::setOnVisibleRangeChanged(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onVisibleRangeChanged) {
|
|
159
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_std__string::javaobject> /* onVisibleRangeChanged */)>("setOnVisibleRangeChanged_cxx");
|
|
160
|
+
method(_javaPart, onVisibleRangeChanged.has_value() ? JFunc_void_std__string_cxx::fromCpp(onVisibleRangeChanged.value()) : nullptr);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Methods
|
|
164
|
+
void JHybridNativeListSpec::applySnapshot(const std::string& snapshotJson) {
|
|
165
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* snapshotJson */)>("applySnapshot");
|
|
166
|
+
method(_javaPart, jni::make_jstring(snapshotJson));
|
|
167
|
+
}
|
|
168
|
+
void JHybridNativeListSpec::applyPatches(const std::string& patchesJson) {
|
|
169
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* patchesJson */)>("applyPatches");
|
|
170
|
+
method(_javaPart, jni::make_jstring(patchesJson));
|
|
171
|
+
}
|
|
172
|
+
void JHybridNativeListSpec::reconcileSelection(const std::string& selectedKeysJson) {
|
|
173
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* selectedKeysJson */)>("reconcileSelection");
|
|
174
|
+
method(_javaPart, jni::make_jstring(selectedKeysJson));
|
|
175
|
+
}
|
|
176
|
+
void JHybridNativeListSpec::scrollToKey(const std::string& key, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) {
|
|
177
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* key */, jboolean /* animated */, jni::alias_ref<JNativeListScrollAlignment> /* alignment */, double /* viewPosition */, double /* viewOffset */)>("scrollToKey");
|
|
178
|
+
method(_javaPart, jni::make_jstring(key), animated, JNativeListScrollAlignment::fromCpp(alignment), viewPosition, viewOffset);
|
|
179
|
+
}
|
|
180
|
+
void JHybridNativeListSpec::scrollToIndex(double index, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) {
|
|
181
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* index */, jboolean /* animated */, jni::alias_ref<JNativeListScrollAlignment> /* alignment */, double /* viewPosition */, double /* viewOffset */)>("scrollToIndex");
|
|
182
|
+
method(_javaPart, index, animated, JNativeListScrollAlignment::fromCpp(alignment), viewPosition, viewOffset);
|
|
183
|
+
}
|
|
184
|
+
void JHybridNativeListSpec::scrollToOffset(double offset, bool animated) {
|
|
185
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* offset */, jboolean /* animated */)>("scrollToOffset");
|
|
186
|
+
method(_javaPart, offset, animated);
|
|
187
|
+
}
|
|
188
|
+
void JHybridNativeListSpec::scrollToEnd(bool animated) {
|
|
189
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* animated */)>("scrollToEnd");
|
|
190
|
+
method(_javaPart, animated);
|
|
191
|
+
}
|
|
192
|
+
void JHybridNativeListSpec::setActionAnchorState(const std::string& stateJson) {
|
|
193
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* stateJson */)>("setActionAnchorState");
|
|
194
|
+
method(_javaPart, jni::make_jstring(stateJson));
|
|
195
|
+
}
|
|
196
|
+
void JHybridNativeListSpec::setRefreshing(bool refreshing) {
|
|
197
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* refreshing */)>("setRefreshing");
|
|
198
|
+
method(_javaPart, refreshing);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
} // namespace margelo::nitro::nativelist
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNativeListSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridNativeListSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nativelist {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridNativeListSpec: public virtual HybridNativeListSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/HybridNativeListSpec;";
|
|
25
|
+
std::shared_ptr<JHybridNativeListSpec> getJHybridNativeListSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/HybridNativeListSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
explicit JHybridNativeListSpec(const jni::local_ref<JHybridNativeListSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridNativeListSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridNativeListSpec() override {
|
|
42
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridNativeListSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
std::string getSnapshotJson() override;
|
|
54
|
+
void setSnapshotJson(const std::string& snapshotJson) override;
|
|
55
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnRowAction() override;
|
|
56
|
+
void setOnRowAction(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onRowAction) override;
|
|
57
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnActionAnchorInvalidated() override;
|
|
58
|
+
void setOnActionAnchorInvalidated(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onActionAnchorInvalidated) override;
|
|
59
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnSelectionDelta() override;
|
|
60
|
+
void setOnSelectionDelta(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onSelectionDelta) override;
|
|
61
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnReorder() override;
|
|
62
|
+
void setOnReorder(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onReorder) override;
|
|
63
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnEndReached() override;
|
|
64
|
+
void setOnEndReached(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onEndReached) override;
|
|
65
|
+
std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnVisibleRangeChanged() override;
|
|
66
|
+
void setOnVisibleRangeChanged(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onVisibleRangeChanged) override;
|
|
67
|
+
|
|
68
|
+
public:
|
|
69
|
+
// Methods
|
|
70
|
+
void applySnapshot(const std::string& snapshotJson) override;
|
|
71
|
+
void applyPatches(const std::string& patchesJson) override;
|
|
72
|
+
void reconcileSelection(const std::string& selectedKeysJson) override;
|
|
73
|
+
void scrollToKey(const std::string& key, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) override;
|
|
74
|
+
void scrollToIndex(double index, bool animated, NativeListScrollAlignment alignment, double viewPosition, double viewOffset) override;
|
|
75
|
+
void scrollToOffset(double offset, bool animated) override;
|
|
76
|
+
void scrollToEnd(bool animated) override;
|
|
77
|
+
void setActionAnchorState(const std::string& stateJson) override;
|
|
78
|
+
void setRefreshing(bool refreshing) override;
|
|
79
|
+
|
|
80
|
+
private:
|
|
81
|
+
jni::global_ref<JHybridNativeListSpec::JavaPart> _javaPart;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro::nativelist
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JNativeListScrollAlignment.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "NativeListScrollAlignment.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nativelist {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "NativeListScrollAlignment" and the Kotlin enum "NativeListScrollAlignment".
|
|
19
|
+
*/
|
|
20
|
+
struct JNativeListScrollAlignment final: public jni::JavaClass<JNativeListScrollAlignment> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/NativeListScrollAlignment;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum NativeListScrollAlignment.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
NativeListScrollAlignment toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<NativeListScrollAlignment>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JNativeListScrollAlignment> fromCpp(NativeListScrollAlignment value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case NativeListScrollAlignment::START:
|
|
46
|
+
static const auto fieldSTART = clazz->getStaticField<JNativeListScrollAlignment>("START");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldSTART);
|
|
48
|
+
case NativeListScrollAlignment::CENTER:
|
|
49
|
+
static const auto fieldCENTER = clazz->getStaticField<JNativeListScrollAlignment>("CENTER");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldCENTER);
|
|
51
|
+
case NativeListScrollAlignment::END:
|
|
52
|
+
static const auto fieldEND = clazz->getStaticField<JNativeListScrollAlignment>("END");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldEND);
|
|
54
|
+
case NativeListScrollAlignment::NEAREST:
|
|
55
|
+
static const auto fieldNEAREST = clazz->getStaticField<JNativeListScrollAlignment>("NEAREST");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldNEAREST);
|
|
57
|
+
default:
|
|
58
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
59
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::nativelist
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNativeListStateUpdater.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridNativeListStateUpdater.hpp"
|
|
9
|
+
#include "views/HybridNativeListComponent.hpp"
|
|
10
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
11
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nativelist::views {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
using ConcreteStateData = react::ConcreteState<HybridNativeListState>;
|
|
17
|
+
|
|
18
|
+
std::shared_ptr<const HybridNativeListProps> JHybridNativeListStateUpdater::getPropsFromStateWrapper(
|
|
19
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper) {
|
|
20
|
+
if (stateWrapper.get() == nullptr) {
|
|
21
|
+
return nullptr;
|
|
22
|
+
}
|
|
23
|
+
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
24
|
+
jobject rawStateWrapper = stateWrapper.get();
|
|
25
|
+
if (!stateWrapper->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
27
|
+
}
|
|
28
|
+
auto stateWrapperImpl = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
29
|
+
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)
|
|
30
|
+
};
|
|
31
|
+
std::shared_ptr<const react::State> state = stateWrapperImpl->cthis()->getState();
|
|
32
|
+
if (state == nullptr) {
|
|
33
|
+
return nullptr;
|
|
34
|
+
}
|
|
35
|
+
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
|
|
36
|
+
const HybridNativeListState& data = concreteState->getData();
|
|
37
|
+
const std::shared_ptr<const HybridNativeListProps>& props = data.getProps();
|
|
38
|
+
if (props == nullptr) [[unlikely]] {
|
|
39
|
+
throw std::runtime_error("HybridNativeListState's data doesn't contain any props!");
|
|
40
|
+
}
|
|
41
|
+
return props;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void JHybridNativeListStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
45
|
+
jni::alias_ref<JHybridNativeListSpec::JavaPart> javaView,
|
|
46
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
47
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState) {
|
|
48
|
+
std::shared_ptr<JHybridNativeListSpec> hybridView = javaView->getJHybridNativeListSpec();
|
|
49
|
+
std::shared_ptr<const HybridNativeListProps> newProps = getPropsFromStateWrapper(newState);
|
|
50
|
+
std::shared_ptr<const HybridNativeListProps> oldProps = getPropsFromStateWrapper(oldState);
|
|
51
|
+
if (newProps == nullptr) [[unlikely]] {
|
|
52
|
+
throw std::runtime_error("Current StateWrapper doesn't contain any props!");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Update only props that differ from the previous State snapshot.
|
|
56
|
+
if (oldProps == nullptr
|
|
57
|
+
? newProps->snapshotJson.isProvided()
|
|
58
|
+
: !newProps->snapshotJson.hasSameValue(oldProps->snapshotJson)) {
|
|
59
|
+
hybridView->setSnapshotJson(newProps->snapshotJson.get());
|
|
60
|
+
}
|
|
61
|
+
if (oldProps == nullptr
|
|
62
|
+
? newProps->onRowAction.isProvided()
|
|
63
|
+
: !newProps->onRowAction.hasSameValue(oldProps->onRowAction)) {
|
|
64
|
+
hybridView->setOnRowAction(newProps->onRowAction.get());
|
|
65
|
+
}
|
|
66
|
+
if (oldProps == nullptr
|
|
67
|
+
? newProps->onActionAnchorInvalidated.isProvided()
|
|
68
|
+
: !newProps->onActionAnchorInvalidated.hasSameValue(oldProps->onActionAnchorInvalidated)) {
|
|
69
|
+
hybridView->setOnActionAnchorInvalidated(newProps->onActionAnchorInvalidated.get());
|
|
70
|
+
}
|
|
71
|
+
if (oldProps == nullptr
|
|
72
|
+
? newProps->onSelectionDelta.isProvided()
|
|
73
|
+
: !newProps->onSelectionDelta.hasSameValue(oldProps->onSelectionDelta)) {
|
|
74
|
+
hybridView->setOnSelectionDelta(newProps->onSelectionDelta.get());
|
|
75
|
+
}
|
|
76
|
+
if (oldProps == nullptr
|
|
77
|
+
? newProps->onReorder.isProvided()
|
|
78
|
+
: !newProps->onReorder.hasSameValue(oldProps->onReorder)) {
|
|
79
|
+
hybridView->setOnReorder(newProps->onReorder.get());
|
|
80
|
+
}
|
|
81
|
+
if (oldProps == nullptr
|
|
82
|
+
? newProps->onEndReached.isProvided()
|
|
83
|
+
: !newProps->onEndReached.hasSameValue(oldProps->onEndReached)) {
|
|
84
|
+
hybridView->setOnEndReached(newProps->onEndReached.get());
|
|
85
|
+
}
|
|
86
|
+
if (oldProps == nullptr
|
|
87
|
+
? newProps->onVisibleRangeChanged.isProvided()
|
|
88
|
+
: !newProps->onVisibleRangeChanged.hasSameValue(oldProps->onVisibleRangeChanged)) {
|
|
89
|
+
hybridView->setOnVisibleRangeChanged(newProps->onVisibleRangeChanged.get());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Update hybridRef if it changed
|
|
93
|
+
if (oldProps == nullptr
|
|
94
|
+
? newProps->hybridRef.isProvided()
|
|
95
|
+
: !newProps->hybridRef.hasSameValue(oldProps->hybridRef)) {
|
|
96
|
+
// hybridRef changed - call it with new this
|
|
97
|
+
const auto& maybeFunc = newProps->hybridRef.get();
|
|
98
|
+
if (maybeFunc.has_value()) {
|
|
99
|
+
maybeFunc.value()(hybridView);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
} // namespace margelo::nitro::nativelist::views
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNativeListStateUpdater.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#ifndef RN_SERIALIZABLE_STATE
|
|
11
|
+
#error nativelist 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/CoreComponentsRegistry.h>
|
|
16
|
+
#include <react/fabric/StateWrapperImpl.h>
|
|
17
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
18
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
19
|
+
#include <NitroModules/JStateWrapper.hpp>
|
|
20
|
+
#include "JHybridNativeListSpec.hpp"
|
|
21
|
+
#include "views/HybridNativeListComponent.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::nativelist::views {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
class JHybridNativeListStateUpdater final: public jni::JavaClass<JHybridNativeListStateUpdater> {
|
|
28
|
+
public:
|
|
29
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nativelist/views/HybridNativeListStateUpdater;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
|
+
jni::alias_ref<JHybridNativeListSpec::JavaPart> view,
|
|
34
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
35
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState);
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
static std::shared_ptr<const HybridNativeListProps> getPropsFromStateWrapper(
|
|
39
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper);
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
static void registerNatives() {
|
|
43
|
+
// Register JNI calls
|
|
44
|
+
javaClassStatic()->registerNatives({
|
|
45
|
+
makeNativeMethod("updateViewProps", JHybridNativeListStateUpdater::updateViewProps),
|
|
46
|
+
});
|
|
47
|
+
// Register React Native view component descriptor
|
|
48
|
+
auto provider = react::concreteComponentDescriptorProvider<HybridNativeListComponentDescriptor>();
|
|
49
|
+
auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry();
|
|
50
|
+
providerRegistry->add(provider);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::nativelist::views
|
package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/Func_void_std__string.kt
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nativelist
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript callback `(payloadJson: string) => void`.
|
|
17
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
18
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
23
|
+
fun interface Func_void_std__string: (String) -> Unit {
|
|
24
|
+
/**
|
|
25
|
+
* Call the given JS callback.
|
|
26
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
27
|
+
*/
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
@Keep
|
|
30
|
+
override fun invoke(payloadJson: String): Unit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the JavaScript callback `(payloadJson: string) => void`.
|
|
35
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
36
|
+
* The callback might be coming from JS.
|
|
37
|
+
*/
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
@Suppress(
|
|
41
|
+
"KotlinJniMissingFunction", "unused",
|
|
42
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
43
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
44
|
+
)
|
|
45
|
+
class Func_void_std__string_cxx: Func_void_std__string {
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
@Keep
|
|
48
|
+
private val mHybridData: HybridData
|
|
49
|
+
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
private constructor(hybridData: HybridData) {
|
|
53
|
+
mHybridData = hybridData
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
override fun invoke(payloadJson: String): Unit
|
|
59
|
+
= invoke_cxx(payloadJson)
|
|
60
|
+
|
|
61
|
+
private external fun invoke_cxx(payloadJson: String): Unit
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Represents the JavaScript callback `(payloadJson: string) => void`.
|
|
66
|
+
* This is implemented in Java/Kotlin, via a `(String) -> Unit`.
|
|
67
|
+
* The callback is always coming from native.
|
|
68
|
+
*/
|
|
69
|
+
@DoNotStrip
|
|
70
|
+
@Keep
|
|
71
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
72
|
+
class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string {
|
|
73
|
+
@DoNotStrip
|
|
74
|
+
@Keep
|
|
75
|
+
override fun invoke(payloadJson: String): Unit {
|
|
76
|
+
return this.function(payloadJson)
|
|
77
|
+
}
|
|
78
|
+
}
|