@onekeyfe/react-native-perp-depth-bar 3.0.95 → 3.0.98

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.
Files changed (43) hide show
  1. package/lib/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +122 -87
  2. package/lib/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.hpp +6 -1
  3. package/lib/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.cpp +66 -41
  4. package/lib/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.hpp +6 -1
  5. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsManager.kt +26 -10
  6. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsStateUpdater.kt +2 -2
  7. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioManager.kt +26 -10
  8. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioStateUpdater.kt +2 -2
  9. package/lib/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +146 -107
  10. package/lib/nitrogen/generated/ios/c++/views/HybridPerpSideRatioComponent.mm +86 -57
  11. package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +23 -225
  12. package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +74 -66
  13. package/lib/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.cpp +13 -125
  14. package/lib/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.hpp +44 -56
  15. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +122 -87
  16. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.hpp +6 -1
  17. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.cpp +66 -41
  18. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.hpp +6 -1
  19. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsManager.kt +26 -10
  20. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsStateUpdater.kt +2 -2
  21. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioManager.kt +26 -10
  22. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioStateUpdater.kt +2 -2
  23. package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +146 -107
  24. package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridPerpSideRatioComponent.mm +86 -57
  25. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +23 -225
  26. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +74 -66
  27. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.cpp +13 -125
  28. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.hpp +44 -56
  29. package/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +122 -87
  30. package/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.hpp +6 -1
  31. package/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.cpp +66 -41
  32. package/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.hpp +6 -1
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsManager.kt +26 -10
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsStateUpdater.kt +2 -2
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioManager.kt +26 -10
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioStateUpdater.kt +2 -2
  37. package/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +146 -107
  38. package/nitrogen/generated/ios/c++/views/HybridPerpSideRatioComponent.mm +86 -57
  39. package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +23 -225
  40. package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +74 -66
  41. package/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.cpp +13 -125
  42. package/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.hpp +44 -56
  43. package/package.json +4 -4
@@ -7,215 +7,38 @@
7
7
 
8
8
  #include "HybridPerpDepthBarsComponent.hpp"
9
9
 
10
- #include <string>
11
- #include <exception>
12
- #include <utility>
13
- #include <NitroModules/NitroDefines.hpp>
14
- #include <NitroModules/JSIConverter.hpp>
15
- #include <NitroModules/PropNameIDCache.hpp>
16
- #include <react/renderer/core/RawValue.h>
17
- #include <react/renderer/core/ShadowNode.h>
18
- #include <react/renderer/core/ComponentDescriptor.h>
19
- #include <react/renderer/components/view/ViewProps.h>
10
+ #include <NitroModules/NitroHash.hpp>
11
+ #include <NitroModules/ReactProp.hpp>
20
12
 
