@onekeyfe/react-native-segment-slider 3.0.40
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/README.md +31 -0
- package/SegmentSlider.podspec +29 -0
- package/android/CMakeLists.txt +26 -0
- package/android/build.gradle +128 -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/margelo/nitro/segmentslider/HybridSegmentSlider.kt +364 -0
- package/android/src/main/java/com/margelo/nitro/segmentslider/SegmentSliderColorParser.kt +56 -0
- package/android/src/main/java/com/margelo/nitro/segmentslider/SegmentSliderPackage.kt +29 -0
- package/ios/HybridSegmentSlider.swift +412 -0
- package/ios/SegmentSliderColorParser.swift +152 -0
- package/lib/module/SegmentSlider.nitro.js +4 -0
- package/lib/module/SegmentSlider.nitro.js.map +1 -0
- package/lib/module/index.js +43 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/lib/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/lib/nitrogen/generated/android/c++/JHybridSegmentSliderSpec.cpp +265 -0
- package/lib/nitrogen/generated/android/c++/JHybridSegmentSliderSpec.hpp +106 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridSegmentSliderStateUpdater.cpp +136 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridSegmentSliderStateUpdater.hpp +49 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/Func_void.kt +80 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/Func_void_double.kt +80 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/HybridSegmentSliderSpec.kt +203 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/segmentsliderOnLoad.kt +35 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/views/HybridSegmentSliderManager.kt +50 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/views/HybridSegmentSliderStateUpdater.kt +23 -0
- package/lib/nitrogen/generated/android/segmentslider+autolinking.cmake +83 -0
- package/lib/nitrogen/generated/android/segmentslider+autolinking.gradle +27 -0
- package/lib/nitrogen/generated/android/segmentsliderOnLoad.cpp +50 -0
- package/lib/nitrogen/generated/android/segmentsliderOnLoad.hpp +25 -0
- package/lib/nitrogen/generated/ios/SegmentSlider+autolinking.rb +60 -0
- package/lib/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Bridge.cpp +49 -0
- package/lib/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Bridge.hpp +116 -0
- package/lib/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Umbrella.hpp +44 -0
- package/lib/nitrogen/generated/ios/SegmentSliderAutolinking.mm +33 -0
- package/lib/nitrogen/generated/ios/SegmentSliderAutolinking.swift +25 -0
- package/lib/nitrogen/generated/ios/c++/HybridSegmentSliderSpecSwift.cpp +11 -0
- package/lib/nitrogen/generated/ios/c++/HybridSegmentSliderSpecSwift.hpp +208 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridSegmentSliderComponent.mm +196 -0
- package/lib/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/lib/nitrogen/generated/ios/swift/HybridSegmentSliderSpec.swift +76 -0
- package/lib/nitrogen/generated/ios/swift/HybridSegmentSliderSpec_cxx.swift +423 -0
- package/lib/nitrogen/generated/shared/c++/HybridSegmentSliderSpec.cpp +62 -0
- package/lib/nitrogen/generated/shared/c++/HybridSegmentSliderSpec.hpp +105 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridSegmentSliderComponent.cpp +327 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridSegmentSliderComponent.hpp +128 -0
- package/lib/nitrogen/generated/shared/json/SegmentSliderConfig.json +30 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/JHybridSegmentSliderSpec.cpp +265 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/JHybridSegmentSliderSpec.hpp +106 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridSegmentSliderStateUpdater.cpp +136 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridSegmentSliderStateUpdater.hpp +49 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/Func_void.kt +80 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/Func_void_double.kt +80 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/HybridSegmentSliderSpec.kt +203 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/segmentsliderOnLoad.kt +35 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/views/HybridSegmentSliderManager.kt +50 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/views/HybridSegmentSliderStateUpdater.kt +23 -0
- package/lib/nitrogen/nitrogen/generated/android/segmentslider+autolinking.cmake +83 -0
- package/lib/nitrogen/nitrogen/generated/android/segmentslider+autolinking.gradle +27 -0
- package/lib/nitrogen/nitrogen/generated/android/segmentsliderOnLoad.cpp +50 -0
- package/lib/nitrogen/nitrogen/generated/android/segmentsliderOnLoad.hpp +25 -0
- package/lib/nitrogen/nitrogen/generated/ios/SegmentSlider+autolinking.rb +60 -0
- package/lib/nitrogen/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Bridge.cpp +49 -0
- package/lib/nitrogen/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Bridge.hpp +116 -0
- package/lib/nitrogen/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Umbrella.hpp +44 -0
- package/lib/nitrogen/nitrogen/generated/ios/SegmentSliderAutolinking.mm +33 -0
- package/lib/nitrogen/nitrogen/generated/ios/SegmentSliderAutolinking.swift +25 -0
- package/lib/nitrogen/nitrogen/generated/ios/c++/HybridSegmentSliderSpecSwift.cpp +11 -0
- package/lib/nitrogen/nitrogen/generated/ios/c++/HybridSegmentSliderSpecSwift.hpp +208 -0
- package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridSegmentSliderComponent.mm +196 -0
- package/lib/nitrogen/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/lib/nitrogen/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/lib/nitrogen/nitrogen/generated/ios/swift/HybridSegmentSliderSpec.swift +76 -0
- package/lib/nitrogen/nitrogen/generated/ios/swift/HybridSegmentSliderSpec_cxx.swift +423 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/HybridSegmentSliderSpec.cpp +62 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/HybridSegmentSliderSpec.hpp +105 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridSegmentSliderComponent.cpp +327 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridSegmentSliderComponent.hpp +128 -0
- package/lib/nitrogen/nitrogen/generated/shared/json/SegmentSliderConfig.json +30 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/SegmentSlider.nitro.d.ts +72 -0
- package/lib/typescript/src/SegmentSlider.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridSegmentSliderSpec.cpp +265 -0
- package/nitrogen/generated/android/c++/JHybridSegmentSliderSpec.hpp +106 -0
- package/nitrogen/generated/android/c++/views/JHybridSegmentSliderStateUpdater.cpp +136 -0
- package/nitrogen/generated/android/c++/views/JHybridSegmentSliderStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/HybridSegmentSliderSpec.kt +203 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/segmentsliderOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/views/HybridSegmentSliderManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/segmentslider/views/HybridSegmentSliderStateUpdater.kt +23 -0
- package/nitrogen/generated/android/segmentslider+autolinking.cmake +83 -0
- package/nitrogen/generated/android/segmentslider+autolinking.gradle +27 -0
- package/nitrogen/generated/android/segmentsliderOnLoad.cpp +50 -0
- package/nitrogen/generated/android/segmentsliderOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/SegmentSlider+autolinking.rb +60 -0
- package/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Bridge.hpp +116 -0
- package/nitrogen/generated/ios/SegmentSlider-Swift-Cxx-Umbrella.hpp +44 -0
- package/nitrogen/generated/ios/SegmentSliderAutolinking.mm +33 -0
- package/nitrogen/generated/ios/SegmentSliderAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridSegmentSliderSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridSegmentSliderSpecSwift.hpp +208 -0
- package/nitrogen/generated/ios/c++/views/HybridSegmentSliderComponent.mm +196 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridSegmentSliderSpec.swift +76 -0
- package/nitrogen/generated/ios/swift/HybridSegmentSliderSpec_cxx.swift +423 -0
- package/nitrogen/generated/shared/c++/HybridSegmentSliderSpec.cpp +62 -0
- package/nitrogen/generated/shared/c++/HybridSegmentSliderSpec.hpp +105 -0
- package/nitrogen/generated/shared/c++/views/HybridSegmentSliderComponent.cpp +327 -0
- package/nitrogen/generated/shared/c++/views/HybridSegmentSliderComponent.hpp +128 -0
- package/nitrogen/generated/shared/json/SegmentSliderConfig.json +30 -0
- package/package.json +170 -0
- package/src/SegmentSlider.nitro.ts +80 -0
- package/src/index.tsx +59 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSegmentSliderComponent.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridSegmentSliderComponent.hpp"
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <exception>
|
|
12
|
+
#include <utility>
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
15
|
+
#include <react/renderer/core/RawValue.h>
|
|
16
|
+
#include <react/renderer/core/ShadowNode.h>
|
|
17
|
+
#include <react/renderer/core/ComponentDescriptor.h>
|
|
18
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::segmentslider::views {
|
|
21
|
+
|
|
22
|
+
extern const char HybridSegmentSliderComponentName[] = "SegmentSlider";
|
|
23
|
+
|
|
24
|
+
HybridSegmentSliderProps::HybridSegmentSliderProps(const react::PropsParserContext& context,
|
|
25
|
+
const HybridSegmentSliderProps& sourceProps,
|
|
26
|
+
const react::RawProps& rawProps):
|
|
27
|
+
react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
|
|
28
|
+
value([&]() -> CachedProp<double> {
|
|
29
|
+
try {
|
|
30
|
+
const react::RawValue* rawValue = rawProps.at("value", nullptr, nullptr);
|
|
31
|
+
if (rawValue == nullptr) return sourceProps.value;
|
|
32
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
33
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.value);
|
|
34
|
+
} catch (const std::exception& exc) {
|
|
35
|
+
throw std::runtime_error(std::string("SegmentSlider.value: ") + exc.what());
|
|
36
|
+
}
|
|
37
|
+
}()),
|
|
38
|
+
min([&]() -> CachedProp<double> {
|
|
39
|
+
try {
|
|
40
|
+
const react::RawValue* rawValue = rawProps.at("min", nullptr, nullptr);
|
|
41
|
+
if (rawValue == nullptr) return sourceProps.min;
|
|
42
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
43
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.min);
|
|
44
|
+
} catch (const std::exception& exc) {
|
|
45
|
+
throw std::runtime_error(std::string("SegmentSlider.min: ") + exc.what());
|
|
46
|
+
}
|
|
47
|
+
}()),
|
|
48
|
+
max([&]() -> CachedProp<double> {
|
|
49
|
+
try {
|
|
50
|
+
const react::RawValue* rawValue = rawProps.at("max", nullptr, nullptr);
|
|
51
|
+
if (rawValue == nullptr) return sourceProps.max;
|
|
52
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
53
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.max);
|
|
54
|
+
} catch (const std::exception& exc) {
|
|
55
|
+
throw std::runtime_error(std::string("SegmentSlider.max: ") + exc.what());
|
|
56
|
+
}
|
|
57
|
+
}()),
|
|
58
|
+
segments([&]() -> CachedProp<double> {
|
|
59
|
+
try {
|
|
60
|
+
const react::RawValue* rawValue = rawProps.at("segments", nullptr, nullptr);
|
|
61
|
+
if (rawValue == nullptr) return sourceProps.segments;
|
|
62
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
63
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.segments);
|
|
64
|
+
} catch (const std::exception& exc) {
|
|
65
|
+
throw std::runtime_error(std::string("SegmentSlider.segments: ") + exc.what());
|
|
66
|
+
}
|
|
67
|
+
}()),
|
|
68
|
+
sliderHeight([&]() -> CachedProp<double> {
|
|
69
|
+
try {
|
|
70
|
+
const react::RawValue* rawValue = rawProps.at("sliderHeight", nullptr, nullptr);
|
|
71
|
+
if (rawValue == nullptr) return sourceProps.sliderHeight;
|
|
72
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
73
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.sliderHeight);
|
|
74
|
+
} catch (const std::exception& exc) {
|
|
75
|
+
throw std::runtime_error(std::string("SegmentSlider.sliderHeight: ") + exc.what());
|
|
76
|
+
}
|
|
77
|
+
}()),
|
|
78
|
+
disabled([&]() -> CachedProp<bool> {
|
|
79
|
+
try {
|
|
80
|
+
const react::RawValue* rawValue = rawProps.at("disabled", nullptr, nullptr);
|
|
81
|
+
if (rawValue == nullptr) return sourceProps.disabled;
|
|
82
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
83
|
+
return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.disabled);
|
|
84
|
+
} catch (const std::exception& exc) {
|
|
85
|
+
throw std::runtime_error(std::string("SegmentSlider.disabled: ") + exc.what());
|
|
86
|
+
}
|
|
87
|
+
}()),
|
|
88
|
+
showBubble([&]() -> CachedProp<bool> {
|
|
89
|
+
try {
|
|
90
|
+
const react::RawValue* rawValue = rawProps.at("showBubble", nullptr, nullptr);
|
|
91
|
+
if (rawValue == nullptr) return sourceProps.showBubble;
|
|
92
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
93
|
+
return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.showBubble);
|
|
94
|
+
} catch (const std::exception& exc) {
|
|
95
|
+
throw std::runtime_error(std::string("SegmentSlider.showBubble: ") + exc.what());
|
|
96
|
+
}
|
|
97
|
+
}()),
|
|
98
|
+
centerOrigin([&]() -> CachedProp<bool> {
|
|
99
|
+
try {
|
|
100
|
+
const react::RawValue* rawValue = rawProps.at("centerOrigin", nullptr, nullptr);
|
|
101
|
+
if (rawValue == nullptr) return sourceProps.centerOrigin;
|
|
102
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
103
|
+
return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.centerOrigin);
|
|
104
|
+
} catch (const std::exception& exc) {
|
|
105
|
+
throw std::runtime_error(std::string("SegmentSlider.centerOrigin: ") + exc.what());
|
|
106
|
+
}
|
|
107
|
+
}()),
|
|
108
|
+
epoch([&]() -> CachedProp<double> {
|
|
109
|
+
try {
|
|
110
|
+
const react::RawValue* rawValue = rawProps.at("epoch", nullptr, nullptr);
|
|
111
|
+
if (rawValue == nullptr) return sourceProps.epoch;
|
|
112
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
113
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.epoch);
|
|
114
|
+
} catch (const std::exception& exc) {
|
|
115
|
+
throw std::runtime_error(std::string("SegmentSlider.epoch: ") + exc.what());
|
|
116
|
+
}
|
|
117
|
+
}()),
|
|
118
|
+
fillColor([&]() -> CachedProp<std::string> {
|
|
119
|
+
try {
|
|
120
|
+
const react::RawValue* rawValue = rawProps.at("fillColor", nullptr, nullptr);
|
|
121
|
+
if (rawValue == nullptr) return sourceProps.fillColor;
|
|
122
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
123
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.fillColor);
|
|
124
|
+
} catch (const std::exception& exc) {
|
|
125
|
+
throw std::runtime_error(std::string("SegmentSlider.fillColor: ") + exc.what());
|
|
126
|
+
}
|
|
127
|
+
}()),
|
|
128
|
+
trackColor([&]() -> CachedProp<std::string> {
|
|
129
|
+
try {
|
|
130
|
+
const react::RawValue* rawValue = rawProps.at("trackColor", nullptr, nullptr);
|
|
131
|
+
if (rawValue == nullptr) return sourceProps.trackColor;
|
|
132
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
133
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.trackColor);
|
|
134
|
+
} catch (const std::exception& exc) {
|
|
135
|
+
throw std::runtime_error(std::string("SegmentSlider.trackColor: ") + exc.what());
|
|
136
|
+
}
|
|
137
|
+
}()),
|
|
138
|
+
thumbColor([&]() -> CachedProp<std::string> {
|
|
139
|
+
try {
|
|
140
|
+
const react::RawValue* rawValue = rawProps.at("thumbColor", nullptr, nullptr);
|
|
141
|
+
if (rawValue == nullptr) return sourceProps.thumbColor;
|
|
142
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
143
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.thumbColor);
|
|
144
|
+
} catch (const std::exception& exc) {
|
|
145
|
+
throw std::runtime_error(std::string("SegmentSlider.thumbColor: ") + exc.what());
|
|
146
|
+
}
|
|
147
|
+
}()),
|
|
148
|
+
thumbBorderColor([&]() -> CachedProp<std::string> {
|
|
149
|
+
try {
|
|
150
|
+
const react::RawValue* rawValue = rawProps.at("thumbBorderColor", nullptr, nullptr);
|
|
151
|
+
if (rawValue == nullptr) return sourceProps.thumbBorderColor;
|
|
152
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
153
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.thumbBorderColor);
|
|
154
|
+
} catch (const std::exception& exc) {
|
|
155
|
+
throw std::runtime_error(std::string("SegmentSlider.thumbBorderColor: ") + exc.what());
|
|
156
|
+
}
|
|
157
|
+
}()),
|
|
158
|
+
markActiveColor([&]() -> CachedProp<std::string> {
|
|
159
|
+
try {
|
|
160
|
+
const react::RawValue* rawValue = rawProps.at("markActiveColor", nullptr, nullptr);
|
|
161
|
+
if (rawValue == nullptr) return sourceProps.markActiveColor;
|
|
162
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
163
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.markActiveColor);
|
|
164
|
+
} catch (const std::exception& exc) {
|
|
165
|
+
throw std::runtime_error(std::string("SegmentSlider.markActiveColor: ") + exc.what());
|
|
166
|
+
}
|
|
167
|
+
}()),
|
|
168
|
+
markInactiveColor([&]() -> CachedProp<std::string> {
|
|
169
|
+
try {
|
|
170
|
+
const react::RawValue* rawValue = rawProps.at("markInactiveColor", nullptr, nullptr);
|
|
171
|
+
if (rawValue == nullptr) return sourceProps.markInactiveColor;
|
|
172
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
173
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.markInactiveColor);
|
|
174
|
+
} catch (const std::exception& exc) {
|
|
175
|
+
throw std::runtime_error(std::string("SegmentSlider.markInactiveColor: ") + exc.what());
|
|
176
|
+
}
|
|
177
|
+
}()),
|
|
178
|
+
markBorderColor([&]() -> CachedProp<std::string> {
|
|
179
|
+
try {
|
|
180
|
+
const react::RawValue* rawValue = rawProps.at("markBorderColor", nullptr, nullptr);
|
|
181
|
+
if (rawValue == nullptr) return sourceProps.markBorderColor;
|
|
182
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
183
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.markBorderColor);
|
|
184
|
+
} catch (const std::exception& exc) {
|
|
185
|
+
throw std::runtime_error(std::string("SegmentSlider.markBorderColor: ") + exc.what());
|
|
186
|
+
}
|
|
187
|
+
}()),
|
|
188
|
+
bubbleColor([&]() -> CachedProp<std::string> {
|
|
189
|
+
try {
|
|
190
|
+
const react::RawValue* rawValue = rawProps.at("bubbleColor", nullptr, nullptr);
|
|
191
|
+
if (rawValue == nullptr) return sourceProps.bubbleColor;
|
|
192
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
193
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.bubbleColor);
|
|
194
|
+
} catch (const std::exception& exc) {
|
|
195
|
+
throw std::runtime_error(std::string("SegmentSlider.bubbleColor: ") + exc.what());
|
|
196
|
+
}
|
|
197
|
+
}()),
|
|
198
|
+
bubbleTextColor([&]() -> CachedProp<std::string> {
|
|
199
|
+
try {
|
|
200
|
+
const react::RawValue* rawValue = rawProps.at("bubbleTextColor", nullptr, nullptr);
|
|
201
|
+
if (rawValue == nullptr) return sourceProps.bubbleTextColor;
|
|
202
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
203
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.bubbleTextColor);
|
|
204
|
+
} catch (const std::exception& exc) {
|
|
205
|
+
throw std::runtime_error(std::string("SegmentSlider.bubbleTextColor: ") + exc.what());
|
|
206
|
+
}
|
|
207
|
+
}()),
|
|
208
|
+
onChange([&]() -> CachedProp<std::optional<std::function<void(double /* value */)>>> {
|
|
209
|
+
try {
|
|
210
|
+
const react::RawValue* rawValue = rawProps.at("onChange", nullptr, nullptr);
|
|
211
|
+
if (rawValue == nullptr) return sourceProps.onChange;
|
|
212
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
213
|
+
return CachedProp<std::optional<std::function<void(double /* value */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onChange);
|
|
214
|
+
} catch (const std::exception& exc) {
|
|
215
|
+
throw std::runtime_error(std::string("SegmentSlider.onChange: ") + exc.what());
|
|
216
|
+
}
|
|
217
|
+
}()),
|
|
218
|
+
onSlideStart([&]() -> CachedProp<std::optional<std::function<void()>>> {
|
|
219
|
+
try {
|
|
220
|
+
const react::RawValue* rawValue = rawProps.at("onSlideStart", nullptr, nullptr);
|
|
221
|
+
if (rawValue == nullptr) return sourceProps.onSlideStart;
|
|
222
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
223
|
+
return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onSlideStart);
|
|
224
|
+
} catch (const std::exception& exc) {
|
|
225
|
+
throw std::runtime_error(std::string("SegmentSlider.onSlideStart: ") + exc.what());
|
|
226
|
+
}
|
|
227
|
+
}()),
|
|
228
|
+
onSlideComplete([&]() -> CachedProp<std::optional<std::function<void()>>> {
|
|
229
|
+
try {
|
|
230
|
+
const react::RawValue* rawValue = rawProps.at("onSlideComplete", nullptr, nullptr);
|
|
231
|
+
if (rawValue == nullptr) return sourceProps.onSlideComplete;
|
|
232
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
233
|
+
return CachedProp<std::optional<std::function<void()>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onSlideComplete);
|
|
234
|
+
} catch (const std::exception& exc) {
|
|
235
|
+
throw std::runtime_error(std::string("SegmentSlider.onSlideComplete: ") + exc.what());
|
|
236
|
+
}
|
|
237
|
+
}()),
|
|
238
|
+
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridSegmentSliderSpec>& /* ref */)>>> {
|
|
239
|
+
try {
|
|
240
|
+
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
241
|
+
if (rawValue == nullptr) return sourceProps.hybridRef;
|
|
242
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
243
|
+
return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridSegmentSliderSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.hybridRef);
|
|
244
|
+
} catch (const std::exception& exc) {
|
|
245
|
+
throw std::runtime_error(std::string("SegmentSlider.hybridRef: ") + exc.what());
|
|
246
|
+
}
|
|
247
|
+
}()) { }
|
|
248
|
+
|
|
249
|
+
HybridSegmentSliderProps::HybridSegmentSliderProps(const HybridSegmentSliderProps& other):
|
|
250
|
+
react::ViewProps(),
|
|
251
|
+
value(other.value),
|
|
252
|
+
min(other.min),
|
|
253
|
+
max(other.max),
|
|
254
|
+
segments(other.segments),
|
|
255
|
+
sliderHeight(other.sliderHeight),
|
|
256
|
+
disabled(other.disabled),
|
|
257
|
+
showBubble(other.showBubble),
|
|
258
|
+
centerOrigin(other.centerOrigin),
|
|
259
|
+
epoch(other.epoch),
|
|
260
|
+
fillColor(other.fillColor),
|
|
261
|
+
trackColor(other.trackColor),
|
|
262
|
+
thumbColor(other.thumbColor),
|
|
263
|
+
thumbBorderColor(other.thumbBorderColor),
|
|
264
|
+
markActiveColor(other.markActiveColor),
|
|
265
|
+
markInactiveColor(other.markInactiveColor),
|
|
266
|
+
markBorderColor(other.markBorderColor),
|
|
267
|
+
bubbleColor(other.bubbleColor),
|
|
268
|
+
bubbleTextColor(other.bubbleTextColor),
|
|
269
|
+
onChange(other.onChange),
|
|
270
|
+
onSlideStart(other.onSlideStart),
|
|
271
|
+
onSlideComplete(other.onSlideComplete),
|
|
272
|
+
hybridRef(other.hybridRef) { }
|
|
273
|
+
|
|
274
|
+
bool HybridSegmentSliderProps::filterObjectKeys(const std::string& propName) {
|
|
275
|
+
switch (hashString(propName)) {
|
|
276
|
+
case hashString("value"): return true;
|
|
277
|
+
case hashString("min"): return true;
|
|
278
|
+
case hashString("max"): return true;
|
|
279
|
+
case hashString("segments"): return true;
|
|
280
|
+
case hashString("sliderHeight"): return true;
|
|
281
|
+
case hashString("disabled"): return true;
|
|
282
|
+
case hashString("showBubble"): return true;
|
|
283
|
+
case hashString("centerOrigin"): return true;
|
|
284
|
+
case hashString("epoch"): return true;
|
|
285
|
+
case hashString("fillColor"): return true;
|
|
286
|
+
case hashString("trackColor"): return true;
|
|
287
|
+
case hashString("thumbColor"): return true;
|
|
288
|
+
case hashString("thumbBorderColor"): return true;
|
|
289
|
+
case hashString("markActiveColor"): return true;
|
|
290
|
+
case hashString("markInactiveColor"): return true;
|
|
291
|
+
case hashString("markBorderColor"): return true;
|
|
292
|
+
case hashString("bubbleColor"): return true;
|
|
293
|
+
case hashString("bubbleTextColor"): return true;
|
|
294
|
+
case hashString("onChange"): return true;
|
|
295
|
+
case hashString("onSlideStart"): return true;
|
|
296
|
+
case hashString("onSlideComplete"): return true;
|
|
297
|
+
case hashString("hybridRef"): return true;
|
|
298
|
+
default: return false;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
HybridSegmentSliderComponentDescriptor::HybridSegmentSliderComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
|
|
303
|
+
: ConcreteComponentDescriptor(parameters,
|
|
304
|
+
react::RawPropsParser(/* enableJsiParser */ true)) {}
|
|
305
|
+
|
|
306
|
+
std::shared_ptr<const react::Props> HybridSegmentSliderComponentDescriptor::cloneProps(const react::PropsParserContext& context,
|
|
307
|
+
const std::shared_ptr<const react::Props>& props,
|
|
308
|
+
react::RawProps rawProps) const {
|
|
309
|
+
// 1. Prepare raw props parser
|
|
310
|
+
rawProps.parse(rawPropsParser_);
|
|
311
|
+
// 2. Copy props with Nitro's cached copy constructor
|
|
312
|
+
return HybridSegmentSliderShadowNode::Props(context, /* & */ rawProps, props);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
#ifdef ANDROID
|
|
316
|
+
void HybridSegmentSliderComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
|
|
317
|
+
// This is called immediately after `ShadowNode` is created, cloned or in progress.
|
|
318
|
+
// On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
|
|
319
|
+
auto& concreteShadowNode = dynamic_cast<HybridSegmentSliderShadowNode&>(shadowNode);
|
|
320
|
+
const HybridSegmentSliderProps& props = concreteShadowNode.getConcreteProps();
|
|
321
|
+
HybridSegmentSliderState state;
|
|
322
|
+
state.setProps(props);
|
|
323
|
+
concreteShadowNode.setStateData(std::move(state));
|
|
324
|
+
}
|
|
325
|
+
#endif
|
|
326
|
+
|
|
327
|
+
} // namespace margelo::nitro::segmentslider::views
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSegmentSliderComponent.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <optional>
|
|
11
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
12
|
+
#include <NitroModules/NitroHash.hpp>
|
|
13
|
+
#include <NitroModules/CachedProp.hpp>
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
16
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
17
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
18
|
+
|
|
19
|
+
#include <string>
|
|
20
|
+
#include <functional>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <memory>
|
|
23
|
+
#include "HybridSegmentSliderSpec.hpp"
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::segmentslider::views {
|
|
26
|
+
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The name of the actual native View.
|
|
31
|
+
*/
|
|
32
|
+
extern const char HybridSegmentSliderComponentName[];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Props for the "SegmentSlider" View.
|
|
36
|
+
*/
|
|
37
|
+
class HybridSegmentSliderProps final: public react::ViewProps {
|
|
38
|
+
public:
|
|
39
|
+
HybridSegmentSliderProps() = default;
|
|
40
|
+
HybridSegmentSliderProps(const HybridSegmentSliderProps&);
|
|
41
|
+
HybridSegmentSliderProps(const react::PropsParserContext& context,
|
|
42
|
+
const HybridSegmentSliderProps& sourceProps,
|
|
43
|
+
const react::RawProps& rawProps);
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
CachedProp<double> value;
|
|
47
|
+
CachedProp<double> min;
|
|
48
|
+
CachedProp<double> max;
|
|
49
|
+
CachedProp<double> segments;
|
|
50
|
+
CachedProp<double> sliderHeight;
|
|
51
|
+
CachedProp<bool> disabled;
|
|
52
|
+
CachedProp<bool> showBubble;
|
|
53
|
+
CachedProp<bool> centerOrigin;
|
|
54
|
+
CachedProp<double> epoch;
|
|
55
|
+
CachedProp<std::string> fillColor;
|
|
56
|
+
CachedProp<std::string> trackColor;
|
|
57
|
+
CachedProp<std::string> thumbColor;
|
|
58
|
+
CachedProp<std::string> thumbBorderColor;
|
|
59
|
+
CachedProp<std::string> markActiveColor;
|
|
60
|
+
CachedProp<std::string> markInactiveColor;
|
|
61
|
+
CachedProp<std::string> markBorderColor;
|
|
62
|
+
CachedProp<std::string> bubbleColor;
|
|
63
|
+
CachedProp<std::string> bubbleTextColor;
|
|
64
|
+
CachedProp<std::optional<std::function<void(double /* value */)>>> onChange;
|
|
65
|
+
CachedProp<std::optional<std::function<void()>>> onSlideStart;
|
|
66
|
+
CachedProp<std::optional<std::function<void()>>> onSlideComplete;
|
|
67
|
+
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridSegmentSliderSpec>& /* ref */)>>> hybridRef;
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
static bool filterObjectKeys(const std::string& propName);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* State for the "SegmentSlider" View.
|
|
75
|
+
*/
|
|
76
|
+
class HybridSegmentSliderState final {
|
|
77
|
+
public:
|
|
78
|
+
HybridSegmentSliderState() = default;
|
|
79
|
+
|
|
80
|
+
public:
|
|
81
|
+
void setProps(const HybridSegmentSliderProps& props) { _props.emplace(props); }
|
|
82
|
+
const std::optional<HybridSegmentSliderProps>& getProps() const { return _props; }
|
|
83
|
+
|
|
84
|
+
public:
|
|
85
|
+
#ifdef ANDROID
|
|
86
|
+
HybridSegmentSliderState(const HybridSegmentSliderState& /* previousState */, folly::dynamic /* data */) {}
|
|
87
|
+
folly::dynamic getDynamic() const {
|
|
88
|
+
throw std::runtime_error("HybridSegmentSliderState does not support folly!");
|
|
89
|
+
}
|
|
90
|
+
react::MapBuffer getMapBuffer() const {
|
|
91
|
+
throw std::runtime_error("HybridSegmentSliderState does not support MapBuffer!");
|
|
92
|
+
};
|
|
93
|
+
#endif
|
|
94
|
+
|
|
95
|
+
private:
|
|
96
|
+
std::optional<HybridSegmentSliderProps> _props;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The Shadow Node for the "SegmentSlider" View.
|
|
101
|
+
*/
|
|
102
|
+
using HybridSegmentSliderShadowNode = react::ConcreteViewShadowNode<HybridSegmentSliderComponentName /* "HybridSegmentSlider" */,
|
|
103
|
+
HybridSegmentSliderProps /* custom props */,
|
|
104
|
+
react::ViewEventEmitter /* default */,
|
|
105
|
+
HybridSegmentSliderState /* custom state */>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The Component Descriptor for the "SegmentSlider" View.
|
|
109
|
+
*/
|
|
110
|
+
class HybridSegmentSliderComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridSegmentSliderShadowNode> {
|
|
111
|
+
public:
|
|
112
|
+
HybridSegmentSliderComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
|
|
113
|
+
|
|
114
|
+
public:
|
|
115
|
+
/**
|
|
116
|
+
* A faster path for cloning props - reuses the caching logic from `HybridSegmentSliderProps`.
|
|
117
|
+
*/
|
|
118
|
+
std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
|
|
119
|
+
const std::shared_ptr<const react::Props>& props,
|
|
120
|
+
react::RawProps rawProps) const override;
|
|
121
|
+
#ifdef ANDROID
|
|
122
|
+
void adopt(react::ShadowNode& shadowNode) const override;
|
|
123
|
+
#endif
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/* The actual view for "SegmentSlider" needs to be implemented in platform-specific code. */
|
|
127
|
+
|
|
128
|
+
} // namespace margelo::nitro::segmentslider::views
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uiViewClassName": "SegmentSlider",
|
|
3
|
+
"supportsRawText": false,
|
|
4
|
+
"bubblingEventTypes": {},
|
|
5
|
+
"directEventTypes": {},
|
|
6
|
+
"validAttributes": {
|
|
7
|
+
"value": true,
|
|
8
|
+
"min": true,
|
|
9
|
+
"max": true,
|
|
10
|
+
"segments": true,
|
|
11
|
+
"sliderHeight": true,
|
|
12
|
+
"disabled": true,
|
|
13
|
+
"showBubble": true,
|
|
14
|
+
"centerOrigin": true,
|
|
15
|
+
"epoch": true,
|
|
16
|
+
"fillColor": true,
|
|
17
|
+
"trackColor": true,
|
|
18
|
+
"thumbColor": true,
|
|
19
|
+
"thumbBorderColor": true,
|
|
20
|
+
"markActiveColor": true,
|
|
21
|
+
"markInactiveColor": true,
|
|
22
|
+
"markBorderColor": true,
|
|
23
|
+
"bubbleColor": true,
|
|
24
|
+
"bubbleTextColor": true,
|
|
25
|
+
"onChange": true,
|
|
26
|
+
"onSlideStart": true,
|
|
27
|
+
"onSlideComplete": true,
|
|
28
|
+
"hybridRef": true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include <functional>
|
|
14
|
+
#include <NitroModules/JNICallable.hpp>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::segmentslider {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents the Java/Kotlin callback `() -> Unit`.
|
|
22
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
23
|
+
*/
|
|
24
|
+
struct JFunc_void: public jni::JavaClass<JFunc_void> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/segmentslider/Func_void;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Invokes the function this `JFunc_void` instance holds through JNI.
|
|
31
|
+
*/
|
|
32
|
+
void invoke() const {
|
|
33
|
+
static const auto method = javaClassStatic()->getMethod<void()>("invoke");
|
|
34
|
+
method(self());
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An implementation of Func_void that is backed by a C++ implementation (using `std::function<...>`)
|
|
40
|
+
*/
|
|
41
|
+
class JFunc_void_cxx final: public jni::HybridClass<JFunc_void_cxx, JFunc_void> {
|
|
42
|
+
public:
|
|
43
|
+
static jni::local_ref<JFunc_void::javaobject> fromCpp(const std::function<void()>& func) {
|
|
44
|
+
return JFunc_void_cxx::newObjectCxxArgs(func);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
/**
|
|
49
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_cxx` instance holds.
|
|
50
|
+
*/
|
|
51
|
+
void invoke_cxx() {
|
|
52
|
+
_func();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
[[nodiscard]]
|
|
57
|
+
inline const std::function<void()>& getFunction() const {
|
|
58
|
+
return _func;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/segmentslider/Func_void_cxx;";
|
|
63
|
+
static void registerNatives() {
|
|
64
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
explicit JFunc_void_cxx(const std::function<void()>& func): _func(func) { }
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
friend HybridBase;
|
|
72
|
+
std::function<void()> _func;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro::segmentslider
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_double.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2026 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include <functional>
|
|
14
|
+
#include <NitroModules/JNICallable.hpp>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::segmentslider {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents the Java/Kotlin callback `(value: Double) -> Unit`.
|
|
22
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
23
|
+
*/
|
|
24
|
+
struct JFunc_void_double: public jni::JavaClass<JFunc_void_double> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/segmentslider/Func_void_double;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Invokes the function this `JFunc_void_double` instance holds through JNI.
|
|
31
|
+
*/
|
|
32
|
+
void invoke(double value) const {
|
|
33
|
+
static const auto method = javaClassStatic()->getMethod<void(double /* value */)>("invoke");
|
|
34
|
+
method(self(), value);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An implementation of Func_void_double that is backed by a C++ implementation (using `std::function<...>`)
|
|
40
|
+
*/
|
|
41
|
+
class JFunc_void_double_cxx final: public jni::HybridClass<JFunc_void_double_cxx, JFunc_void_double> {
|
|
42
|
+
public:
|
|
43
|
+
static jni::local_ref<JFunc_void_double::javaobject> fromCpp(const std::function<void(double /* value */)>& func) {
|
|
44
|
+
return JFunc_void_double_cxx::newObjectCxxArgs(func);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
/**
|
|
49
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_double_cxx` instance holds.
|
|
50
|
+
*/
|
|
51
|
+
void invoke_cxx(double value) {
|
|
52
|
+
_func(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
[[nodiscard]]
|
|
57
|
+
inline const std::function<void(double /* value */)>& getFunction() const {
|
|
58
|
+
return _func;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/segmentslider/Func_void_double_cxx;";
|
|
63
|
+
static void registerNatives() {
|
|
64
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_cxx::invoke_cxx)});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private:
|
|
68
|
+
explicit JFunc_void_double_cxx(const std::function<void(double /* value */)>& func): _func(func) { }
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
friend HybridBase;
|
|
72
|
+
std::function<void(double /* value */)> _func;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro::segmentslider
|