@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,105 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridSegmentSliderSpec.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
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <functional>
|
|
20
|
+
#include <optional>
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::segmentslider {
|
|
23
|
+
|
|
24
|
+
using namespace margelo::nitro;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An abstract base class for `SegmentSlider`
|
|
28
|
+
* Inherit this class to create instances of `HybridSegmentSliderSpec` in C++.
|
|
29
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
30
|
+
* @example
|
|
31
|
+
* ```cpp
|
|
32
|
+
* class HybridSegmentSlider: public HybridSegmentSliderSpec {
|
|
33
|
+
* public:
|
|
34
|
+
* HybridSegmentSlider(...): HybridObject(TAG) { ... }
|
|
35
|
+
* // ...
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
class HybridSegmentSliderSpec: public virtual HybridObject {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor
|
|
42
|
+
explicit HybridSegmentSliderSpec(): HybridObject(TAG) { }
|
|
43
|
+
|
|
44
|
+
// Destructor
|
|
45
|
+
~HybridSegmentSliderSpec() override = default;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
// Properties
|
|
49
|
+
virtual double getValue() = 0;
|
|
50
|
+
virtual void setValue(double value) = 0;
|
|
51
|
+
virtual double getMin() = 0;
|
|
52
|
+
virtual void setMin(double min) = 0;
|
|
53
|
+
virtual double getMax() = 0;
|
|
54
|
+
virtual void setMax(double max) = 0;
|
|
55
|
+
virtual double getSegments() = 0;
|
|
56
|
+
virtual void setSegments(double segments) = 0;
|
|
57
|
+
virtual double getSliderHeight() = 0;
|
|
58
|
+
virtual void setSliderHeight(double sliderHeight) = 0;
|
|
59
|
+
virtual bool getDisabled() = 0;
|
|
60
|
+
virtual void setDisabled(bool disabled) = 0;
|
|
61
|
+
virtual bool getShowBubble() = 0;
|
|
62
|
+
virtual void setShowBubble(bool showBubble) = 0;
|
|
63
|
+
virtual bool getCenterOrigin() = 0;
|
|
64
|
+
virtual void setCenterOrigin(bool centerOrigin) = 0;
|
|
65
|
+
virtual double getEpoch() = 0;
|
|
66
|
+
virtual void setEpoch(double epoch) = 0;
|
|
67
|
+
virtual std::string getFillColor() = 0;
|
|
68
|
+
virtual void setFillColor(const std::string& fillColor) = 0;
|
|
69
|
+
virtual std::string getTrackColor() = 0;
|
|
70
|
+
virtual void setTrackColor(const std::string& trackColor) = 0;
|
|
71
|
+
virtual std::string getThumbColor() = 0;
|
|
72
|
+
virtual void setThumbColor(const std::string& thumbColor) = 0;
|
|
73
|
+
virtual std::string getThumbBorderColor() = 0;
|
|
74
|
+
virtual void setThumbBorderColor(const std::string& thumbBorderColor) = 0;
|
|
75
|
+
virtual std::string getMarkActiveColor() = 0;
|
|
76
|
+
virtual void setMarkActiveColor(const std::string& markActiveColor) = 0;
|
|
77
|
+
virtual std::string getMarkInactiveColor() = 0;
|
|
78
|
+
virtual void setMarkInactiveColor(const std::string& markInactiveColor) = 0;
|
|
79
|
+
virtual std::string getMarkBorderColor() = 0;
|
|
80
|
+
virtual void setMarkBorderColor(const std::string& markBorderColor) = 0;
|
|
81
|
+
virtual std::string getBubbleColor() = 0;
|
|
82
|
+
virtual void setBubbleColor(const std::string& bubbleColor) = 0;
|
|
83
|
+
virtual std::string getBubbleTextColor() = 0;
|
|
84
|
+
virtual void setBubbleTextColor(const std::string& bubbleTextColor) = 0;
|
|
85
|
+
virtual std::optional<std::function<void(double /* value */)>> getOnChange() = 0;
|
|
86
|
+
virtual void setOnChange(const std::optional<std::function<void(double /* value */)>>& onChange) = 0;
|
|
87
|
+
virtual std::optional<std::function<void()>> getOnSlideStart() = 0;
|
|
88
|
+
virtual void setOnSlideStart(const std::optional<std::function<void()>>& onSlideStart) = 0;
|
|
89
|
+
virtual std::optional<std::function<void()>> getOnSlideComplete() = 0;
|
|
90
|
+
virtual void setOnSlideComplete(const std::optional<std::function<void()>>& onSlideComplete) = 0;
|
|
91
|
+
|
|
92
|
+
public:
|
|
93
|
+
// Methods
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
protected:
|
|
97
|
+
// Hybrid Setup
|
|
98
|
+
void loadHybridMethods() override;
|
|
99
|
+
|
|
100
|
+
protected:
|
|
101
|
+
// Tag for logging
|
|
102
|
+
static constexpr auto TAG = "SegmentSlider";
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
} // namespace margelo::nitro::segmentslider
|
|
@@ -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 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { HybridView, HybridViewMethods, HybridViewProps } from 'react-native-nitro-modules';
|
|
2
|
+
/**
|
|
3
|
+
* A segmented slider rendered entirely by native code. Track, fill bar, the
|
|
4
|
+
* N+1 segment marks, the draggable thumb and the value bubble are all drawn on
|
|
5
|
+
* the native UI thread (CALayer on iOS, Canvas onDraw on Android) and the pan
|
|
6
|
+
* gesture is handled natively — there is NO JS round-trip per frame during a
|
|
7
|
+
* drag. This mirrors the web variant
|
|
8
|
+
* (`packages/components/src/composite/SegmentSlider/index.tsx`) which avoids
|
|
9
|
+
* React state per frame by mutating the DOM imperatively.
|
|
10
|
+
*
|
|
11
|
+
* Geometry contract (points), matching the web layout 1:1:
|
|
12
|
+
* THUMB_SIZE = 16, MARK_SIZE = 10, hit/container height = 24
|
|
13
|
+
* track is inset by THUMB_SIZE/2 on each end → usable width W' = W - 16
|
|
14
|
+
* pct = (clamp(value,min,max) - min) / (max - min)
|
|
15
|
+
* thumb x = 8 + pct * W'
|
|
16
|
+
* mark i x = 8 + (i / segments) * W' (i in 0..segments)
|
|
17
|
+
*
|
|
18
|
+
* Colors are resolved from the Tamagui theme in the JS wrapper and passed in as
|
|
19
|
+
* hex / rgba() strings so the native side never depends on the theme system.
|
|
20
|
+
*/
|
|
21
|
+
export interface SegmentSliderProps extends HybridViewProps {
|
|
22
|
+
/** Current (controlled) value. Ignored while the user is dragging. */
|
|
23
|
+
value: number;
|
|
24
|
+
/** Range minimum (default range 0..100). */
|
|
25
|
+
min: number;
|
|
26
|
+
/** Range maximum. */
|
|
27
|
+
max: number;
|
|
28
|
+
/** Number of segment marks. 0 = continuous (no marks). Marks are visual. */
|
|
29
|
+
segments: number;
|
|
30
|
+
/** Track height in points (web default 4). */
|
|
31
|
+
sliderHeight: number;
|
|
32
|
+
/** When true the slider is non-interactive and dimmed. */
|
|
33
|
+
disabled: boolean;
|
|
34
|
+
/** When true a `${round(value)}%` bubble appears above the thumb on drag. */
|
|
35
|
+
showBubble: boolean;
|
|
36
|
+
/** When true the fill grows from the value-0 origin instead of the left. */
|
|
37
|
+
centerOrigin: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Monotonic token. Bump from JS on coin / leverage reset so the native view
|
|
40
|
+
* snaps to the new value WITHOUT animating the thumb scale. Mirrors the
|
|
41
|
+
* `epoch` convention used by react-native-perp-depth-bar.
|
|
42
|
+
*/
|
|
43
|
+
epoch: number;
|
|
44
|
+
/** Active fill bar color (Tamagui `bgPrimary`). */
|
|
45
|
+
fillColor: string;
|
|
46
|
+
/** Inactive track color (Tamagui `neutral5`). */
|
|
47
|
+
trackColor: string;
|
|
48
|
+
/** Thumb fill color (Tamagui `bg`). */
|
|
49
|
+
thumbColor: string;
|
|
50
|
+
/** Thumb border color (Tamagui `borderStrong`). */
|
|
51
|
+
thumbBorderColor: string;
|
|
52
|
+
/** Active mark fill + border color (Tamagui `bgPrimary`). */
|
|
53
|
+
markActiveColor: string;
|
|
54
|
+
/** Inactive mark fill color (Tamagui `bg`). */
|
|
55
|
+
markInactiveColor: string;
|
|
56
|
+
/** Inactive mark border color (Tamagui `neutral5`). */
|
|
57
|
+
markBorderColor: string;
|
|
58
|
+
/** Bubble background color (Tamagui `bgPrimary`). */
|
|
59
|
+
bubbleColor: string;
|
|
60
|
+
/** Bubble text color (Tamagui `bg`). */
|
|
61
|
+
bubbleTextColor: string;
|
|
62
|
+
/** Fired (already rounded to an integer) when the value changes. */
|
|
63
|
+
onChange?: (value: number) => void;
|
|
64
|
+
/** Fired once when a drag/tap begins. */
|
|
65
|
+
onSlideStart?: () => void;
|
|
66
|
+
/** Fired once when a drag/tap ends. */
|
|
67
|
+
onSlideComplete?: () => void;
|
|
68
|
+
}
|
|
69
|
+
export interface SegmentSliderMethods extends HybridViewMethods {
|
|
70
|
+
}
|
|
71
|
+
export type SegmentSlider = HybridView<SegmentSliderProps, SegmentSliderMethods>;
|
|
72
|
+
//# sourceMappingURL=SegmentSlider.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentSlider.nitro.d.ts","sourceRoot":"","sources":["../../../src/SegmentSlider.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,eAAe,EAChB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,qBAAqB;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,UAAU,EAAE,OAAO,CAAC;IACpB,4EAA4E;IAC5E,YAAY,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IAGd,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;IAExB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,uCAAuC;IACvC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;CAAG;AAElE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC"}
|