21
13
  namespace margelo::nitro::perpdepthbar::views {
22
14
 
15
+ using namespace facebook;
16
+
23
17
  extern const char HybridPerpDepthBarsComponentName[] = "PerpDepthBars";
24
18
 
25
19
  HybridPerpDepthBarsProps::HybridPerpDepthBarsProps(const react::PropsParserContext& context,
26
20
  const HybridPerpDepthBarsProps& sourceProps,
27
21
  const react::RawProps& rawProps):
28
22
  react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
- percents([&]() -> CachedProp<std::vector<double>> {
30
- try {
31
- const react::RawValue* rawValue = rawProps.at("percents", nullptr, nullptr);
32
- if (rawValue == nullptr) return sourceProps.percents;
33
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
- return CachedProp<std::vector<double>>::fromRawValue(*runtime, value, sourceProps.percents);
35
- } catch (const std::exception& exc) {
36
- throw std::runtime_error(std::string("PerpDepthBars.percents: ") + exc.what());
37
- }
38
- }()),
39
- rowHeight([&]() -> CachedProp<double> {
40
- try {
41
- const react::RawValue* rawValue = rawProps.at("rowHeight", nullptr, nullptr);
42
- if (rawValue == nullptr) return sourceProps.rowHeight;
43
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.rowHeight);
45
- } catch (const std::exception& exc) {
46
- throw std::runtime_error(std::string("PerpDepthBars.rowHeight: ") + exc.what());
47
- }
48
- }()),
49
- rowMarginTop([&]() -> CachedProp<double> {
50
- try {
51
- const react::RawValue* rawValue = rawProps.at("rowMarginTop", nullptr, nullptr);
52
- if (rawValue == nullptr) return sourceProps.rowMarginTop;
53
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.rowMarginTop);
55
- } catch (const std::exception& exc) {
56
- throw std::runtime_error(std::string("PerpDepthBars.rowMarginTop: ") + exc.what());
57
- }
58
- }()),
59
- barInset([&]() -> CachedProp<double> {
60
- try {
61
- const react::RawValue* rawValue = rawProps.at("barInset", nullptr, nullptr);
62
- if (rawValue == nullptr) return sourceProps.barInset;
63
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.barInset);
65
- } catch (const std::exception& exc) {
66
- throw std::runtime_error(std::string("PerpDepthBars.barInset: ") + exc.what());
67
- }
68
- }()),
69
- color([&]() -> CachedProp<std::string> {
70
- try {
71
- const react::RawValue* rawValue = rawProps.at("color", nullptr, nullptr);
72
- if (rawValue == nullptr) return sourceProps.color;
73
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.color);
75
- } catch (const std::exception& exc) {
76
- throw std::runtime_error(std::string("PerpDepthBars.color: ") + exc.what());
77
- }
78
- }()),
79
- origin([&]() -> CachedProp<std::string> {
80
- try {
81
- const react::RawValue* rawValue = rawProps.at("origin", nullptr, nullptr);
82
- if (rawValue == nullptr) return sourceProps.origin;
83
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.origin);
85
- } catch (const std::exception& exc) {
86
- throw std::runtime_error(std::string("PerpDepthBars.origin: ") + exc.what());
87
- }
88
- }()),
89
- reducedMotion([&]() -> CachedProp<bool> {
90
- try {
91
- const react::RawValue* rawValue = rawProps.at("reducedMotion", nullptr, nullptr);
92
- if (rawValue == nullptr) return sourceProps.reducedMotion;
93
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
94
- return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.reducedMotion);
95
- } catch (const std::exception& exc) {
96
- throw std::runtime_error(std::string("PerpDepthBars.reducedMotion: ") + exc.what());
97
- }
98
- }()),
99
- epoch([&]() -> CachedProp<double> {
100
- try {
101
- const react::RawValue* rawValue = rawProps.at("epoch", nullptr, nullptr);
102
- if (rawValue == nullptr) return sourceProps.epoch;
103
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
104
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.epoch);
105
- } catch (const std::exception& exc) {
106
- throw std::runtime_error(std::string("PerpDepthBars.epoch: ") + exc.what());
107
- }
108
- }()),
109
- prices([&]() -> CachedProp<std::vector<std::string>> {
110
- try {
111
- const react::RawValue* rawValue = rawProps.at("prices", nullptr, nullptr);
112
- if (rawValue == nullptr) return sourceProps.prices;
113
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
114
- return CachedProp<std::vector<std::string>>::fromRawValue(*runtime, value, sourceProps.prices);
115
- } catch (const std::exception& exc) {
116
- throw std::runtime_error(std::string("PerpDepthBars.prices: ") + exc.what());
117
- }
118
- }()),
119
- sizes([&]() -> CachedProp<std::vector<std::string>> {
120
- try {
121
- const react::RawValue* rawValue = rawProps.at("sizes", nullptr, nullptr);
122
- if (rawValue == nullptr) return sourceProps.sizes;
123
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
124
- return CachedProp<std::vector<std::string>>::fromRawValue(*runtime, value, sourceProps.sizes);
125
- } catch (const std::exception& exc) {
126
- throw std::runtime_error(std::string("PerpDepthBars.sizes: ") + exc.what());
127
- }
128
- }()),
129
- priceColor([&]() -> CachedProp<std::string> {
130
- try {
131
- const react::RawValue* rawValue = rawProps.at("priceColor", nullptr, nullptr);
132
- if (rawValue == nullptr) return sourceProps.priceColor;
133
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
134
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.priceColor);
135
- } catch (const std::exception& exc) {
136
- throw std::runtime_error(std::string("PerpDepthBars.priceColor: ") + exc.what());
137
- }
138
- }()),
139
- sizeColor([&]() -> CachedProp<std::string> {
140
- try {
141
- const react::RawValue* rawValue = rawProps.at("sizeColor", nullptr, nullptr);
142
- if (rawValue == nullptr) return sourceProps.sizeColor;
143
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
144
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.sizeColor);
145
- } catch (const std::exception& exc) {
146
- throw std::runtime_error(std::string("PerpDepthBars.sizeColor: ") + exc.what());
147
- }
148
- }()),
149
- priceFontSize([&]() -> CachedProp<double> {
150
- try {
151
- const react::RawValue* rawValue = rawProps.at("priceFontSize", nullptr, nullptr);
152
- if (rawValue == nullptr) return sourceProps.priceFontSize;
153
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
154
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.priceFontSize);
155
- } catch (const std::exception& exc) {
156
- throw std::runtime_error(std::string("PerpDepthBars.priceFontSize: ") + exc.what());
157
- }
158
- }()),
159
- sizeFontSize([&]() -> CachedProp<double> {
160
- try {
161
- const react::RawValue* rawValue = rawProps.at("sizeFontSize", nullptr, nullptr);
162
- if (rawValue == nullptr) return sourceProps.sizeFontSize;
163
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
164
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.sizeFontSize);
165
- } catch (const std::exception& exc) {
166
- throw std::runtime_error(std::string("PerpDepthBars.sizeFontSize: ") + exc.what());
167
- }
168
- }()),
169
- textInset([&]() -> CachedProp<double> {
170
- try {
171
- const react::RawValue* rawValue = rawProps.at("textInset", nullptr, nullptr);
172
- if (rawValue == nullptr) return sourceProps.textInset;
173
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
174
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.textInset);
175
- } catch (const std::exception& exc) {
176
- throw std::runtime_error(std::string("PerpDepthBars.textInset: ") + exc.what());
177
- }
178
- }()),
179
- placeholderText([&]() -> CachedProp<std::string> {
180
- try {
181
- const react::RawValue* rawValue = rawProps.at("placeholderText", nullptr, nullptr);
182
- if (rawValue == nullptr) return sourceProps.placeholderText;
183
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
184
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.placeholderText);
185
- } catch (const std::exception& exc) {
186
- throw std::runtime_error(std::string("PerpDepthBars.placeholderText: ") + exc.what());
187
- }
188
- }()),
189
- placeholderRows([&]() -> CachedProp<double> {
190
- try {
191
- const react::RawValue* rawValue = rawProps.at("placeholderRows", nullptr, nullptr);
192
- if (rawValue == nullptr) return sourceProps.placeholderRows;
193
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
194
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.placeholderRows);
195
- } catch (const std::exception& exc) {
196
- throw std::runtime_error(std::string("PerpDepthBars.placeholderRows: ") + exc.what());
197
- }
198
- }()),
199
- onRowPress([&]() -> CachedProp<std::optional<std::function<void(double /* rowIndex */)>>> {
200
- try {
201
- const react::RawValue* rawValue = rawProps.at("onRowPress", nullptr, nullptr);
202
- if (rawValue == nullptr) return sourceProps.onRowPress;
203
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
204
- return CachedProp<std::optional<std::function<void(double /* rowIndex */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onRowPress);
205
- } catch (const std::exception& exc) {
206
- throw std::runtime_error(std::string("PerpDepthBars.onRowPress: ") + exc.what());
207
- }
208
- }()),
209
- hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>> {
210
- try {
211
- const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
212
- if (rawValue == nullptr) return sourceProps.hybridRef;
213
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
214
- return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
215
- } catch (const std::exception& exc) {
216
- throw std::runtime_error(std::string("PerpDepthBars.hybridRef: ") + exc.what());
217
- }
218
- }()) { }
23
+ percents(nitro::ReactProp<std::vector<double>>::fromRawValue("PerpDepthBars", "percents", rawProps, sourceProps.percents)),
24
+ rowHeight(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "rowHeight", rawProps, sourceProps.rowHeight)),
25
+ rowMarginTop(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "rowMarginTop", rawProps, sourceProps.rowMarginTop)),
26
+ barInset(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "barInset", rawProps, sourceProps.barInset)),
27
+ color(nitro::ReactProp<std::string>::fromRawValue("PerpDepthBars", "color", rawProps, sourceProps.color)),
28
+ origin(nitro::ReactProp<std::string>::fromRawValue("PerpDepthBars", "origin", rawProps, sourceProps.origin)),
29
+ reducedMotion(nitro::ReactProp<bool>::fromRawValue("PerpDepthBars", "reducedMotion", rawProps, sourceProps.reducedMotion)),
30
+ epoch(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "epoch", rawProps, sourceProps.epoch)),
31
+ prices(nitro::ReactProp<std::vector<std::string>>::fromRawValue("PerpDepthBars", "prices", rawProps, sourceProps.prices)),
32
+ sizes(nitro::ReactProp<std::vector<std::string>>::fromRawValue("PerpDepthBars", "sizes", rawProps, sourceProps.sizes)),
33
+ priceColor(nitro::ReactProp<std::string>::fromRawValue("PerpDepthBars", "priceColor", rawProps, sourceProps.priceColor)),
34
+ sizeColor(nitro::ReactProp<std::string>::fromRawValue("PerpDepthBars", "sizeColor", rawProps, sourceProps.sizeColor)),
35
+ priceFontSize(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "priceFontSize", rawProps, sourceProps.priceFontSize)),
36
+ sizeFontSize(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "sizeFontSize", rawProps, sourceProps.sizeFontSize)),
37
+ textInset(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "textInset", rawProps, sourceProps.textInset)),
38
+ placeholderText(nitro::ReactProp<std::string>::fromRawValue("PerpDepthBars", "placeholderText", rawProps, sourceProps.placeholderText)),
39
+ placeholderRows(nitro::ReactProp<double>::fromRawValue("PerpDepthBars", "placeholderRows", rawProps, sourceProps.placeholderRows)),
40
+ onRowPress(nitro::ReactProp<std::optional<std::function<void(double /* rowIndex */)>>>::fromRawValue("PerpDepthBars", "onRowPress", rawProps, sourceProps.onRowPress)),
41
+ hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>>::fromRawValue("PerpDepthBars", "hybridRef", rawProps, sourceProps.hybridRef)) { }
219
42
 
