@onekeyfe/react-native-perp-depth-bar 3.0.43 → 3.0.45
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.
|
@@ -14,12 +14,11 @@ import kotlin.math.exp
|
|
|
14
14
|
* Renders an entire column of order-book depth bars for one side. Draws N rects
|
|
15
15
|
* whose horizontal fill fraction is eased on the UI thread.
|
|
16
16
|
*
|
|
17
|
-
* Animation model: a
|
|
18
|
-
*
|
|
19
|
-
* data just retargets — the loop keeps gliding and only stops once every row
|
|
20
|
-
* settled. Updates
|
|
21
|
-
*
|
|
22
|
-
* coin/tick switch snaps, via `epoch`).
|
|
17
|
+
* Animation model: a [Choreographer] frame loop continuously eases every row's
|
|
18
|
+
* on-screen fill toward its latest target (short fixed exponential smoothing).
|
|
19
|
+
* New data just retargets — the loop keeps gliding and only stops once every row
|
|
20
|
+
* has settled. Updates chain into continuous motion and a fluctuating row count
|
|
21
|
+
* no longer freezes the column (only a coin/tick switch snaps, via `epoch`).
|
|
23
22
|
*/
|
|
24
23
|
@DoNotStrip
|
|
25
24
|
class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBarsSpec() {
|
|
@@ -36,11 +35,10 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
|
|
|
36
35
|
private var hasDrawn = false
|
|
37
36
|
private var isDisposed = false
|
|
38
37
|
|
|
39
|
-
// Continuous-easing frame loop.
|
|
40
38
|
private val choreographer = Choreographer.getInstance()
|
|
41
39
|
private var frameScheduled = false
|
|
42
40
|
private var lastFrameNanos = 0L
|
|
43
|
-
private val frameCallback = Choreographer.FrameCallback {
|
|
41
|
+
private val frameCallback = Choreographer.FrameCallback { onFrame(it) }
|
|
44
42
|
|
|
45
43
|
override val view: View = object : View(context) {
|
|
46
44
|
override fun onDraw(canvas: Canvas) {
|
|
@@ -84,6 +82,7 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
|
|
|
84
82
|
get() = field
|
|
85
83
|
set(value) { if (!isDisposed) { field = value; view.invalidate() } }
|
|
86
84
|
|
|
85
|
+
/** Kept for OS "reduce motion" accessibility only — NOT a caller on/off knob. */
|
|
87
86
|
override var reducedMotion: Boolean = false
|
|
88
87
|
get() = field
|
|
89
88
|
set(value) { field = value }
|
|
@@ -191,8 +190,7 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
|
|
|
191
190
|
// Keep existing rows easing; brand-new rows appear at their target (no
|
|
192
191
|
// grow-from-zero flash). Then retarget and let the frame loop glide.
|
|
193
192
|
if (current.size != count) {
|
|
194
|
-
|
|
195
|
-
current = resized
|
|
193
|
+
current = DoubleArray(count) { i -> if (i < current.size) current[i] else newTarget[i] }
|
|
196
194
|
}
|
|
197
195
|
target = newTarget
|
|
198
196
|
lastEpoch = epoch
|
|
@@ -303,8 +301,7 @@ class HybridPerpDepthBars(val context: ThemedReactContext) : HybridPerpDepthBars
|
|
|
303
301
|
companion object {
|
|
304
302
|
/**
|
|
305
303
|
* Exponential-smoothing time constant (seconds); mirror of
|
|
306
|
-
* PerpTiming.depthBarSmoothingTauSeconds on iOS.
|
|
307
|
-
* in TAU, ~95% in 3*TAU.
|
|
304
|
+
* PerpTiming.depthBarSmoothingTauSeconds on iOS.
|
|
308
305
|
*/
|
|
309
306
|
private const val TAU_SECONDS = 0.10
|
|
310
307
|
}
|
|
@@ -13,9 +13,9 @@ import kotlin.math.exp
|
|
|
13
13
|
/**
|
|
14
14
|
* Two horizontal segments whose widths ease to the bid/ask ratio.
|
|
15
15
|
*
|
|
16
|
-
* Animation model mirrors the depth bars: a
|
|
17
|
-
* continuously eases the split fraction toward its latest target (
|
|
18
|
-
* smoothing). New data just retargets; the loop stops once settled.
|
|
16
|
+
* Animation model mirrors the depth bars: a [Choreographer] frame loop
|
|
17
|
+
* continuously eases the split fraction toward its latest target (short fixed
|
|
18
|
+
* exponential smoothing). New data just retargets; the loop stops once settled.
|
|
19
19
|
*/
|
|
20
20
|
@DoNotStrip
|
|
21
21
|
class HybridPerpSideRatio(val context: ThemedReactContext) : HybridPerpSideRatioSpec() {
|
|
@@ -30,11 +30,10 @@ class HybridPerpSideRatio(val context: ThemedReactContext) : HybridPerpSideRatio
|
|
|
30
30
|
private var hasDrawn = false
|
|
31
31
|
private var isDisposed = false
|
|
32
32
|
|
|
33
|
-
// Continuous-easing frame loop.
|
|
34
33
|
private val choreographer = Choreographer.getInstance()
|
|
35
34
|
private var frameScheduled = false
|
|
36
35
|
private var lastFrameNanos = 0L
|
|
37
|
-
private val frameCallback = Choreographer.FrameCallback {
|
|
36
|
+
private val frameCallback = Choreographer.FrameCallback { onFrame(it) }
|
|
38
37
|
|
|
39
38
|
override val view: View = object : View(context) {
|
|
40
39
|
override fun onDraw(canvas: Canvas) {
|
|
@@ -65,6 +64,7 @@ class HybridPerpSideRatio(val context: ThemedReactContext) : HybridPerpSideRatio
|
|
|
65
64
|
get() = field
|
|
66
65
|
set(value) { if (!isDisposed) { field = value; view.invalidate() } }
|
|
67
66
|
|
|
67
|
+
/** Kept for OS "reduce motion" accessibility only — NOT a caller on/off knob. */
|
|
68
68
|
override var reducedMotion: Boolean = false
|
|
69
69
|
get() = field
|
|
70
70
|
set(value) { field = value }
|
|
@@ -6,11 +6,12 @@ import UIKit
|
|
|
6
6
|
/// thread, replacing N reanimated `DepthBar` instances.
|
|
7
7
|
///
|
|
8
8
|
/// Animation model: a single `CADisplayLink` continuously eases every row's
|
|
9
|
-
/// on-screen scale toward its latest target (exponential smoothing
|
|
10
|
-
/// just retargets — the link keeps gliding and only
|
|
11
|
-
/// settled.
|
|
12
|
-
///
|
|
13
|
-
/// coin/tick switch snaps, via `epoch`).
|
|
9
|
+
/// on-screen scale toward its latest target (short fixed exponential smoothing,
|
|
10
|
+
/// `tau ≈ 0.1s`). New data just retargets — the link keeps gliding and only
|
|
11
|
+
/// stops once every row has settled. Updates therefore chain into continuous
|
|
12
|
+
/// motion, and a fluctuating row count no longer freezes the column (only a
|
|
13
|
+
/// coin/tick switch snaps, via `epoch`). Tracks the per-row text closely so the
|
|
14
|
+
/// bar and the price/size labels stay in agreement.
|
|
14
15
|
final class HybridPerpDepthBars: HybridPerpDepthBarsSpec {
|
|
15
16
|
|
|
16
17
|
// MARK: - HybridView
|
|
@@ -40,6 +41,8 @@ final class HybridPerpDepthBars: HybridPerpDepthBarsSpec {
|
|
|
40
41
|
var rowMarginTop: Double = 0 { didSet { scheduleLayout() } }
|
|
41
42
|
var barInset: Double = 0 { didSet { scheduleLayout() } }
|
|
42
43
|
var origin: String = "left" { didSet { scheduleLayout() } }
|
|
44
|
+
/// Kept for OS "reduce motion" accessibility only — NOT a caller on/off knob.
|
|
45
|
+
/// Depth bars animate by default; callers don't pass anything to enable it.
|
|
43
46
|
var reducedMotion: Bool = false { didSet { scheduleLayout() } }
|
|
44
47
|
var epoch: Double = 0 { didSet { scheduleLayout() } }
|
|
45
48
|
|
|
@@ -114,8 +117,6 @@ final class HybridPerpDepthBars: HybridPerpDepthBarsSpec {
|
|
|
114
117
|
syncLayerCount(count)
|
|
115
118
|
syncTextLayerCount(count)
|
|
116
119
|
|
|
117
|
-
// Only a coin/tick switch (or reduced motion / first paint) snaps. A
|
|
118
|
-
// fluctuating row count no longer freezes the whole column — see below.
|
|
119
120
|
let epochChanged = epoch != lastEpoch
|
|
120
121
|
let snap = !hasLaidOut || reducedMotion || epochChanged
|
|
121
122
|
|
|
@@ -3,9 +3,9 @@ import UIKit
|
|
|
3
3
|
|
|
4
4
|
/// Two horizontal segments whose widths ease to the bid/ask ratio.
|
|
5
5
|
///
|
|
6
|
-
/// Animation model mirrors the depth bars: a
|
|
7
|
-
///
|
|
8
|
-
/// New data just retargets
|
|
6
|
+
/// Animation model mirrors the depth bars: a `CADisplayLink` continuously eases
|
|
7
|
+
/// the split fraction toward its latest target (short fixed exponential
|
|
8
|
+
/// smoothing). New data just retargets; the link stops once settled.
|
|
9
9
|
final class HybridPerpSideRatio: HybridPerpSideRatioSpec {
|
|
10
10
|
|
|
11
11
|
// MARK: - HybridView
|
|
@@ -27,6 +27,7 @@ final class HybridPerpSideRatio: HybridPerpSideRatioSpec {
|
|
|
27
27
|
var segmentHeight: Double = 4 { didSet { scheduleLayout() } }
|
|
28
28
|
var cornerRadius: Double = 999 { didSet { scheduleLayout() } }
|
|
29
29
|
var gap: Double = 2 { didSet { scheduleLayout() } }
|
|
30
|
+
/// Kept for OS "reduce motion" accessibility only — NOT a caller on/off knob.
|
|
30
31
|
var reducedMotion: Bool = false { didSet { scheduleLayout() } }
|
|
31
32
|
|
|
32
33
|
var longColor: String = "" {
|