@onekeyfe/react-native-perp-depth-bar 3.0.39 → 3.0.42

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 (72) hide show
  1. package/android/src/main/java/com/margelo/nitro/perpdepthbar/HybridPerpDepthBars.kt +100 -1
  2. package/ios/HybridPerpDepthBars.swift +97 -1
  3. package/ios/PerpColorParser.swift +8 -0
  4. package/lib/module/index.js +25 -2
  5. package/lib/module/index.js.map +1 -1
  6. package/lib/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  7. package/lib/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +120 -0
  8. package/lib/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +16 -0
  9. package/lib/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +32 -0
  10. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/Func_void_double.kt +80 -0
  11. package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +56 -0
  12. package/lib/nitrogen/generated/android/perpdepthbarOnLoad.cpp +2 -0
  13. package/lib/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.cpp +8 -0
  14. package/lib/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.hpp +51 -0
  15. package/lib/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Umbrella.hpp +2 -0
  16. package/lib/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +55 -0
  17. package/lib/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +40 -0
  18. package/lib/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  19. package/lib/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +8 -0
  20. package/lib/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +121 -0
  21. package/lib/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +16 -0
  22. package/lib/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +18 -0
  23. package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +96 -0
  24. package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +10 -2
  25. package/lib/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +8 -0
  26. package/lib/nitrogen/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  27. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +120 -0
  28. package/lib/nitrogen/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +16 -0
  29. package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +32 -0
  30. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/Func_void_double.kt +80 -0
  31. package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +56 -0
  32. package/lib/nitrogen/nitrogen/generated/android/perpdepthbarOnLoad.cpp +2 -0
  33. package/lib/nitrogen/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.cpp +8 -0
  34. package/lib/nitrogen/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.hpp +51 -0
  35. package/lib/nitrogen/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Umbrella.hpp +2 -0
  36. package/lib/nitrogen/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +55 -0
  37. package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +40 -0
  38. package/lib/nitrogen/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  39. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +8 -0
  40. package/lib/nitrogen/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +121 -0
  41. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +16 -0
  42. package/lib/nitrogen/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +18 -0
  43. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +96 -0
  44. package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +10 -2
  45. package/lib/nitrogen/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +8 -0
  46. package/lib/typescript/src/PerpDepthBars.nitro.d.ts +20 -0
  47. package/lib/typescript/src/PerpDepthBars.nitro.d.ts.map +1 -1
  48. package/lib/typescript/src/index.d.ts +7 -1
  49. package/lib/typescript/src/index.d.ts.map +1 -1
  50. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  51. package/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.cpp +120 -0
  52. package/nitrogen/generated/android/c++/JHybridPerpDepthBarsSpec.hpp +16 -0
  53. package/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +32 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/Func_void_double.kt +80 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/HybridPerpDepthBarsSpec.kt +56 -0
  56. package/nitrogen/generated/android/perpdepthbarOnLoad.cpp +2 -0
  57. package/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.cpp +8 -0
  58. package/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Bridge.hpp +51 -0
  59. package/nitrogen/generated/ios/PerpDepthBar-Swift-Cxx-Umbrella.hpp +2 -0
  60. package/nitrogen/generated/ios/c++/HybridPerpDepthBarsSpecSwift.hpp +55 -0
  61. package/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +40 -0
  62. package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
  63. package/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec.swift +8 -0
  64. package/nitrogen/generated/ios/swift/HybridPerpDepthBarsSpec_cxx.swift +121 -0
  65. package/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.cpp +16 -0
  66. package/nitrogen/generated/shared/c++/HybridPerpDepthBarsSpec.hpp +18 -0
  67. package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +96 -0
  68. package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +10 -2
  69. package/nitrogen/generated/shared/json/PerpDepthBarsConfig.json +8 -0
  70. package/package.json +1 -1
  71. package/src/PerpDepthBars.nitro.ts +27 -0
  72. package/src/index.tsx +28 -2
@@ -3,6 +3,7 @@ package com.margelo.nitro.perpdepthbar
3
3
  import android.animation.ValueAnimator
4
4
  import android.graphics.Canvas
5
5
  import android.graphics.Paint
6
+ import android.view.MotionEvent
6
7
  import android.view.View
7
8
  import android.view.animation.PathInterpolator