220
43
  bool HybridPerpDepthBarsProps::filterObjectKeys(const std::string& propName) {
221
44
  switch (hashString(propName)) {
@@ -242,29 +65,4 @@ namespace margelo::nitro::perpdepthbar::views {
242
65
  }
243
66
  }
244
67
 
245
- HybridPerpDepthBarsComponentDescriptor::HybridPerpDepthBarsComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
246
- : ConcreteComponentDescriptor(parameters,
247
- react::RawPropsParser()) {}
248
-
249
- std::shared_ptr<const react::Props> HybridPerpDepthBarsComponentDescriptor::cloneProps(const react::PropsParserContext& context,
250
- const std::shared_ptr<const react::Props>& props,
251
- react::RawProps rawProps) const {
252
- // 1. Prepare raw props parser
253
- rawProps.parse(rawPropsParser_);
254
- // 2. Copy props with Nitro's cached copy constructor
255
- return HybridPerpDepthBarsShadowNode::Props(context, /* & */ rawProps, props);
256
- }
257
-
258
- #ifdef ANDROID
259
- void HybridPerpDepthBarsComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
260
- // This is called immediately after `ShadowNode` is created, cloned or in progress.
261
- // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
262
- auto& concreteShadowNode = static_cast<HybridPerpDepthBarsShadowNode&>(shadowNode);
263
- const std::shared_ptr<const HybridPerpDepthBarsProps>& constProps = concreteShadowNode.getConcreteSharedProps();
264
- const std::shared_ptr<HybridPerpDepthBarsProps>& props = std::const_pointer_cast<HybridPerpDepthBarsProps>(constProps);
265
- HybridPerpDepthBarsState state{props};
266
- concreteShadowNode.setStateData(std::move(state));
267
- }
268
- #endif
269
-
270
68
  } // namespace margelo::nitro::perpdepthbar::views
