@onekeyfe/react-native-perp-depth-bar 3.0.39 → 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/android/src/main/java/com/margelo/nitro/perpdepthbar/HybridPerpDepthBars.kt +100 -1
- package/ios/HybridPerpDepthBars.swift +97 -1
- package/ios/PerpColorParser.swift +8 -0
- package/lib/module/index.js +25 -2
- package/lib/module/index.js.map +1 -1
- package/lib/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/lib/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +120 -0
- package/lib/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +16 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +32 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/Func_void_double.kt +80 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +56 -0
- package/lib/nitrogen/generated/android/perpdepthbarOnLoad.cpp +2 -0
- package/lib/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.cpp +8 -0
- package/lib/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.hpp +51 -0
- package/lib/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Umbrella.hpp +2 -0
- package/lib/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +55 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +40 -0
- package/lib/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/lib/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +8 -0
- package/lib/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +121 -0
- package/lib/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +16 -0
- package/lib/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +18 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +96 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +10 -2
- package/lib/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +8 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +120 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +16 -0
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +32 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/Func_void_double.kt +80 -0
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +56 -0
- package/lib/nitrogen/nitrogen/generated/android/perpdepthbarOnLoad.cpp +2 -0
- package/lib/nitrogen/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.cpp +8 -0
- package/lib/nitrogen/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.hpp +51 -0
- package/lib/nitrogen/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Umbrella.hpp +2 -0
- package/lib/nitrogen/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +55 -0
- package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +40 -0
- package/lib/nitrogen/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/lib/nitrogen/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +8 -0
- package/lib/nitrogen/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +121 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +16 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +18 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +96 -0
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +10 -2
- package/lib/nitrogen/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +8 -0
- package/lib/typescript/src/PerpDepthBars.nitro.d.ts +20 -0
- package/lib/typescript/src/PerpDepthBars.nitro.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +7 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +120 -0
- package/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +16 -0
- package/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +56 -0
- package/nitrogen/generated/android/perpdepthbarOnLoad.cpp +2 -0
- package/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.hpp +51 -0
- package/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Umbrella.hpp +2 -0
- package/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +55 -0
- package/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +40 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +8 -0
- package/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +121 -0
- package/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +16 -0
- package/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +18 -0
- package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +96 -0
- package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +10 -2
- package/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +8 -0
- package/package.json +1 -1
- package/src/PerpDepthBars.nitro.ts +27 -0
- package/src/index.tsx +28 -2
|
@@ -105,6 +105,86 @@ namespace margelo::nitro::perpdepthbar::views {
|
|
|
105
105
|
throw std::runtime_error(std::string("PerpDepthBars.epoch: ") + exc.what());
|
|
106
106
|
}
|
|
107
107
|
}()),
|
|
108
|
+
prices([&]() -> CachedProp<std::vector<std::string>> {
|
|
109
|
+
try {
|
|
110
|
+
const react::RawValue* rawValue = rawProps.at("prices", nullptr, nullptr);
|
|
111
|
+
if (rawValue == nullptr) return sourceProps.prices;
|
|
112
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
113
|
+
return CachedProp<std::vector<std::string>>::fromRawValue(*runtime, value, sourceProps.prices);
|
|
114
|
+
} catch (const std::exception& exc) {
|
|
115
|
+
throw std::runtime_error(std::string("PerpDepthBars.prices: ") + exc.what());
|
|
116
|
+
}
|
|
117
|
+
}()),
|
|
118
|
+
sizes([&]() -> CachedProp<std::vector<std::string>> {
|
|
119
|
+
try {
|
|
120
|
+
const react::RawValue* rawValue = rawProps.at("sizes", nullptr, nullptr);
|
|
121
|
+
if (rawValue == nullptr) return sourceProps.sizes;
|
|
122
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
123
|
+
return CachedProp<std::vector<std::string>>::fromRawValue(*runtime, value, sourceProps.sizes);
|
|
124
|
+
} catch (const std::exception& exc) {
|
|
125
|
+
throw std::runtime_error(std::string("PerpDepthBars.sizes: ") + exc.what());
|
|
126
|
+
}
|
|
127
|
+
}()),
|
|
128
|
+
priceColor([&]() -> CachedProp<std::string> {
|
|
129
|
+
try {
|
|
130
|
+
const react::RawValue* rawValue = rawProps.at("priceColor", nullptr, nullptr);
|
|
131
|
+
if (rawValue == nullptr) return sourceProps.priceColor;
|
|
132
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
133
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.priceColor);
|
|
134
|
+
} catch (const std::exception& exc) {
|
|
135
|
+
throw std::runtime_error(std::string("PerpDepthBars.priceColor: ") + exc.what());
|
|
136
|
+
}
|
|
137
|
+
}()),
|
|
138
|
+
sizeColor([&]() -> CachedProp<std::string> {
|
|
139
|
+
try {
|
|
140
|
+
const react::RawValue* rawValue = rawProps.at("sizeColor", nullptr, nullptr);
|
|
141
|
+
if (rawValue == nullptr) return sourceProps.sizeColor;
|
|
142
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
143
|
+
return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.sizeColor);
|
|
144
|
+
} catch (const std::exception& exc) {
|
|
145
|
+
throw std::runtime_error(std::string("PerpDepthBars.sizeColor: ") + exc.what());
|
|
146
|
+
}
|
|
147
|
+
}()),
|
|
148
|
+
priceFontSize([&]() -> CachedProp<double> {
|
|
149
|
+
try {
|
|
150
|
+
const react::RawValue* rawValue = rawProps.at("priceFontSize", nullptr, nullptr);
|
|
151
|
+
if (rawValue == nullptr) return sourceProps.priceFontSize;
|
|
152
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
153
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.priceFontSize);
|
|
154
|
+
} catch (const std::exception& exc) {
|
|
155
|
+
throw std::runtime_error(std::string("PerpDepthBars.priceFontSize: ") + exc.what());
|
|
156
|
+
}
|
|
157
|
+
}()),
|
|
158
|
+
sizeFontSize([&]() -> CachedProp<double> {
|
|
159
|
+
try {
|
|
160
|
+
const react::RawValue* rawValue = rawProps.at("sizeFontSize", nullptr, nullptr);
|
|
161
|
+
if (rawValue == nullptr) return sourceProps.sizeFontSize;
|
|
162
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
163
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.sizeFontSize);
|
|
164
|
+
} catch (const std::exception& exc) {
|
|
165
|
+
throw std::runtime_error(std::string("PerpDepthBars.sizeFontSize: ") + exc.what());
|
|
166
|
+
}
|
|
167
|
+
}()),
|
|
168
|
+
textInset([&]() -> CachedProp<double> {
|
|
169
|
+
try {
|
|
170
|
+
const react::RawValue* rawValue = rawProps.at("textInset", nullptr, nullptr);
|
|
171
|
+
if (rawValue == nullptr) return sourceProps.textInset;
|
|
172
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
173
|
+
return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.textInset);
|
|
174
|
+
} catch (const std::exception& exc) {
|
|
175
|
+
throw std::runtime_error(std::string("PerpDepthBars.textInset: ") + exc.what());
|
|
176
|
+
}
|
|
177
|
+
}()),
|
|
178
|
+
onRowPress([&]() -> CachedProp<std::optional<std::function<void(double /* rowIndex */)>>> {
|
|
179
|
+
try {
|
|
180
|
+
const react::RawValue* rawValue = rawProps.at("onRowPress", nullptr, nullptr);
|
|
181
|
+
if (rawValue == nullptr) return sourceProps.onRowPress;
|
|
182
|
+
const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
|
|
183
|
+
return CachedProp<std::optional<std::function<void(double /* rowIndex */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onRowPress);
|
|
184
|
+
} catch (const std::exception& exc) {
|
|
185
|
+
throw std::runtime_error(std::string("PerpDepthBars.onRowPress: ") + exc.what());
|
|
186
|
+
}
|
|
187
|
+
}()),
|
|
108
188
|
hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>> {
|
|
109
189
|
try {
|
|
110
190
|
const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
|
|
@@ -126,6 +206,14 @@ namespace margelo::nitro::perpdepthbar::views {
|
|
|
126
206
|
origin(other.origin),
|
|
127
207
|
reducedMotion(other.reducedMotion),
|
|
128
208
|
epoch(other.epoch),
|
|
209
|
+
prices(other.prices),
|
|
210
|
+
sizes(other.sizes),
|
|
211
|
+
priceColor(other.priceColor),
|
|
212
|
+
sizeColor(other.sizeColor),
|
|
213
|
+
priceFontSize(other.priceFontSize),
|
|
214
|
+
sizeFontSize(other.sizeFontSize),
|
|
215
|
+
textInset(other.textInset),
|
|
216
|
+
onRowPress(other.onRowPress),
|
|
129
217
|
hybridRef(other.hybridRef) { }
|
|
130
218
|
|
|
131
219
|
bool HybridPerpDepthBarsProps::filterObjectKeys(const std::string& propName) {
|
|
@@ -138,6 +226,14 @@ namespace margelo::nitro::perpdepthbar::views {
|
|
|
138
226
|
case hashString("origin"): return true;
|
|
139
227
|
case hashString("reducedMotion"): return true;
|
|
140
228
|
case hashString("epoch"): return true;
|
|
229
|
+
case hashString("prices"): return true;
|
|
230
|
+
case hashString("sizes"): return true;
|
|
231
|
+
case hashString("priceColor"): return true;
|
|
232
|
+
case hashString("sizeColor"): return true;
|
|
233
|
+
case hashString("priceFontSize"): return true;
|
|
234
|
+
case hashString("sizeFontSize"): return true;
|
|
235
|
+
case hashString("textInset"): return true;
|
|
236
|
+
case hashString("onRowPress"): return true;
|
|
141
237
|
case hashString("hybridRef"): return true;
|
|
142
238
|
default: return false;
|
|
143
239
|
}
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
|
|
19
19
|
#include <vector>
|
|
20
20
|
#include <string>
|
|
21
|
-
#include <memory>
|
|
22
|
-
#include "HybridPerpDepthBarsSpec.hpp"
|
|
23
21
|
#include <functional>
|
|
24
22
|
#include <optional>
|
|
23
|
+
#include <memory>
|
|
24
|
+
#include "HybridPerpDepthBarsSpec.hpp"
|
|
25
25
|
|
|
26
26
|
namespace margelo::nitro::perpdepthbar::views {
|
|
27
27
|
|
|
@@ -52,6 +52,14 @@ namespace margelo::nitro::perpdepthbar::views {
|
|
|
52
52
|
CachedProp<std::string> origin;
|
|
53
53
|
CachedProp<bool> reducedMotion;
|
|
54
54
|
CachedProp<double> epoch;
|
|
55
|
+
CachedProp<std::vector<std::string>> prices;
|
|
56
|
+
CachedProp<std::vector<std::string>> sizes;
|
|
57
|
+
CachedProp<std::string> priceColor;
|
|
58
|
+
CachedProp<std::string> sizeColor;
|
|
59
|
+
CachedProp<double> priceFontSize;
|
|
60
|
+
CachedProp<double> sizeFontSize;
|
|
61
|
+
CachedProp<double> textInset;
|
|
62
|
+
CachedProp<std::optional<std::function<void(double /* rowIndex */)>>> onRowPress;
|
|
55
63
|
CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPerpDepthBarsSpec>& /* ref */)>>> hybridRef;
|
|
56
64
|
|
|
57
65
|
private:
|
|
@@ -12,6 +12,14 @@
|
|
|
12
12
|
"origin": true,
|
|
13
13
|
"reducedMotion": true,
|
|
14
14
|
"epoch": true,
|
|
15
|
+
"prices": true,
|
|
16
|
+
"sizes": true,
|
|
17
|
+
"priceColor": true,
|
|
18
|
+
"sizeColor": true,
|
|
19
|
+
"priceFontSize": true,
|
|
20
|
+
"sizeFontSize": true,
|
|
21
|
+
"textInset": true,
|
|
22
|
+
"onRowPress": true,
|
|
15
23
|
"hybridRef": true
|
|
16
24
|
}
|
|
17
25
|
}
|
package/package.json
CHANGED
|
@@ -35,6 +35,33 @@ export interface PerpDepthBarsProps extends HybridViewProps {
|
|
|
35
35
|
* empty<->full so native snaps to the new values WITHOUT animating.
|
|
36
36
|
*/
|
|
37
37
|
epoch: number;
|
|
38
|
+
|
|
39
|
+
// --- Per-row text (optional). When `prices`/`sizes` are empty the view
|
|
40
|
+
// renders bars only (backward compatible). When provided they are drawn
|
|
41
|
+
// natively per row — price left-aligned, size right-aligned, vertically
|
|
42
|
+
// centred — so the order-book ladder needs NO sibling RN <Text> rows.
|
|
43
|
+
// Each array is parallel to `percents` (same length / order).
|
|
44
|
+
/** Formatted price string per row (e.g. "1981.4"). */
|
|
45
|
+
prices: string[];
|
|
46
|
+
/** Formatted size string per row (e.g. "389.04"). */
|
|
47
|
+
sizes: string[];
|
|
48
|
+
/** Price text color: hex or rgba()/rgb(). */
|
|
49
|
+
priceColor: string;
|
|
50
|
+
/** Size text color: hex or rgba()/rgb(). */
|
|
51
|
+
sizeColor: string;
|
|
52
|
+
/** Price text font size in points. */
|
|
53
|
+
priceFontSize: number;
|
|
54
|
+
/** Size text font size in points. */
|
|
55
|
+
sizeFontSize: number;
|
|
56
|
+
/** Horizontal text inset in points (price padding-left, size padding-right). */
|
|
57
|
+
textInset: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Fired natively when a row is tapped. `rowIndex` is the 0-based row
|
|
61
|
+
* (top→bottom, parallel to `percents`/`prices`/`sizes`). The view handles
|
|
62
|
+
* the touch itself — no RN overlay / JS hit-testing needed.
|
|
63
|
+
*/
|
|
64
|
+
onRowPress?: (rowIndex: number) => void;
|
|
38
65
|
}
|
|
39
66
|
|
|
40
67
|
export interface PerpDepthBarsMethods extends HybridViewMethods {}
|
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
import { callback, getHostComponent } from 'react-native-nitro-modules';
|
|
2
3
|
|
|
3
4
|
import type {
|
|
4
5
|
PerpDepthBarsMethods,
|
|
@@ -19,11 +20,36 @@ export type {
|
|
|
19
20
|
PerpSideRatioProps,
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
const PerpDepthBarsHost = getHostComponent<
|
|
23
24
|
PerpDepthBarsProps,
|
|
24
25
|
PerpDepthBarsMethods
|
|
25
26
|
>('PerpDepthBars', () => PerpDepthBarsConfig);
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Thin wrapper so consumers pass a plain `onRowPress` function. Nitro view
|
|
30
|
+
* callbacks must be wrapped with `callback(...)` to cross the JSI boundary;
|
|
31
|
+
* we encapsulate that here (with a ref so the underlying callback stays
|
|
32
|
+
* stable across re-renders) instead of leaking it to every call site.
|
|
33
|
+
*/
|
|
34
|
+
export function PerpDepthBarsView({
|
|
35
|
+
onRowPress,
|
|
36
|
+
...props
|
|
37
|
+
}: PerpDepthBarsProps) {
|
|
38
|
+
const onRowPressRef = useRef(onRowPress);
|
|
39
|
+
onRowPressRef.current = onRowPress;
|
|
40
|
+
|
|
41
|
+
const stableOnRowPress = useCallback((rowIndex: number) => {
|
|
42
|
+
onRowPressRef.current?.(rowIndex);
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<PerpDepthBarsHost
|
|
47
|
+
{...props}
|
|
48
|
+
onRowPress={onRowPress ? callback(stableOnRowPress) : undefined}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
27
53
|
export const PerpSideRatioView = getHostComponent<
|
|
28
54
|
PerpSideRatioProps,
|
|
29
55
|
PerpSideRatioMethods
|