8
9
  import com.facebook.proguard.annotations.DoNotStrip
@@ -18,6 +19,8 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
18
19
 
19
20
  private val density = context.resources.displayMetrics.density
20
21
  private val paint = Paint(Paint.ANTI_ALIAS_FLAG)
22
+ private val pricePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { textAlign = Paint.Align.LEFT }
23
+ private val sizePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { textAlign = Paint.Align.RIGHT }
21
24
 
22
25
  private var current = DoubleArray(0)
23
26
  private var start = DoubleArray(0)
@@ -31,9 +34,21 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
31
34
  override val view: View = object : View(context) {
32
35
  override fun onDraw(canvas: Canvas) {
33
36
  drawBars(canvas)
37
+ drawTexts(canvas)
38
+ }
39
+
40
+ override fun onTouchEvent(event: MotionEvent): Boolean {
41
+ when (event.action) {
42
+ MotionEvent.ACTION_DOWN -> return true // claim the gesture
43
+ MotionEvent.ACTION_UP -> {
44
+ handleTap(event.y)
45
+ return true
46
+ }
47
+ }
48
+ return super.onTouchEvent(event)
34
49
  }
35
50
  }.apply {
36
- isClickable = false
51
+ isClickable = true
37
52
  isFocusable = false
38
53
  }
39
54
 
@@ -75,6 +90,67 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
75
90
  view.invalidate()
76
91
  }
77
92
 