@@ -7,14 +7,15 @@
7
7
 
8
8
  #pragma once
9
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>
10
+ #include <NitroModules/ReactProp.hpp>
11
+ #include <NitroModules/ViewComponentDescriptor.hpp>
12
+ #include <NitroModules/ViewPropsHolderState.hpp>
16
13
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
14
  #include <react/renderer/components/view/ViewProps.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/core/RawProps.h>
17
+
18
+ #include <string>
18
19
 
19
20
  #include <vector>
20
21
  #include <string>
@@ -43,25 +44,71 @@ namespace margelo::nitro::perpdepthbar::views {
43
44
  const react::RawProps& rawProps);
44
45
 
45
46
  public:
46
- CachedProp<std::vector<double>> percents;
47
- CachedProp<double> rowHeight;
48
- CachedProp<double> rowMarginTop;
49
- CachedProp<double> barInset;
50
- CachedProp<std::string> color;
51
- CachedProp<std::string> origin;
52
- CachedProp<bool> reducedMotion;
53
- CachedProp<double> epoch;
54
- CachedProp<std::vector<std::string>> prices;
55
- CachedProp<std::vector<std::string>> sizes;
56
- CachedProp<std::string> priceColor;
57
- CachedProp<std::string> sizeColor;
58
- CachedProp<double> priceFontSize;
59
- CachedProp<double> sizeFontSize;
60
- CachedProp<double> textInset;
61
- CachedProp<std::string> placeholderText;
62
- CachedProp<double> placeholderRows;
63
- CachedProp<std::optional<std::function<void(double /* rowIndex */)>>> onRowPress;
64
- CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>> hybridRef;
47
+ nitro::ReactProp<std::vector<double>> percents;
48
+ nitro::ReactProp<double> rowHeight;
49
+ nitro::ReactProp<double> rowMarginTop;
50
+ nitro::ReactProp<double> barInset;
51
+ nitro::ReactProp<std::string> color;
52
+ nitro::ReactProp<std::string> origin;
53
+ nitro::ReactProp<bool> reducedMotion;
54
+ nitro::ReactProp<double> epoch;
55
+ nitro::ReactProp<std::vector<std::string>> prices;
56
+ nitro::ReactProp<std::vector<std::string>> sizes;
57
+ nitro::ReactProp<std::string> priceColor;
58
+ nitro::ReactProp<std::string> sizeColor;
59
+ nitro::ReactProp<double> priceFontSize;
60
+ nitro::ReactProp<double> sizeFontSize;
61
+ nitro::ReactProp<double> textInset;
62
+ nitro::ReactProp<std::string> placeholderText;
63
+ nitro::ReactProp<double> placeholderRows;
64
+ nitro::ReactProp<std::optional<std::function<void(double /* rowIndex */)>>> onRowPress;
65
+ nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>> hybridRef;
66
+
67
+ [[nodiscard]]
68
+ bool hasSameProps(const HybridPerpDepthBarsProps& other) const noexcept {
69
+ return percents.hasSameValue(other.percents) &&
70
+ rowHeight.hasSameValue(other.rowHeight) &&
71
+ rowMarginTop.hasSameValue(other.rowMarginTop) &&
72
+ barInset.hasSameValue(other.barInset) &&
73
+ color.hasSameValue(other.color) &&
74
+ origin.hasSameValue(other.origin) &&
75
+ reducedMotion.hasSameValue(other.reducedMotion) &&
76
+ epoch.hasSameValue(other.epoch) &&
77
+ prices.hasSameValue(other.prices) &&
78
+ sizes.hasSameValue(other.sizes) &&
79
+ priceColor.hasSameValue(other.priceColor) &&
80
+ sizeColor.hasSameValue(other.sizeColor) &&
81
+ priceFontSize.hasSameValue(other.priceFontSize) &&
82
+ sizeFontSize.hasSameValue(other.sizeFontSize) &&
83
+ textInset.hasSameValue(other.textInset) &&
84
+ placeholderText.hasSameValue(other.placeholderText) &&
85
+ placeholderRows.hasSameValue(other.placeholderRows) &&
86
+ onRowPress.hasSameValue(other.onRowPress) &&
87
+ hybridRef.hasSameValue(other.hybridRef);
88
+ }
89
+
90
+ [[nodiscard]]
91
+ bool hasAnyProvidedProps() const noexcept {
92
+ return percents.isProvided() ||
93
+ rowHeight.isProvided() ||
94
+ rowMarginTop.isProvided() ||
95
+ barInset.isProvided() ||
96
+ color.isProvided() ||
97
+ origin.isProvided() ||
98
+ reducedMotion.isProvided() ||
99
+ epoch.isProvided() ||
100
+ prices.isProvided() ||
101
+ sizes.isProvided() ||
102
+ priceColor.isProvided() ||
103
+ sizeColor.isProvided() ||
104
+ priceFontSize.isProvided() ||
105
+ sizeFontSize.isProvided() ||
106
+ textInset.isProvided() ||
107
+ placeholderText.isProvided() ||
108
+ placeholderRows.isProvided() ||
109
+ onRowPress.isProvided() ||
110
+ hybridRef.isProvided();
111
+ }
65
112
 
