@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.
- package/lib/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +122 -87
- package/lib/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.hpp +6 -1
- package/lib/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.cpp +66 -41
- package/lib/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.hpp +6 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsManager.kt +26 -10
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsStateUpdater.kt +2 -2
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioManager.kt +26 -10
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioStateUpdater.kt +2 -2
- package/lib/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +146 -107
- package/lib/nitrogen/generated/ios/c++/views/HybridPerpSideRatioComponent.mm +86 -57
- package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +23 -225
- package/lib/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +74 -66
- package/lib/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.cpp +13 -125
- package/lib/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.hpp +44 -56
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +122 -87
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.hpp +6 -1
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.cpp +66 -41
- package/lib/nitrogen/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.hpp +6 -1
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsManager.kt +26 -10
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsStateUpdater.kt +2 -2
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioManager.kt +26 -10
- package/lib/nitrogen/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioStateUpdater.kt +2 -2
- package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +146 -107
- package/lib/nitrogen/nitrogen/generated/ios/c++/views/HybridPerpSideRatioComponent.mm +86 -57
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +23 -225
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +74 -66
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.cpp +13 -125
- package/lib/nitrogen/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.hpp +44 -56
- package/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.cpp +122 -87
- package/nitrogen/generated/android/c++/views/JHybridPerpDepthBarsStateUpdater.hpp +6 -1
- package/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.cpp +66 -41
- package/nitrogen/generated/android/c++/views/JHybridPerpSideRatioStateUpdater.hpp +6 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsManager.kt +26 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpDepthBarsStateUpdater.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioManager.kt +26 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/perpdepthbar/views/HybridPerpSideRatioStateUpdater.kt +2 -2
- package/nitrogen/generated/ios/c++/views/HybridPerpDepthBarsComponent.mm +146 -107
- package/nitrogen/generated/ios/c++/views/HybridPerpSideRatioComponent.mm +86 -57
- package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.cpp +23 -225
- package/nitrogen/generated/shared/c++/views/HybridPerpDepthBarsComponent.hpp +74 -66
- package/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.cpp +13 -125
- package/nitrogen/generated/shared/c++/views/HybridPerpSideRatioComponent.hpp +44 -56
- package/package.json +4 -4
|
@@ -20,6 +20,14 @@ import com.margelo.nitro.perpdepthbar.*
|
|
|
20
20
|
* Represents the React Native `ViewManager` for the "PerpSideRatio" Nitro HybridView.
|
|
21
21
|
*/
|
|
22
22
|
public class HybridPerpSideRatioManager: SimpleViewManager<View>() {
|
|
23
|
+
/**
|
|
24
|
+
* Represents the View and its last state snapshot (mutable)
|
|
25
|
+
*/
|
|
26
|
+
private class HybridViewHolder(
|
|
27
|
+
val hybridView: HybridPerpSideRatio,
|
|
28
|
+
var lastState: StateWrapper? = null,
|
|
29
|
+
)
|
|
30
|
+
|
|
23
31
|
init {
|
|
24
32
|
if (RecyclableView::class.java.isAssignableFrom(HybridPerpSideRatio::class.java)) {
|
|
25
33
|
// Enable view recycling
|
|
@@ -34,33 +42,41 @@ public class HybridPerpSideRatioManager: SimpleViewManager<View>() {
|
|
|
34
42
|
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
35
43
|
val hybridView = HybridPerpSideRatio(reactContext)
|
|
36
44
|
val view = hybridView.view
|
|
37
|
-
view.setTag(associated_hybrid_view_tag, hybridView)
|
|
45
|
+
view.setTag(associated_hybrid_view_tag, HybridViewHolder(hybridView))
|
|
38
46
|
return view
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
42
|
-
val
|
|
50
|
+
val holder = getHybridViewHolder(view)
|
|
43
51
|
?: throw Error("Couldn't find view $view in local views table!")
|
|
52
|
+
val hybridView = holder.hybridView
|
|
53
|
+
val oldState = holder.lastState
|
|
54
|
+
val newState = stateWrapper
|
|
44
55
|
|
|
45
56
|
// 1. Update each prop individually
|
|
46
57
|
hybridView.beforeUpdate()
|
|
47
|
-
HybridPerpSideRatioStateUpdater.updateViewProps(hybridView,
|
|
58
|
+
HybridPerpSideRatioStateUpdater.updateViewProps(hybridView, newState, oldState)
|
|
48
59
|
hybridView.afterUpdate()
|
|
60
|
+
holder.lastState = newState
|
|
49
61
|
|
|
50
62
|
// 2. Continue in base View props
|
|
51
|
-
return super.updateState(view, props,
|
|
63
|
+
return super.updateState(view, props, newState)
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
override fun onDropViewInstance(view: View) {
|
|
55
|
-
val
|
|
56
|
-
|
|
67
|
+
val holder = getHybridViewHolder(view)
|
|
68
|
+
holder?.lastState = null
|
|
69
|
+
holder?.hybridView?.onDropView()
|
|
57
70
|
return super.onDropViewInstance(view)
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
|
|
61
|
-
super.prepareToRecycleView(reactContext, view)
|
|
62
|
-
|
|
74
|
+
val preparedView = super.prepareToRecycleView(reactContext, view)
|
|
75
|
+
?: return null
|
|
76
|
+
val holder = getHybridViewHolder(preparedView)
|
|
63
77
|
?: return null
|
|
78
|
+
val hybridView = holder.hybridView
|
|
79
|
+
holder.lastState = null
|
|
64
80
|
|
|
65
81
|
@Suppress("USELESS_IS_CHECK")
|
|
66
82
|
if (hybridView is RecyclableView) {
|
|
@@ -74,7 +90,7 @@ public class HybridPerpSideRatioManager: SimpleViewManager<View>() {
|
|
|
74
90
|
}
|
|
75
91
|
}
|
|
76
92
|
|
|
77
|
-
private fun
|
|
78
|
-
return view.getTag(associated_hybrid_view_tag) as?
|
|
93
|
+
private fun getHybridViewHolder(view: View): HybridViewHolder? {
|
|
94
|
+
return view.getTag(associated_hybrid_view_tag) as? HybridViewHolder
|
|
79
95
|
}
|
|
80
96
|
}
|
|
@@ -14,10 +14,10 @@ internal class HybridPerpSideRatioStateUpdater {
|
|
|
14
14
|
companion object {
|
|
15
15
|
/**
|
|
16
16
|
* Updates the props for [view] through C++.
|
|
17
|
-
* The [
|
|
17
|
+
* The [newState] prop is expected to contain [view]'s props as wrapped Fabric state.
|
|
18
18
|
*/
|
|
19
19
|
@Suppress("KotlinJniMissingFunction")
|
|
20
20
|
@JvmStatic
|
|
21
|
-
external fun updateViewProps(view: HybridPerpSideRatioSpec,
|
|
21
|
+
external fun updateViewProps(view: HybridPerpSideRatioSpec, newState: StateWrapper, oldState: StateWrapper?)
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -37,6 +37,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
37
37
|
|
|
38
38
|
@implementation HybridPerpDepthBarsComponent {
|
|
39
39
|
std::shared_ptr<HybridPerpDepthBarsSpecSwift> _hybridView;
|
|
40
|
+
BOOL _didDropView;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
+ (void) load {
|
|
@@ -50,6 +51,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
50
51
|
|
|
51
52
|
- (instancetype) init {
|
|
52
53
|
if (self = [super init]) {
|
|
54
|
+
_props = HybridPerpDepthBarsShadowNode::defaultSharedProps();
|
|
53
55
|
std::shared_ptr<HybridPerpDepthBarsSpec> hybridView = PerpDepthBar::PerpDepthBarAutolinking::createPerpDepthBars();
|
|
54
56
|
_hybridView = std::dynamic_pointer_cast<HybridPerpDepthBarsSpecSwift>(hybridView);
|
|
55
57
|
[self updateView];
|
|
@@ -69,120 +71,157 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
69
71
|
[self setContentView:view];
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
- (void) notifyOnDropView {
|
|
75
|
+
// A recycled component can later be invalidated. Notify only once per mount.
|
|
76
|
+
if (_didDropView) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
PerpDepthBar::HybridPerpDepthBarsSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
80
|
+
swiftPart.onDropView();
|
|
81
|
+
_didDropView = YES;
|
|
82
|
+
}
|
|
83
|
+
|
|
72
84
|
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
73
85
|
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
86
|
+
// A props update marks a newly mounted or still-active component.
|
|
87
|
+
_didDropView = NO;
|
|
88
|
+
|
|
74
89
|
// 1. Downcast props
|
|
75
|
-
const auto&
|
|
76
|
-
auto
|
|
90
|
+
const auto& newViewProps = *std::static_pointer_cast<const HybridPerpDepthBarsProps>(props);
|
|
91
|
+
const auto* oldViewProps = static_cast<const HybridPerpDepthBarsProps*>(oldProps.get());
|
|
77
92
|
PerpDepthBar::HybridPerpDepthBarsSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
78
93
|
|
|
79
|
-
// 2. Update
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
swiftPart.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
94
|
+
// 2. Update only props that differ from the previous Props snapshot.
|
|
95
|
+
const bool hasTransactionPropChanges = oldViewProps == nullptr
|
|
96
|
+
? newViewProps.hasAnyProvidedProps()
|
|
97
|
+
: !newViewProps.hasSameProps(*oldViewProps);
|
|
98
|
+
if (hasTransactionPropChanges) {
|
|
99
|
+
swiftPart.beforeUpdate();
|
|
100
|
+
|
|
101
|
+
// percents: array
|
|
102
|
+
if (oldViewProps == nullptr
|
|
103
|
+
? newViewProps.percents.isProvided()
|
|
104
|
+
: !newViewProps.percents.hasSameValue(oldViewProps->percents)) {
|
|
105
|
+
swiftPart.setPercents(newViewProps.percents.get());
|
|
106
|
+
}
|
|
107
|
+
// rowHeight: number
|
|
108
|
+
if (oldViewProps == nullptr
|
|
109
|
+
? newViewProps.rowHeight.isProvided()
|
|
110
|
+
: !newViewProps.rowHeight.hasSameValue(oldViewProps->rowHeight)) {
|
|
111
|
+
swiftPart.setRowHeight(newViewProps.rowHeight.get());
|
|
112
|
+
}
|
|
113
|
+
// rowMarginTop: number
|
|
114
|
+
if (oldViewProps == nullptr
|
|
115
|
+
? newViewProps.rowMarginTop.isProvided()
|
|
116
|
+
: !newViewProps.rowMarginTop.hasSameValue(oldViewProps->rowMarginTop)) {
|
|
117
|
+
swiftPart.setRowMarginTop(newViewProps.rowMarginTop.get());
|
|
118
|
+
}
|
|
119
|
+
// barInset: number
|
|
120
|
+
if (oldViewProps == nullptr
|
|
121
|
+
? newViewProps.barInset.isProvided()
|
|
122
|
+
: !newViewProps.barInset.hasSameValue(oldViewProps->barInset)) {
|
|
123
|
+
swiftPart.setBarInset(newViewProps.barInset.get());
|
|
124
|
+
}
|
|
125
|
+
// color: string
|
|
126
|
+
if (oldViewProps == nullptr
|
|
127
|
+
? newViewProps.color.isProvided()
|
|
128
|
+
: !newViewProps.color.hasSameValue(oldViewProps->color)) {
|
|
129
|
+
swiftPart.setColor(newViewProps.color.get());
|
|
130
|
+
}
|
|
131
|
+
// origin: string
|
|
132
|
+
if (oldViewProps == nullptr
|
|
133
|
+
? newViewProps.origin.isProvided()
|
|
134
|
+
: !newViewProps.origin.hasSameValue(oldViewProps->origin)) {
|
|
135
|
+
swiftPart.setOrigin(newViewProps.origin.get());
|
|
136
|
+
}
|
|
137
|
+
// reducedMotion: boolean
|
|
138
|
+
if (oldViewProps == nullptr
|
|
139
|
+
? newViewProps.reducedMotion.isProvided()
|
|
140
|
+
: !newViewProps.reducedMotion.hasSameValue(oldViewProps->reducedMotion)) {
|
|
141
|
+
swiftPart.setReducedMotion(newViewProps.reducedMotion.get());
|
|
142
|
+
}
|
|
143
|
+
// epoch: number
|
|
144
|
+
if (oldViewProps == nullptr
|
|
145
|
+
? newViewProps.epoch.isProvided()
|
|
146
|
+
: !newViewProps.epoch.hasSameValue(oldViewProps->epoch)) {
|
|
147
|
+
swiftPart.setEpoch(newViewProps.epoch.get());
|
|
148
|
+
}
|
|
149
|
+
// prices: array
|
|
150
|
+
if (oldViewProps == nullptr
|
|
151
|
+
? newViewProps.prices.isProvided()
|
|
152
|
+
: !newViewProps.prices.hasSameValue(oldViewProps->prices)) {
|
|
153
|
+
swiftPart.setPrices(newViewProps.prices.get());
|
|
154
|
+
}
|
|
155
|
+
// sizes: array
|
|
156
|
+
if (oldViewProps == nullptr
|
|
157
|
+
? newViewProps.sizes.isProvided()
|
|
158
|
+
: !newViewProps.sizes.hasSameValue(oldViewProps->sizes)) {
|
|
159
|
+
swiftPart.setSizes(newViewProps.sizes.get());
|
|
160
|
+
}
|
|
161
|
+
// priceColor: string
|
|
162
|
+
if (oldViewProps == nullptr
|
|
163
|
+
? newViewProps.priceColor.isProvided()
|
|
164
|
+
: !newViewProps.priceColor.hasSameValue(oldViewProps->priceColor)) {
|
|
165
|
+
swiftPart.setPriceColor(newViewProps.priceColor.get());
|
|
166
|
+
}
|
|
167
|
+
// sizeColor: string
|
|
168
|
+
if (oldViewProps == nullptr
|
|
169
|
+
? newViewProps.sizeColor.isProvided()
|
|
170
|
+
: !newViewProps.sizeColor.hasSameValue(oldViewProps->sizeColor)) {
|
|
171
|
+
swiftPart.setSizeColor(newViewProps.sizeColor.get());
|
|
172
|
+
}
|
|
173
|
+
// priceFontSize: number
|
|
174
|
+
if (oldViewProps == nullptr
|
|
175
|
+
? newViewProps.priceFontSize.isProvided()
|
|
176
|
+
: !newViewProps.priceFontSize.hasSameValue(oldViewProps->priceFontSize)) {
|
|
177
|
+
swiftPart.setPriceFontSize(newViewProps.priceFontSize.get());
|
|
178
|
+
}
|
|
179
|
+
// sizeFontSize: number
|
|
180
|
+
if (oldViewProps == nullptr
|
|
181
|
+
? newViewProps.sizeFontSize.isProvided()
|
|
182
|
+
: !newViewProps.sizeFontSize.hasSameValue(oldViewProps->sizeFontSize)) {
|
|
183
|
+
swiftPart.setSizeFontSize(newViewProps.sizeFontSize.get());
|
|
184
|
+
}
|
|
185
|
+
// textInset: number
|
|
186
|
+
if (oldViewProps == nullptr
|
|
187
|
+
? newViewProps.textInset.isProvided()
|
|
188
|
+
: !newViewProps.textInset.hasSameValue(oldViewProps->textInset)) {
|
|
189
|
+
swiftPart.setTextInset(newViewProps.textInset.get());
|
|
190
|
+
}
|
|
191
|
+
// placeholderText: string
|
|
192
|
+
if (oldViewProps == nullptr
|
|
193
|
+
? newViewProps.placeholderText.isProvided()
|
|
194
|
+
: !newViewProps.placeholderText.hasSameValue(oldViewProps->placeholderText)) {
|
|
195
|
+
swiftPart.setPlaceholderText(newViewProps.placeholderText.get());
|
|
196
|
+
}
|
|
197
|
+
// placeholderRows: number
|
|
198
|
+
if (oldViewProps == nullptr
|
|
199
|
+
? newViewProps.placeholderRows.isProvided()
|
|
200
|
+
: !newViewProps.placeholderRows.hasSameValue(oldViewProps->placeholderRows)) {
|
|
201
|
+
swiftPart.setPlaceholderRows(newViewProps.placeholderRows.get());
|
|
202
|
+
}
|
|
203
|
+
// onRowPress: optional
|
|
204
|
+
if (oldViewProps == nullptr
|
|
205
|
+
? newViewProps.onRowPress.isProvided()
|
|
206
|
+
: !newViewProps.onRowPress.hasSameValue(oldViewProps->onRowPress)) {
|
|
207
|
+
swiftPart.setOnRowPress(newViewProps.onRowPress.get());
|
|
208
|
+
}
|
|
174
209
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
maybeFunc.
|
|
210
|
+
// Update hybridRef if it changed
|
|
211
|
+
if (oldViewProps == nullptr
|
|
212
|
+
? newViewProps.hybridRef.isProvided()
|
|
213
|
+
: !newViewProps.hybridRef.hasSameValue(oldViewProps->hybridRef)) {
|
|
214
|
+
// hybridRef changed - call it with new this
|
|
215
|
+
const auto& maybeFunc = newViewProps.hybridRef.get();
|
|
216
|
+
if (maybeFunc.has_value()) {
|
|
217
|
+
maybeFunc.value()(_hybridView);
|
|
218
|
+
}
|
|
181
219
|
}
|
|
182
|
-
|
|
220
|
+
|
|
221
|
+
swiftPart.afterUpdate();
|
|
183
222
|
}
|
|
184
223
|
|
|
185
|
-
//
|
|
224
|
+
// 3. Continue in base class
|
|
186
225
|
[super updateProps:props oldProps:oldProps];
|
|
187
226
|
}
|
|
188
227
|
|
|
@@ -191,6 +230,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
191
230
|
}
|
|
192
231
|
|
|
193
232
|
- (void)prepareForRecycle {
|
|
233
|
+
[self notifyOnDropView];
|
|
194
234
|
[super prepareForRecycle];
|
|
195
235
|
PerpDepthBar::HybridPerpDepthBarsSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
196
236
|
swiftPart.maybePrepareForRecycle();
|
|
@@ -198,8 +238,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
198
238
|
|
|
199
239
|
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
200
240
|
- (void)invalidate {
|
|
201
|
-
|
|
202
|
-
swiftPart.onDropView();
|
|
241
|
+
[self notifyOnDropView];
|
|
203
242
|
[super invalidate];
|
|
204
243
|
}
|
|
205
244
|
#endif
|
|
@@ -37,6 +37,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
37
37
|
|
|
38
38
|
@implementation HybridPerpSideRatioComponent {
|
|
39
39
|
std::shared_ptr<HybridPerpSideRatioSpecSwift> _hybridView;
|
|
40
|
+
BOOL _didDropView;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
+ (void) load {
|
|
@@ -50,6 +51,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
50
51
|
|
|
51
52
|
- (instancetype) init {
|
|
52
53
|
if (self = [super init]) {
|
|
54
|
+
_props = HybridPerpSideRatioShadowNode::defaultSharedProps();
|
|
53
55
|
std::shared_ptr<HybridPerpSideRatioSpec> hybridView = PerpDepthBar::PerpDepthBarAutolinking::createPerpSideRatio();
|
|
54
56
|
_hybridView = std::dynamic_pointer_cast<HybridPerpSideRatioSpecSwift>(hybridView);
|
|
55
57
|
[self updateView];
|
|
@@ -69,70 +71,97 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
69
71
|
[self setContentView:view];
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
- (void) notifyOnDropView {
|
|
75
|
+
// A recycled component can later be invalidated. Notify only once per mount.
|
|
76
|
+
if (_didDropView) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
PerpDepthBar::HybridPerpSideRatioSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
80
|
+
swiftPart.onDropView();
|
|
81
|
+
_didDropView = YES;
|
|
82
|
+
}
|
|
83
|
+
|
|
72
84
|
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
73
85
|
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
86
|
+
// A props update marks a newly mounted or still-active component.
|
|
87
|
+
_didDropView = NO;
|
|
88
|
+
|
|
74
89
|
// 1. Downcast props
|
|
75
|
-
const auto&
|
|
76
|
-
auto
|
|
90
|
+
const auto& newViewProps = *std::static_pointer_cast<const HybridPerpSideRatioProps>(props);
|
|
91
|
+
const auto* oldViewProps = static_cast<const HybridPerpSideRatioProps*>(oldProps.get());
|
|
77
92
|
PerpDepthBar::HybridPerpSideRatioSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
78
93
|
|
|
79
|
-
// 2. Update
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
swiftPart.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
94
|
+
// 2. Update only props that differ from the previous Props snapshot.
|
|
95
|
+
const bool hasTransactionPropChanges = oldViewProps == nullptr
|
|
96
|
+
? newViewProps.hasAnyProvidedProps()
|
|
97
|
+
: !newViewProps.hasSameProps(*oldViewProps);
|
|
98
|
+
if (hasTransactionPropChanges) {
|
|
99
|
+
swiftPart.beforeUpdate();
|
|
100
|
+
|
|
101
|
+
// bidPercentage: number
|
|
102
|
+
if (oldViewProps == nullptr
|
|
103
|
+
? newViewProps.bidPercentage.isProvided()
|
|
104
|
+
: !newViewProps.bidPercentage.hasSameValue(oldViewProps->bidPercentage)) {
|
|
105
|
+
swiftPart.setBidPercentage(newViewProps.bidPercentage.get());
|
|
106
|
+
}
|
|
107
|
+
// askPercentage: number
|
|
108
|
+
if (oldViewProps == nullptr
|
|
109
|
+
? newViewProps.askPercentage.isProvided()
|
|
110
|
+
: !newViewProps.askPercentage.hasSameValue(oldViewProps->askPercentage)) {
|
|
111
|
+
swiftPart.setAskPercentage(newViewProps.askPercentage.get());
|
|
112
|
+
}
|
|
113
|
+
// longColor: string
|
|
114
|
+
if (oldViewProps == nullptr
|
|
115
|
+
? newViewProps.longColor.isProvided()
|
|
116
|
+
: !newViewProps.longColor.hasSameValue(oldViewProps->longColor)) {
|
|
117
|
+
swiftPart.setLongColor(newViewProps.longColor.get());
|
|
118
|
+
}
|
|
119
|
+
// shortColor: string
|
|
120
|
+
if (oldViewProps == nullptr
|
|
121
|
+
? newViewProps.shortColor.isProvided()
|
|
122
|
+
: !newViewProps.shortColor.hasSameValue(oldViewProps->shortColor)) {
|
|
123
|
+
swiftPart.setShortColor(newViewProps.shortColor.get());
|
|
124
|
+
}
|
|
125
|
+
// segmentHeight: number
|
|
126
|
+
if (oldViewProps == nullptr
|
|
127
|
+
? newViewProps.segmentHeight.isProvided()
|
|
128
|
+
: !newViewProps.segmentHeight.hasSameValue(oldViewProps->segmentHeight)) {
|
|
129
|
+
swiftPart.setSegmentHeight(newViewProps.segmentHeight.get());
|
|
130
|
+
}
|
|
131
|
+
// cornerRadius: number
|
|
132
|
+
if (oldViewProps == nullptr
|
|
133
|
+
? newViewProps.cornerRadius.isProvided()
|
|
134
|
+
: !newViewProps.cornerRadius.hasSameValue(oldViewProps->cornerRadius)) {
|
|
135
|
+
swiftPart.setCornerRadius(newViewProps.cornerRadius.get());
|
|
136
|
+
}
|
|
137
|
+
// gap: number
|
|
138
|
+
if (oldViewProps == nullptr
|
|
139
|
+
? newViewProps.gap.isProvided()
|
|
140
|
+
: !newViewProps.gap.hasSameValue(oldViewProps->gap)) {
|
|
141
|
+
swiftPart.setGap(newViewProps.gap.get());
|
|
142
|
+
}
|
|
143
|
+
// reducedMotion: boolean
|
|
144
|
+
if (oldViewProps == nullptr
|
|
145
|
+
? newViewProps.reducedMotion.isProvided()
|
|
146
|
+
: !newViewProps.reducedMotion.hasSameValue(oldViewProps->reducedMotion)) {
|
|
147
|
+
swiftPart.setReducedMotion(newViewProps.reducedMotion.get());
|
|
148
|
+
}
|
|
124
149
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
maybeFunc.
|
|
150
|
+
// Update hybridRef if it changed
|
|
151
|
+
if (oldViewProps == nullptr
|
|
152
|
+
? newViewProps.hybridRef.isProvided()
|
|
153
|
+
: !newViewProps.hybridRef.hasSameValue(oldViewProps->hybridRef)) {
|
|
154
|
+
// hybridRef changed - call it with new this
|
|
155
|
+
const auto& maybeFunc = newViewProps.hybridRef.get();
|
|
156
|
+
if (maybeFunc.has_value()) {
|
|
157
|
+
maybeFunc.value()(_hybridView);
|
|
158
|
+
}
|
|
131
159
|
}
|
|
132
|
-
|
|
160
|
+
|
|
161
|
+
swiftPart.afterUpdate();
|
|
133
162
|
}
|
|
134
163
|
|
|
135
|
-
//
|
|
164
|
+
// 3. Continue in base class
|
|
136
165
|
[super updateProps:props oldProps:oldProps];
|
|
137
166
|
}
|
|
138
167
|
|
|
@@ -141,6 +170,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
141
170
|
}
|
|
142
171
|
|
|
143
172
|
- (void)prepareForRecycle {
|
|
173
|
+
[self notifyOnDropView];
|
|
144
174
|
[super prepareForRecycle];
|
|
145
175
|
PerpDepthBar::HybridPerpSideRatioSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
146
176
|
swiftPart.maybePrepareForRecycle();
|
|
@@ -148,8 +178,7 @@ using namespace margelo::nitro::perpdepthbar::views;
|
|
|
148
178
|
|
|
149
179
|
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
150
180
|
- (void)invalidate {
|
|
151
|
-
|
|
152
|
-
swiftPart.onDropView();
|
|
181
|
+
[self notifyOnDropView];
|
|
153
182
|
[super invalidate];
|
|
154
183
|
}
|
|
155
184
|
#endif
|