93
+ // MARK: - Text props
94
+ override var prices: Array<String> = emptyArray()
95
+ get() = field
96
+ set(value) { if (!isDisposed) { field = value; view.invalidate() } }
97
+
98
+ override var sizes: Array<String> = emptyArray()
99
+ get() = field
100
+ set(value) { if (!isDisposed) { field = value; view.invalidate() } }
101
+
102
+ override var priceColor: String = ""
103
+ get() = field
104
+ set(value) {
105
+ if (isDisposed) return
106
+ field = value
107
+ pricePaint.color = PerpColorParser.parse(value)
108
+ view.invalidate()
109
+ }
110
+
111
+ override var sizeColor: String = ""
112
+ get() = field
113
+ set(value) {
114
+ if (isDisposed) return
115
+ field = value
116
+ sizePaint.color = PerpColorParser.parse(value)
117
+ view.invalidate()
118
+ }
119
+
120
+ override var priceFontSize: Double = 11.0
121
+ get() = field
122
+ set(value) {
123
+ if (isDisposed) return
124
+ field = value
125
+ pricePaint.textSize = (value * density).toFloat()
126
+ view.invalidate()
127
+ }
128
+
129
+ override var sizeFontSize: Double = 11.0
130
+ get() = field
131
+ set(value) {
132
+ if (isDisposed) return
133
+ field = value
134
+ sizePaint.textSize = (value * density).toFloat()
135
+ view.invalidate()
136
+ }
137
+
138
+ override var textInset: Double = 0.0
139
+ get() = field
140
+ set(value) { if (!isDisposed) { field = value; view.invalidate() } }
141
+
142
+ override var onRowPress: ((rowIndex: Double) -> Unit)? = null
143
+
144
+ private fun handleTap(y: Float) {
145
+ if (isDisposed) return
146
+ val step = ((rowHeight + rowMarginTop) * density).toFloat()
147
+ if (step <= 0f) return
148
+ val mt = (rowMarginTop * density).toFloat()
149
+ val i = ((y - mt) / step).toInt()
150
+ val count = maxOf(percents.size, maxOf(prices.size, sizes.size))
151
+ if (i in 0 until count) onRowPress?.invoke(i.toDouble())
152
+ }
153
+
78
154
  /**
79
155
  * Called by Nitro once after a prop-update transaction. Recompute targets and
80
156
  * (re)start the animation here so a multi-prop update animates once.
@@ -148,6 +224,29 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
148
224
  }
149
225
  }
150
226
 
227
+ private fun drawTexts(canvas: Canvas) {
228
+ if (prices.isEmpty() && sizes.isEmpty()) return
229
+ val w = view.width.toFloat()
230
+ if (w <= 0f) return
231
+ val rh = (rowHeight * density).toFloat()
232
+ val mt = (rowMarginTop * density).toFloat()
233
+ val pad = (textInset * density).toFloat()
234
+ val rightX = w - pad
235
+ val rows = maxOf(prices.size, sizes.size)
236
+ for (i in 0 until rows) {
237
+ val rowTop = mt + i * (rh + mt)
238
+ // Vertically center single-line text within the row.
239
+ if (i < prices.size && prices[i].isNotEmpty()) {
240
+ val baseline = rowTop + rh / 2f - (pricePaint.descent() + pricePaint.ascent()) / 2f
241
+ canvas.drawText(prices[i], pad, baseline, pricePaint)
242
+ }
243
+ if (i < sizes.size && sizes[i].isNotEmpty()) {
244
+ val baseline = rowTop + rh / 2f - (sizePaint.descent() + sizePaint.ascent()) / 2f
245
+ canvas.drawText(sizes[i], rightX, baseline, sizePaint)
246
+ }
247
+ }
248
+ }
249
+
151
250
  private fun clampFrac(percent: Double): Double =
152
251
  (percent.coerceIn(0.0, 100.0)) / 100.0
153
252
 
@@ -12,6 +12,11 @@ final class HybridPerpDepthBars: HybridPerpDepthBarsSpec {
12
12
  // MARK: - Per-row fill layers
13
13
  private var barLayers: [CALayer] = []
14
14
 
15
+ // MARK: - Per-row text layers (price left, size right)
16
+ private var priceLayers: [CATextLayer] = []
17
+ private var sizeLayers: [CATextLayer] = []
18
+ private let textScale = UIScreen.main.scale
19
+
15
20
  // MARK: - State for animation decisions
16
21
  private var lastPercents: [Double] = []
17
22
  private var lastEpoch: Double = .nan
@@ -34,13 +39,49 @@ final class HybridPerpDepthBars: HybridPerpDepthBarsSpec {
34
39
  }
35
40
  private var cachedColor: CGColor = UIColor.clear.cgColor
36
41
 
42
+ // MARK: - Text props
43
+ var prices: [String] = [] { didSet { scheduleLayout() } }
44
+ var sizes: [String] = [] { didSet { scheduleLayout() } }
45
+ var priceFontSize: Double = 11 { didSet { scheduleLayout() } }
46
+ var sizeFontSize: Double = 11 { didSet { scheduleLayout() } }
47
+ var textInset: Double = 0 { didSet { scheduleLayout() } }
48
+
49
+ var priceColor: String = "" {
50
+ didSet {
51
+ cachedPriceColor = PerpColorParser.parse(priceColor).cgColor
52
+ scheduleLayout()
53
+ }
54
+ }
55
+ var sizeColor: String = "" {
56
+ didSet {
57
+ cachedSizeColor = PerpColorParser.parse(sizeColor).cgColor
58
+ scheduleLayout()
59
+ }
60
+ }
61
+ private var cachedPriceColor: CGColor = UIColor.black.cgColor
62
+ private var cachedSizeColor: CGColor = UIColor.gray.cgColor
63
+
64
+ // MARK: - Tap callback (native row hit-testing)
65
+ var onRowPress: ((Double) -> Void)?
66
+
37
67
  // MARK: - Init
38
68
  override init() {
39
69
  super.init()
40
- view.isUserInteractionEnabled = false // taps handled by RN overlay
70
+ view.isUserInteractionEnabled = true // native row tap handling
41
71
  view.clipsToBounds = true
42
72
  if let layoutView = view as? PerpLayoutView {
43
73
  layoutView.onLayout = { [weak self] in self?.performLayout() }
74
+ layoutView.onTap = { [weak self] y in self?.handleTap(atY: y) }
75
+ }
76
+ }
77
+
78
+ private func handleTap(atY y: CGFloat) {
79
+ let step = CGFloat(rowHeight + rowMarginTop)
80
+ guard step > 0 else { return }
81
+ let i = Int((y - CGFloat(rowMarginTop)) / step)
82
+ let count = max(percents.count, max(prices.count, sizes.count))
83
+ if i >= 0 && i < count {
84
+ onRowPress?(Double(i))
44
85
  }
45
86
  }
46
87
 
@@ -55,6 +96,7 @@ final class HybridPerpDepthBars: HybridPerpDepthBarsSpec {
55
96
 
56
97
  let count = percents.count
57
98
  syncLayerCount(count)
99
+ syncTextLayerCount(count)
58
100
 
59
101
  // Decide whether this update should animate or snap.
60
102
  let epochChanged = epoch != lastEpoch
@@ -94,11 +136,65 @@ final class HybridPerpDepthBars: HybridPerpDepthBarsSpec {
94
136
 
95
137
  CATransaction.commit()
96
138
 
139
+ // Text never animates — snap frames/strings each layout pass.
140
+ CATransaction.begin()
141
+ CATransaction.setDisableActions(true)
142
+ let half = rowW / 2
143
+ let pad = CGFloat(textInset)
144
+ for i in 0..<count {
145
+ let rowTop = CGFloat(rowMarginTop) + CGFloat(i) * (h + CGFloat(rowMarginTop))
146
+ let priceLine = CGFloat(priceFontSize) * 1.16
147
+ let sizeLine = CGFloat(sizeFontSize) * 1.16
148
+ let priceLayer = priceLayers[i]
149
+ priceLayer.frame = CGRect(
150
+ x: pad, y: rowTop + (h - priceLine) / 2,
151
+ width: max(half - pad, 0), height: priceLine)
152
+ priceLayer.fontSize = CGFloat(priceFontSize)
153
+ priceLayer.foregroundColor = cachedPriceColor
154
+ priceLayer.string = i < prices.count ? prices[i] : ""
155
+
156
+ let sizeLayer = sizeLayers[i]
157
+ sizeLayer.frame = CGRect(
158
+ x: half, y: rowTop + (h - sizeLine) / 2,
159
+ width: max(half - pad, 0), height: sizeLine)
160
+ sizeLayer.fontSize = CGFloat(sizeFontSize)
161
+ sizeLayer.foregroundColor = cachedSizeColor
162
+ sizeLayer.string = i < sizes.count ? sizes[i] : ""
163
+ }
164
+ CATransaction.commit()
165
+
97
166
  lastPercents = percents
98
167
  lastEpoch = epoch
99
168
  hasLaidOut = true
100
169
  }
101
170
 
171
+ private func makeTextLayer(alignment: CATextLayerAlignmentMode) -> CATextLayer {
172
+ let l = CATextLayer()
173
+ l.contentsScale = textScale
174
+ l.alignmentMode = alignment
175
+ l.truncationMode = .none
176
+ l.isWrapped = false
177
+ return l
178
+ }
179
+
180
+ private func syncTextLayerCount(_ count: Int) {
181
+ if priceLayers.count < count {
182
+ for _ in priceLayers.count..<count {
183
+ let p = makeTextLayer(alignment: .left)
184
+ let s = makeTextLayer(alignment: .right)
185
+ view.layer.addSublayer(p)
186
+ view.layer.addSublayer(s)
187
+ priceLayers.append(p)
188
+ sizeLayers.append(s)
189
+ }
190
+ } else if priceLayers.count > count {
191
+ for l in priceLayers[count...] { l.removeFromSuperlayer() }
192
+ for l in sizeLayers[count...] { l.removeFromSuperlayer() }
193
+ priceLayers.removeLast(priceLayers.count - count)
194
+ sizeLayers.removeLast(sizeLayers.count - count)
195
+ }
196
+ }
197
+
102
198
  private func animateScaleX(layer: CALayer, to target: CGFloat) {
103
199
  // Continue from the on-screen (presentation) value to avoid snap-back when
104
200
  // a new animation starts every tick (~10Hz).
@@ -84,9 +84,17 @@ enum PerpTiming {
84
84
  /// HybridView can re-lay-out its CALayers when bounds change.
85
85
  final class PerpLayoutView: UIView {
86
86
  var onLayout: (() -> Void)?
87
+ /// Native tap handler — receives the tap's y in view coordinates (points).
88
+ var onTap: ((CGFloat) -> Void)?
87
89
 
88
90
  override func layoutSubviews() {
89
91
  super.layoutSubviews()
90
92
  onLayout?()
91
93
  }
94
+
95
+ override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
96
+ super.touchesEnded(touches, with: event)
97
+ guard let onTap, let touch = touches.first else { return }
98
+ onTap(touch.location(in: self).y)
99
+ }
92
100
  }
@@ -1,8 +1,31 @@
1
1
  "use strict";
2
2
 
3
- import { getHostComponent } from 'react-native-nitro-modules';
3
+ import { useCallback, useRef } from 'react';
4
+ import { callback, getHostComponent } from 'react-native-nitro-modules';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
4
6
  const PerpDepthBarsConfig = require('../nitrogen/generated/shared/json/PerpDepthBarsConfig.json');
5
7
  const PerpSideRatioConfig = require('../nitrogen/generated/shared/json/PerpSideRatioConfig.json');
6
- export const PerpDepthBarsView = getHostComponent('PerpDepthBars', () => PerpDepthBarsConfig);
8
+ const PerpDepthBarsHost = getHostComponent('PerpDepthBars', () => PerpDepthBarsConfig);
9
+
10
+ /**
11
+ * Thin wrapper so consumers pass a plain `onRowPress` function. Nitro view
12
+ * callbacks must be wrapped with `callback(...)` to cross the JSI boundary;
13
+ * we encapsulate that here (with a ref so the underlying callback stays
14
+ * stable across re-renders) instead of leaking it to every call site.
15
+ */
16
+ export function PerpDepthBarsView({
17
+ onRowPress,
18
+ ...props
19
+ }) {
20
+ const onRowPressRef = useRef(onRowPress);
21
+ onRowPressRef.current = onRowPress;
22
+ const stableOnRowPress = useCallback(rowIndex => {
23
+ onRowPressRef.current?.(rowIndex);
24
+ }, []);
25
+ return /*#__PURE__*/_jsx(PerpDepthBarsHost, {
26
+ ...props,
27
+ onRowPress: onRowPress ? callback(stableOnRowPress) : undefined
28
+ });
29
+ }
7
30
  export const PerpSideRatioView = getHostComponent('PerpSideRatio', () => PerpSideRatioConfig);