66
113
  private:
67
114
  static bool filterObjectKeys(const std::string& propName);
@@ -70,32 +117,7 @@ namespace margelo::nitro::perpdepthbar::views {
70
117
  /**
71
118
  * State for the "PerpDepthBars" View.
72
119
  */
73
- class HybridPerpDepthBarsState final {
74
- public:
75
- HybridPerpDepthBarsState() = default;
76
- explicit HybridPerpDepthBarsState(const std::shared_ptr<HybridPerpDepthBarsProps>& props):
77
- _props(props) {}
78
-
79
- public:
80
- [[nodiscard]]
81
- const std::shared_ptr<HybridPerpDepthBarsProps>& getProps() const {
82
- return _props;
83
- }
84
-
85
- public:
86
- #ifdef ANDROID
87
- HybridPerpDepthBarsState(const HybridPerpDepthBarsState& /* previousState */, folly::dynamic /* data */) {}
88
- folly::dynamic getDynamic() const {
89
- throw std::runtime_error("HybridPerpDepthBarsState does not support folly!");
90
- }
91
- react::MapBuffer getMapBuffer() const {
92
- throw std::runtime_error("HybridPerpDepthBarsState does not support MapBuffer!");
93
- };
94
- #endif
95
-
96
- private:
97
- std::shared_ptr<HybridPerpDepthBarsProps> _props;
98
- };
120
+ using HybridPerpDepthBarsState = nitro::ViewPropsHolderState<HybridPerpDepthBarsProps>;
99
121
 
100
122
  /**
101
123
  * The Shadow Node for the "PerpDepthBars" View.
@@ -108,21 +130,7 @@ namespace margelo::nitro::perpdepthbar::views {
108
130
  /**
109
131
  * The Component Descriptor for the "PerpDepthBars" View.
110
132
  */
111
- class HybridPerpDepthBarsComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridPerpDepthBarsShadowNode> {
112
- public:
113
- explicit HybridPerpDepthBarsComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
114
-
115
- public:
116
- /**
117
- * A faster path for cloning props - reuses the caching logic from `HybridPerpDepthBarsProps`.
118
- */
119
- std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
120
- const std::shared_ptr<const react::Props>& props,
121
- react::RawProps rawProps) const override;
122
- #ifdef ANDROID
123
- void adopt(react::ShadowNode& shadowNode) const override;
124
- #endif
125
- };
133
+ using HybridPerpDepthBarsComponentDescriptor = nitro::ViewComponentDescriptor<HybridPerpDepthBarsShadowNode>;
126
134
 