8
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getHostComponent","PerpDepthBarsConfig","require","PerpSideRatioConfig","PerpDepthBarsView","PerpSideRatioView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,4BAA4B;AAW7D,MAAMC,mBAAmB,GAAGC,OAAO,CAAC,4DAA4D,CAAC;AACjG,MAAMC,mBAAmB,GAAGD,OAAO,CAAC,4DAA4D,CAAC;AASjG,OAAO,MAAME,iBAAiB,GAAGJ,gBAAgB,CAG/C,eAAe,EAAE,MAAMC,mBAAmB,CAAC;AAE7C,OAAO,MAAMI,iBAAiB,GAAGL,gBAAgB,CAG/C,eAAe,EAAE,MAAMG,mBAAmB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useRef","callback","getHostComponent","jsx","_jsx","PerpDepthBarsConfig","require","PerpSideRatioConfig","PerpDepthBarsHost","PerpDepthBarsView","onRowPress","props","onRowPressRef","current","stableOnRowPress","rowIndex","undefined","PerpSideRatioView"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAC3C,SAASC,QAAQ,EAAEC,gBAAgB,QAAQ,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAWxE,MAAMC,mBAAmB,GAAGC,OAAO,CAAC,4DAA4D,CAAC;AACjG,MAAMC,mBAAmB,GAAGD,OAAO,CAAC,4DAA4D,CAAC;AASjG,MAAME,iBAAiB,GAAGN,gBAAgB,CAGxC,eAAe,EAAE,MAAMG,mBAAmB,CAAC;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,iBAAiBA,CAAC;EAChCC,UAAU;EACV,GAAGC;AACe,CAAC,EAAE;EACrB,MAAMC,aAAa,GAAGZ,MAAM,CAACU,UAAU,CAAC;EACxCE,aAAa,CAACC,OAAO,GAAGH,UAAU;EAElC,MAAMI,gBAAgB,GAAGf,WAAW,CAAEgB,QAAgB,IAAK;IACzDH,aAAa,CAACC,OAAO,GAAGE,QAAQ,CAAC;EACnC,CAAC,EAAE,EAAE,CAAC;EAEN,oBACEX,IAAA,CAACI,iBAAiB;IAAA,GACZG,KAAK;IACTD,UAAU,EAAEA,UAAU,GAAGT,QAAQ,CAACa,gBAAgB,CAAC,GAAGE;EAAU,CACjE,CAAC;AAEN;AAEA,OAAO,MAAMC,iBAAiB,GAAGf,gBAAgB,CAG/C,eAAe,EAAE,MAAMK,mBAAmB,CAAC","ignoreList":[]}
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// JFunc_void_double.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include <functional>
12
+
13
+ #include <functional>
14
+ #include <NitroModules/JNICallable.hpp>
15
+
16
+ namespace margelo::nitro::perpdepthbar {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * Represents the Java/Kotlin callback `(rowIndex: Double) -> Unit`.
22
+ * This can be passed around between C++ and Java/Kotlin.
23
+ */
24
+ struct JFunc_void_double: public jni::JavaClass<JFunc_void_double> {
25
+ public:
26
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/perpdepthbar/Func_void_double;";
27
+
28
+ public:
29
+ /**
30
+ * Invokes the function this `JFunc_void_double` instance holds through JNI.
31
+ */
32
+ void invoke(double rowIndex) const {
33
+ static const auto method = javaClassStatic()->getMethod<void(double /* rowIndex */)>("invoke");
34
+ method(self(), rowIndex);
35
+ }
36
+ };
37
+
38
+ /**
39
+ * An implementation of Func_void_double that is backed by a C++ implementation (using `std::function<...>`)
40
+ */
41
+ class JFunc_void_double_cxx final: public jni::HybridClass<JFunc_void_double_cxx, JFunc_void_double> {
42
+ public:
43
+ static jni::local_ref<JFunc_void_double::javaobject> fromCpp(const std::function<void(double /* rowIndex */)>& func) {
44
+ return JFunc_void_double_cxx::newObjectCxxArgs(func);
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Invokes the C++ `std::function<...>` this `JFunc_void_double_cxx` instance holds.
50
+ */
51
+ void invoke_cxx(double rowIndex) {
52
+ _func(rowIndex);
53
+ }
54
+
55
+ public:
56
+ [[nodiscard]]
57
+ inline const std::function<void(double /* rowIndex */)>& getFunction() const {
58
+ return _func;
59
+ }
60
+
61
+ public:
62
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/perpdepthbar/Func_void_double_cxx;";
63
+ static void registerNatives() {
64
+ registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_cxx::invoke_cxx)});
65
+ }
66
+
67
+ private:
68
+ explicit JFunc_void_double_cxx(const std::function<void(double /* rowIndex */)>& func): _func(func) { }
69
+
70
+ private:
71
+ friend HybridBase;
72
+ std::function<void(double /* rowIndex */)> _func;
73
+ };
74
+
75
+ } // namespace margelo::nitro::perpdepthbar
@@ -11,6 +11,10 @@
11
11
 
12
12
  #include <vector>
13
13
  #include <string>
14
+ #include <functional>
15
+ #include <optional>
16
+ #include "JFunc_void_double.hpp"
17
+ #include <NitroModules/JNICallable.hpp>
14
18
 
15
19
  namespace margelo::nitro::perpdepthbar {
16
20
 
@@ -123,6 +127,122 @@ namespace margelo::nitro::perpdepthbar {
123
127
  static const auto method = javaClassStatic()->getMethod<void(double /* epoch */)>("setEpoch");
124
128
  method(_javaPart, epoch);
125
129
  }
130
+ std::vector<std::string> JHybridPerpDepthBarsSpec::getPrices() {
131
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<jni::JString>>()>("getPrices");
132
+ auto __result = method(_javaPart);
133
+ return [&]() {
134
+ size_t __size = __result->size();
135
+ std::vector<std::string> __vector;
136
+ __vector.reserve(__size);
137
+ for (size_t __i = 0; __i < __size; __i++) {
138
+ auto __element = __result->getElement(__i);
139
+ __vector.push_back(__element->toStdString());
140
+ }
141
+ return __vector;
142
+ }();
143
+ }
144
+ void JHybridPerpDepthBarsSpec::setPrices(const std::vector<std::string>& prices) {
145
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<jni::JString>> /* prices */)>("setPrices");
146
+ method(_javaPart, [&]() {
147
+ size_t __size = prices.size();
148
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
149
+ for (size_t __i = 0; __i < __size; __i++) {
150
+ const auto& __element = prices[__i];
151
+ auto __elementJni = jni::make_jstring(__element);
152
+ __array->setElement(__i, *__elementJni);
153
+ }
154
+ return __array;
155
+ }());
156
+ }
157
+ std::vector<std::string> JHybridPerpDepthBarsSpec::getSizes() {
158
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<jni::JString>>()>("getSizes");
159
+ auto __result = method(_javaPart);
160
+ return [&]() {
161
+ size_t __size = __result->size();
162
+ std::vector<std::string> __vector;
163
+ __vector.reserve(__size);
164
+ for (size_t __i = 0; __i < __size; __i++) {
165
+ auto __element = __result->getElement(__i);
166
+ __vector.push_back(__element->toStdString());
167
+ }
168
+ return __vector;
169
+ }();
170
+ }
171
+ void JHybridPerpDepthBarsSpec::setSizes(const std::vector<std::string>& sizes) {
172
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<jni::JString>> /* sizes */)>("setSizes");
173
+ method(_javaPart, [&]() {
174
+ size_t __size = sizes.size();
175
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
176
+ for (size_t __i = 0; __i < __size; __i++) {
177
+ const auto& __element = sizes[__i];
178
+ auto __elementJni = jni::make_jstring(__element);
179
+ __array->setElement(__i, *__elementJni);
180
+ }
181
+ return __array;
182
+ }());
183
+ }
184
+ std::string JHybridPerpDepthBarsSpec::getPriceColor() {
185
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getPriceColor");
186
+ auto __result = method(_javaPart);
187
+ return __result->toStdString();
188
+ }
189
+ void JHybridPerpDepthBarsSpec::setPriceColor(const std::string& priceColor) {
190
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* priceColor */)>("setPriceColor");
191
+ method(_javaPart, jni::make_jstring(priceColor));
192
+ }
193
+ std::string JHybridPerpDepthBarsSpec::getSizeColor() {
194
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getSizeColor");
195
+ auto __result = method(_javaPart);
196
+ return __result->toStdString();
197
+ }
198
+ void JHybridPerpDepthBarsSpec::setSizeColor(const std::string& sizeColor) {
199
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* sizeColor */)>("setSizeColor");
200
+ method(_javaPart, jni::make_jstring(sizeColor));
201
+ }
202
+ double JHybridPerpDepthBarsSpec::getPriceFontSize() {
203
+ static const auto method = javaClassStatic()->getMethod<double()>("getPriceFontSize");
204
+ auto __result = method(_javaPart);
205
+ return __result;
206
+ }
207
+ void JHybridPerpDepthBarsSpec::setPriceFontSize(double priceFontSize) {
208
+ static const auto method = javaClassStatic()->getMethod<void(double /* priceFontSize */)>("setPriceFontSize");
209
+ method(_javaPart, priceFontSize);
210
+ }
211
+ double JHybridPerpDepthBarsSpec::getSizeFontSize() {
212
+ static const auto method = javaClassStatic()->getMethod<double()>("getSizeFontSize");
213
+ auto __result = method(_javaPart);
214
+ return __result;
215
+ }
216
+ void JHybridPerpDepthBarsSpec::setSizeFontSize(double sizeFontSize) {
217
+ static const auto method = javaClassStatic()->getMethod<void(double /* sizeFontSize */)>("setSizeFontSize");
218
+ method(_javaPart, sizeFontSize);
219
+ }
220
+ double JHybridPerpDepthBarsSpec::getTextInset() {
221
+ static const auto method = javaClassStatic()->getMethod<double()>("getTextInset");
222
+ auto __result = method(_javaPart);
223
+ return __result;
224
+ }
225
+ void JHybridPerpDepthBarsSpec::setTextInset(double textInset) {
226
+ static const auto method = javaClassStatic()->getMethod<void(double /* textInset */)>("setTextInset");
227
+ method(_javaPart, textInset);
228
+ }
229
+ std::optional<std::function<void(double /* rowIndex */)>> JHybridPerpDepthBarsSpec::getOnRowPress() {
230
+ static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_double::javaobject>()>("getOnRowPress_cxx");
231
+ auto __result = method(_javaPart);
232
+ return __result != nullptr ? std::make_optional([&]() -> std::function<void(double /* rowIndex */)> {
233
+ if (__result->isInstanceOf(JFunc_void_double_cxx::javaClassStatic())) [[likely]] {
234
+ auto downcast = jni::static_ref_cast<JFunc_void_double_cxx::javaobject>(__result);
235
+ return downcast->cthis()->getFunction();
236
+ } else {
237
+ auto __resultRef = jni::make_global(__result);
238
+ return JNICallable<JFunc_void_double, void(double)>(std::move(__resultRef));
239
+ }
240
+ }()) : std::nullopt;
241
+ }
242
+ void JHybridPerpDepthBarsSpec::setOnRowPress(const std::optional<std::function<void(double /* rowIndex */)>>& onRowPress) {
243
+ static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_double::javaobject> /* onRowPress */)>("setOnRowPress_cxx");
244
+ method(_javaPart, onRowPress.has_value() ? JFunc_void_double_cxx::fromCpp(onRowPress.value()) : nullptr);
245
+ }
126
246
 