127
135
  /* The actual view for "PerpDepthBars" needs to be implemented in platform-specific code. */
128
136
 
@@ -7,115 +7,28 @@
7
7
 
8
8
  #include "HybridPerpSideRatioComponent.hpp"
9
9
 
10
- #include <string>
11
- #include <exception>
12
- #include <utility>
13
- #include <NitroModules/NitroDefines.hpp>
14
- #include <NitroModules/JSIConverter.hpp>
15
- #include <NitroModules/PropNameIDCache.hpp>
16
- #include <react/renderer/core/RawValue.h>
17
- #include <react/renderer/core/ShadowNode.h>
18
- #include <react/renderer/core/ComponentDescriptor.h>
19
- #include <react/renderer/components/view/ViewProps.h>
10
+ #include <NitroModules/NitroHash.hpp>
11
+ #include <NitroModules/ReactProp.hpp>
20
12
 
21
13
  namespace margelo::nitro::perpdepthbar::views {
22
14
 
15
+ using namespace facebook;
16
+
23
17
  extern const char HybridPerpSideRatioComponentName[] = "PerpSideRatio";
24
18
 
25
19
  HybridPerpSideRatioProps::HybridPerpSideRatioProps(const react::PropsParserContext& context,
26
20
  const HybridPerpSideRatioProps& sourceProps,
27
21
  const react::RawProps& rawProps):
28
22
  react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
- bidPercentage([&]() -> CachedProp<double> {
30
- try {
31
- const react::RawValue* rawValue = rawProps.at("bidPercentage", nullptr, nullptr);
32
- if (rawValue == nullptr) return sourceProps.bidPercentage;
33
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.bidPercentage);
35
- } catch (const std::exception& exc) {
36
- throw std::runtime_error(std::string("PerpSideRatio.bidPercentage: ") + exc.what());
37
- }
38
- }()),
39
- askPercentage([&]() -> CachedProp<double> {
40
- try {
41
- const react::RawValue* rawValue = rawProps.at("askPercentage", nullptr, nullptr);
42
- if (rawValue == nullptr) return sourceProps.askPercentage;
43
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.askPercentage);
45
- } catch (const std::exception& exc) {
46
- throw std::runtime_error(std::string("PerpSideRatio.askPercentage: ") + exc.what());
47
- }
48
- }()),
49
- longColor([&]() -> CachedProp<std::string> {
50
- try {
51
- const react::RawValue* rawValue = rawProps.at("longColor", nullptr, nullptr);
52
- if (rawValue == nullptr) return sourceProps.longColor;
53
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.longColor);
55
- } catch (const std::exception& exc) {
56
- throw std::runtime_error(std::string("PerpSideRatio.longColor: ") + exc.what());
57
- }
58
- }()),
59
- shortColor([&]() -> CachedProp<std::string> {
60
- try {
61
- const react::RawValue* rawValue = rawProps.at("shortColor", nullptr, nullptr);
62
- if (rawValue == nullptr) return sourceProps.shortColor;
63
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.shortColor);
65
- } catch (const std::exception& exc) {
66
- throw std::runtime_error(std::string("PerpSideRatio.shortColor: ") + exc.what());
67
- }
68
- }()),
69
- segmentHeight([&]() -> CachedProp<double> {
70
- try {
71
- const react::RawValue* rawValue = rawProps.at("segmentHeight", nullptr, nullptr);
72
- if (rawValue == nullptr) return sourceProps.segmentHeight;
73
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.segmentHeight);
75
- } catch (const std::exception& exc) {
76
- throw std::runtime_error(std::string("PerpSideRatio.segmentHeight: ") + exc.what());
77
- }
78
- }()),
79
- cornerRadius([&]() -> CachedProp<double> {
80
- try {
81
- const react::RawValue* rawValue = rawProps.at("cornerRadius", nullptr, nullptr);
82
- if (rawValue == nullptr) return sourceProps.cornerRadius;
83
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.cornerRadius);
85
- } catch (const std::exception& exc) {
86
- throw std::runtime_error(std::string("PerpSideRatio.cornerRadius: ") + exc.what());
87
- }
88
- }()),
89
- gap([&]() -> CachedProp<double> {
90
- try {
91
- const react::RawValue* rawValue = rawProps.at("gap", nullptr, nullptr);
92
- if (rawValue == nullptr) return sourceProps.gap;
93
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
94
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.gap);
95
- } catch (const std::exception& exc) {
96
- throw std::runtime_error(std::string("PerpSideRatio.gap: ") + exc.what());
97
- }
98
- }()),
99
- reducedMotion([&]() -> CachedProp<bool> {
100
- try {
101
- const react::RawValue* rawValue = rawProps.at("reducedMotion", nullptr, nullptr);
102
- if (rawValue == nullptr) return sourceProps.reducedMotion;
103
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
104
- return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.reducedMotion);
105
- } catch (const std::exception& exc) {
106
- throw std::runtime_error(std::string("PerpSideRatio.reducedMotion: ") + exc.what());
107
- }
108
- }()),
109
- hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpSideRatioSpec>& /* ref */)>>> {
110
- try {
111
- const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
112
- if (rawValue == nullptr) return sourceProps.hybridRef;
113
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
114
- return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpSideRatioSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
115
- } catch (const std::exception& exc) {
116
- throw std::runtime_error(std::string("PerpSideRatio.hybridRef: ") + exc.what());
117
- }
118
- }()) { }
23
+ bidPercentage(nitro::ReactProp<double>::fromRawValue("PerpSideRatio", "bidPercentage", rawProps, sourceProps.bidPercentage)),
24
+ askPercentage(nitro::ReactProp<double>::fromRawValue("PerpSideRatio", "askPercentage", rawProps, sourceProps.askPercentage)),
25
+ longColor(nitro::ReactProp<std::string>::fromRawValue("PerpSideRatio", "longColor", rawProps, sourceProps.longColor)),
26
+ shortColor(nitro::ReactProp<std::string>::fromRawValue("PerpSideRatio", "shortColor", rawProps, sourceProps.shortColor)),
27
+ segmentHeight(nitro::ReactProp<double>::fromRawValue("PerpSideRatio", "segmentHeight", rawProps, sourceProps.segmentHeight)),
28
+ cornerRadius(nitro::ReactProp<double>::fromRawValue("PerpSideRatio", "cornerRadius", rawProps, sourceProps.cornerRadius)),
29
+ gap(nitro::ReactProp<double>::fromRawValue("PerpSideRatio", "gap", rawProps, sourceProps.gap)),
30
+ reducedMotion(nitro::ReactProp<bool>::fromRawValue("PerpSideRatio", "reducedMotion", rawProps, sourceProps.reducedMotion)),
31
+ hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpSideRatioSpec>& /* ref */)>>>::fromRawValue("PerpSideRatio", "hybridRef", rawProps, sourceProps.hybridRef)) { }
119
32
 