127
247
  // Methods
128
248
 
@@ -66,6 +66,22 @@ namespace margelo::nitro::perpdepthbar {
66
66
  void setReducedMotion(bool reducedMotion) override;
67
67
  double getEpoch() override;
68
68
  void setEpoch(double epoch) override;
69
+ std::vector<std::string> getPrices() override;
70
+ void setPrices(const std::vector<std::string>& prices) override;
71
+ std::vector<std::string> getSizes() override;
72
+ void setSizes(const std::vector<std::string>& sizes) override;
73
+ std::string getPriceColor() override;
74
+ void setPriceColor(const std::string& priceColor) override;
75
+ std::string getSizeColor() override;
76
+ void setSizeColor(const std::string& sizeColor) override;
77
+ double getPriceFontSize() override;
78
+ void setPriceFontSize(double priceFontSize) override;
79
+ double getSizeFontSize() override;
80
+ void setSizeFontSize(double sizeFontSize) override;
81
+ double getTextInset() override;
82
+ void setTextInset(double textInset) override;
83
+ std::optional<std::function<void(double /* rowIndex */)>> getOnRowPress() override;
84
+ void setOnRowPress(const std::optional<std::function<void(double /* rowIndex */)>>& onRowPress) override;
69
85
 
70
86
  public:
71
87
  // Methods
@@ -68,6 +68,38 @@ void JHybridPerpDepthBarsStateUpdater::updateViewProps(jni::alias_ref<jni::JClas
68
68
  view->setEpoch(props.epoch.value);
69
69
  // TODO: Set isDirty = false
70
70
  }
71
+ if (props.prices.isDirty) {
72
+ view->setPrices(props.prices.value);
73
+ // TODO: Set isDirty = false
74
+ }
75
+ if (props.sizes.isDirty) {
76
+ view->setSizes(props.sizes.value);
77
+ // TODO: Set isDirty = false
78
+ }
79
+ if (props.priceColor.isDirty) {
80
+ view->setPriceColor(props.priceColor.value);
81
+ // TODO: Set isDirty = false
82
+ }
83
+ if (props.sizeColor.isDirty) {
84
+ view->setSizeColor(props.sizeColor.value);
85
+ // TODO: Set isDirty = false
86
+ }
87
+ if (props.priceFontSize.isDirty) {
88
+ view->setPriceFontSize(props.priceFontSize.value);
89
+ // TODO: Set isDirty = false
90
+ }
91
+ if (props.sizeFontSize.isDirty) {
92
+ view->setSizeFontSize(props.sizeFontSize.value);
93
+ // TODO: Set isDirty = false
94
+ }
95
+ if (props.textInset.isDirty) {
96
+ view->setTextInset(props.textInset.value);
97
+ // TODO: Set isDirty = false
98
+ }
99
+ if (props.onRowPress.isDirty) {
100
+ view->setOnRowPress(props.onRowPress.value);
101
+ // TODO: Set isDirty = false
102
+ }
71
103
 
72
104
  // Update hybridRef if it changed
73
105
  if (props.hybridRef.isDirty) {
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void_double.kt
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
+ package com.margelo.nitro.perpdepthbar
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+
15
+
16
+ /**
17
+ * Represents the JavaScript callback `(rowIndex: number) => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void_double: (Double) -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(rowIndex: Double): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `(rowIndex: number) => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_double_cxx: Func_void_double {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(rowIndex: Double): Unit
60
+ = invoke_cxx(rowIndex)
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(rowIndex: Double): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `(rowIndex: number) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(Double) -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_double_java(private val function: (Double) -> Unit): Func_void_double {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(rowIndex: Double): Unit {
78
+ return this.function(rowIndex)
79
+ }
80
+ }