120
33
  bool HybridPerpSideRatioProps::filterObjectKeys(const std::string& propName) {
121
34
  switch (hashString(propName)) {
@@ -132,29 +45,4 @@ namespace margelo::nitro::perpdepthbar::views {
132
45
  }
133
46
  }
134
47
 
135
- HybridPerpSideRatioComponentDescriptor::HybridPerpSideRatioComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
136
- : ConcreteComponentDescriptor(parameters,
137
- react::RawPropsParser()) {}
138
-
139
- std::shared_ptr<const react::Props> HybridPerpSideRatioComponentDescriptor::cloneProps(const react::PropsParserContext& context,
140
- const std::shared_ptr<const react::Props>& props,
141
- react::RawProps rawProps) const {
142
- // 1. Prepare raw props parser
143
- rawProps.parse(rawPropsParser_);
144
- // 2. Copy props with Nitro's cached copy constructor
145
- return HybridPerpSideRatioShadowNode::Props(context, /* & */ rawProps, props);
146
- }
147
-
148
- #ifdef ANDROID
149
- void HybridPerpSideRatioComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
150
- // This is called immediately after `ShadowNode` is created, cloned or in progress.
151
- // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
152
- auto& concreteShadowNode = static_cast<HybridPerpSideRatioShadowNode&>(shadowNode);
153
- const std::shared_ptr<const HybridPerpSideRatioProps>& constProps = concreteShadowNode.getConcreteSharedProps();
154
- const std::shared_ptr<HybridPerpSideRatioProps>& props = std::const_pointer_cast<HybridPerpSideRatioProps>(constProps);
155
- HybridPerpSideRatioState state{props};
156
- concreteShadowNode.setStateData(std::move(state));
157
- }
158
- #endif
159
-
160
48
  } // namespace margelo::nitro::perpdepthbar::views