@onekeyfe/react-native-auto-size-input 3.0.96 → 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/JHybridAutoSizeInputStateUpdater.cpp +187 -139
- package/lib/nitrogen/generated/android/c++/views/JHybridAutoSizeInputStateUpdater.hpp +6 -1
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/views/HybridAutoSizeInputManager.kt +26 -10
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/views/HybridAutoSizeInputStateUpdater.kt +2 -2
- package/lib/nitrogen/generated/ios/c++/views/HybridAutoSizeInputComponent.mm +223 -171
- package/lib/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.cpp +36 -355
- package/lib/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.hpp +113 -79
- package/nitrogen/generated/android/c++/views/JHybridAutoSizeInputStateUpdater.cpp +187 -139
- package/nitrogen/generated/android/c++/views/JHybridAutoSizeInputStateUpdater.hpp +6 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/views/HybridAutoSizeInputManager.kt +26 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/autosizeinput/views/HybridAutoSizeInputStateUpdater.kt +2 -2
- package/nitrogen/generated/ios/c++/views/HybridAutoSizeInputComponent.mm +223 -171
- package/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.cpp +36 -355
- package/nitrogen/generated/shared/c++/views/HybridAutoSizeInputComponent.hpp +113 -79
- package/package.json +4 -4
|
@@ -15,161 +15,209 @@ namespace margelo::nitro::autosizeinput::views {
|
|
|
15
15
|
using namespace facebook;
|
|
16
16
|
using ConcreteStateData = react::ConcreteState<HybridAutoSizeInputState>;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
std::shared_ptr<const HybridAutoSizeInputProps> JHybridAutoSizeInputStateUpdater::getPropsFromStateWrapper(
|
|
19
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper) {
|
|
20
|
+
if (stateWrapper.get() == nullptr) {
|
|
21
|
+
return nullptr;
|
|
22
|
+
}
|
|
23
23
|
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
24
|
-
jobject rawStateWrapper =
|
|
25
|
-
if (!
|
|
26
|
-
|
|
24
|
+
jobject rawStateWrapper = stateWrapper.get();
|
|
25
|
+
if (!stateWrapper->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
27
|
+
}
|
|
28
|
+
auto stateWrapperImpl = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
29
|
+
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)
|
|
30
|
+
};
|
|
31
|
+
std::shared_ptr<const react::State> state = stateWrapperImpl->cthis()->getState();
|
|
32
|
+
if (state == nullptr) {
|
|
33
|
+
return nullptr;
|
|
27
34
|
}
|
|
28
|
-
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
29
|
-
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
30
|
-
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
35
|
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
|
|
32
36
|
const HybridAutoSizeInputState& data = concreteState->getData();
|
|
33
|
-
const std::shared_ptr<HybridAutoSizeInputProps>& props = data.getProps();
|
|
37
|
+
const std::shared_ptr<const HybridAutoSizeInputProps>& props = data.getProps();
|
|
34
38
|
if (props == nullptr) [[unlikely]] {
|
|
35
|
-
// Props aren't set yet!
|
|
36
39
|
throw std::runtime_error("HybridAutoSizeInputState's data doesn't contain any props!");
|
|
37
40
|
}
|
|
41
|
+
return props;
|
|
42
|
+
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (props->prefix.isDirty) {
|
|
49
|
-
hybridView->setPrefix(props->prefix.value);
|
|
50
|
-
props->prefix.isDirty = false;
|
|
51
|
-
}
|
|
52
|
-
if (props->suffix.isDirty) {
|
|
53
|
-
hybridView->setSuffix(props->suffix.value);
|
|
54
|
-
props->suffix.isDirty = false;
|
|
55
|
-
}
|
|
56
|
-
if (props->placeholder.isDirty) {
|
|
57
|
-
hybridView->setPlaceholder(props->placeholder.value);
|
|
58
|
-
props->placeholder.isDirty = false;
|
|
59
|
-
}
|
|
60
|
-
if (props->fontSize.isDirty) {
|
|
61
|
-
hybridView->setFontSize(props->fontSize.value);
|
|
62
|
-
props->fontSize.isDirty = false;
|
|
63
|
-
}
|
|
64
|
-
if (props->minFontSize.isDirty) {
|
|
65
|
-
hybridView->setMinFontSize(props->minFontSize.value);
|
|
66
|
-
props->minFontSize.isDirty = false;
|
|
67
|
-
}
|
|
68
|
-
if (props->multiline.isDirty) {
|
|
69
|
-
hybridView->setMultiline(props->multiline.value);
|
|
70
|
-
props->multiline.isDirty = false;
|
|
71
|
-
}
|
|
72
|
-
if (props->maxNumberOfLines.isDirty) {
|
|
73
|
-
hybridView->setMaxNumberOfLines(props->maxNumberOfLines.value);
|
|
74
|
-
props->maxNumberOfLines.isDirty = false;
|
|
75
|
-
}
|
|
76
|
-
if (props->textColor.isDirty) {
|
|
77
|
-
hybridView->setTextColor(props->textColor.value);
|
|
78
|
-
props->textColor.isDirty = false;
|
|
79
|
-
}
|
|
80
|
-
if (props->prefixColor.isDirty) {
|
|
81
|
-
hybridView->setPrefixColor(props->prefixColor.value);
|
|
82
|
-
props->prefixColor.isDirty = false;
|
|
83
|
-
}
|
|
84
|
-
if (props->suffixColor.isDirty) {
|
|
85
|
-
hybridView->setSuffixColor(props->suffixColor.value);
|
|
86
|
-
props->suffixColor.isDirty = false;
|
|
87
|
-
}
|
|
88
|
-
if (props->placeholderColor.isDirty) {
|
|
89
|
-
hybridView->setPlaceholderColor(props->placeholderColor.value);
|
|
90
|
-
props->placeholderColor.isDirty = false;
|
|
91
|
-
}
|
|
92
|
-
if (props->textAlign.isDirty) {
|
|
93
|
-
hybridView->setTextAlign(props->textAlign.value);
|
|
94
|
-
props->textAlign.isDirty = false;
|
|
95
|
-
}
|
|
96
|
-
if (props->fontFamily.isDirty) {
|
|
97
|
-
hybridView->setFontFamily(props->fontFamily.value);
|
|
98
|
-
props->fontFamily.isDirty = false;
|
|
99
|
-
}
|
|
100
|
-
if (props->fontWeight.isDirty) {
|
|
101
|
-
hybridView->setFontWeight(props->fontWeight.value);
|
|
102
|
-
props->fontWeight.isDirty = false;
|
|
103
|
-
}
|
|
104
|
-
if (props->editable.isDirty) {
|
|
105
|
-
hybridView->setEditable(props->editable.value);
|
|
106
|
-
props->editable.isDirty = false;
|
|
107
|
-
}
|
|
108
|
-
if (props->keyboardType.isDirty) {
|
|
109
|
-
hybridView->setKeyboardType(props->keyboardType.value);
|
|
110
|
-
props->keyboardType.isDirty = false;
|
|
111
|
-
}
|
|
112
|
-
if (props->returnKeyType.isDirty) {
|
|
113
|
-
hybridView->setReturnKeyType(props->returnKeyType.value);
|
|
114
|
-
props->returnKeyType.isDirty = false;
|
|
115
|
-
}
|
|
116
|
-
if (props->autoCorrect.isDirty) {
|
|
117
|
-
hybridView->setAutoCorrect(props->autoCorrect.value);
|
|
118
|
-
props->autoCorrect.isDirty = false;
|
|
119
|
-
}
|
|
120
|
-
if (props->autoCapitalize.isDirty) {
|
|
121
|
-
hybridView->setAutoCapitalize(props->autoCapitalize.value);
|
|
122
|
-
props->autoCapitalize.isDirty = false;
|
|
123
|
-
}
|
|
124
|
-
if (props->selectionColor.isDirty) {
|
|
125
|
-
hybridView->setSelectionColor(props->selectionColor.value);
|
|
126
|
-
props->selectionColor.isDirty = false;
|
|
127
|
-
}
|
|
128
|
-
if (props->prefixMarginRight.isDirty) {
|
|
129
|
-
hybridView->setPrefixMarginRight(props->prefixMarginRight.value);
|
|
130
|
-
props->prefixMarginRight.isDirty = false;
|
|
131
|
-
}
|
|
132
|
-
if (props->suffixMarginLeft.isDirty) {
|
|
133
|
-
hybridView->setSuffixMarginLeft(props->suffixMarginLeft.value);
|
|
134
|
-
props->suffixMarginLeft.isDirty = false;
|
|
135
|
-
}
|
|
136
|
-
if (props->showBorder.isDirty) {
|
|
137
|
-
hybridView->setShowBorder(props->showBorder.value);
|
|
138
|
-
props->showBorder.isDirty = false;
|
|
139
|
-
}
|
|
140
|
-
if (props->inputBackgroundColor.isDirty) {
|
|
141
|
-
hybridView->setInputBackgroundColor(props->inputBackgroundColor.value);
|
|
142
|
-
props->inputBackgroundColor.isDirty = false;
|
|
143
|
-
}
|
|
144
|
-
if (props->contentAutoWidth.isDirty) {
|
|
145
|
-
hybridView->setContentAutoWidth(props->contentAutoWidth.value);
|
|
146
|
-
props->contentAutoWidth.isDirty = false;
|
|
147
|
-
}
|
|
148
|
-
if (props->contentCentered.isDirty) {
|
|
149
|
-
hybridView->setContentCentered(props->contentCentered.value);
|
|
150
|
-
props->contentCentered.isDirty = false;
|
|
151
|
-
}
|
|
152
|
-
if (props->onChangeText.isDirty) {
|
|
153
|
-
hybridView->setOnChangeText(props->onChangeText.value);
|
|
154
|
-
props->onChangeText.isDirty = false;
|
|
155
|
-
}
|
|
156
|
-
if (props->onFocus.isDirty) {
|
|
157
|
-
hybridView->setOnFocus(props->onFocus.value);
|
|
158
|
-
props->onFocus.isDirty = false;
|
|
44
|
+
void JHybridAutoSizeInputStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
45
|
+
jni::alias_ref<JHybridAutoSizeInputSpec::JavaPart> javaView,
|
|
46
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
47
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState) {
|
|
48
|
+
std::shared_ptr<JHybridAutoSizeInputSpec> hybridView = javaView->getJHybridAutoSizeInputSpec();
|
|
49
|
+
std::shared_ptr<const HybridAutoSizeInputProps> newProps = getPropsFromStateWrapper(newState);
|
|
50
|
+
std::shared_ptr<const HybridAutoSizeInputProps> oldProps = getPropsFromStateWrapper(oldState);
|
|
51
|
+
if (newProps == nullptr) [[unlikely]] {
|
|
52
|
+
throw std::runtime_error("Current StateWrapper doesn't contain any props!");
|
|
159
53
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
54
|
+
|
|
55
|
+
// Update only props that differ from the previous State snapshot.
|
|
56
|
+
if (oldProps == nullptr
|
|
57
|
+
? newProps->mostRecentEventCount.isProvided()
|
|
58
|
+
: !newProps->mostRecentEventCount.hasSameValue(oldProps->mostRecentEventCount)) {
|
|
59
|
+
hybridView->setMostRecentEventCount(newProps->mostRecentEventCount.get());
|
|
60
|
+
}
|
|
61
|
+
if (oldProps == nullptr
|
|
62
|
+
? newProps->text.isProvided()
|
|
63
|
+
: !newProps->text.hasSameValue(oldProps->text)) {
|
|
64
|
+
hybridView->setText(newProps->text.get());
|
|
65
|
+
}
|
|
66
|
+
if (oldProps == nullptr
|
|
67
|
+
? newProps->prefix.isProvided()
|
|
68
|
+
: !newProps->prefix.hasSameValue(oldProps->prefix)) {
|
|
69
|
+
hybridView->setPrefix(newProps->prefix.get());
|
|
70
|
+
}
|
|
71
|
+
if (oldProps == nullptr
|
|
72
|
+
? newProps->suffix.isProvided()
|
|
73
|
+
: !newProps->suffix.hasSameValue(oldProps->suffix)) {
|
|
74
|
+
hybridView->setSuffix(newProps->suffix.get());
|
|
75
|
+
}
|
|
76
|
+
if (oldProps == nullptr
|
|
77
|
+
? newProps->placeholder.isProvided()
|
|
78
|
+
: !newProps->placeholder.hasSameValue(oldProps->placeholder)) {
|
|
79
|
+
hybridView->setPlaceholder(newProps->placeholder.get());
|
|
80
|
+
}
|
|
81
|
+
if (oldProps == nullptr
|
|
82
|
+
? newProps->fontSize.isProvided()
|
|
83
|
+
: !newProps->fontSize.hasSameValue(oldProps->fontSize)) {
|
|
84
|
+
hybridView->setFontSize(newProps->fontSize.get());
|
|
85
|
+
}
|
|
86
|
+
if (oldProps == nullptr
|
|
87
|
+
? newProps->minFontSize.isProvided()
|
|
88
|
+
: !newProps->minFontSize.hasSameValue(oldProps->minFontSize)) {
|
|
89
|
+
hybridView->setMinFontSize(newProps->minFontSize.get());
|
|
90
|
+
}
|
|
91
|
+
if (oldProps == nullptr
|
|
92
|
+
? newProps->multiline.isProvided()
|
|
93
|
+
: !newProps->multiline.hasSameValue(oldProps->multiline)) {
|
|
94
|
+
hybridView->setMultiline(newProps->multiline.get());
|
|
95
|
+
}
|
|
96
|
+
if (oldProps == nullptr
|
|
97
|
+
? newProps->maxNumberOfLines.isProvided()
|
|
98
|
+
: !newProps->maxNumberOfLines.hasSameValue(oldProps->maxNumberOfLines)) {
|
|
99
|
+
hybridView->setMaxNumberOfLines(newProps->maxNumberOfLines.get());
|
|
100
|
+
}
|
|
101
|
+
if (oldProps == nullptr
|
|
102
|
+
? newProps->textColor.isProvided()
|
|
103
|
+
: !newProps->textColor.hasSameValue(oldProps->textColor)) {
|
|
104
|
+
hybridView->setTextColor(newProps->textColor.get());
|
|
105
|
+
}
|
|
106
|
+
if (oldProps == nullptr
|
|
107
|
+
? newProps->prefixColor.isProvided()
|
|
108
|
+
: !newProps->prefixColor.hasSameValue(oldProps->prefixColor)) {
|
|
109
|
+
hybridView->setPrefixColor(newProps->prefixColor.get());
|
|
110
|
+
}
|
|
111
|
+
if (oldProps == nullptr
|
|
112
|
+
? newProps->suffixColor.isProvided()
|
|
113
|
+
: !newProps->suffixColor.hasSameValue(oldProps->suffixColor)) {
|
|
114
|
+
hybridView->setSuffixColor(newProps->suffixColor.get());
|
|
115
|
+
}
|
|
116
|
+
if (oldProps == nullptr
|
|
117
|
+
? newProps->placeholderColor.isProvided()
|
|
118
|
+
: !newProps->placeholderColor.hasSameValue(oldProps->placeholderColor)) {
|
|
119
|
+
hybridView->setPlaceholderColor(newProps->placeholderColor.get());
|
|
120
|
+
}
|
|
121
|
+
if (oldProps == nullptr
|
|
122
|
+
? newProps->textAlign.isProvided()
|
|
123
|
+
: !newProps->textAlign.hasSameValue(oldProps->textAlign)) {
|
|
124
|
+
hybridView->setTextAlign(newProps->textAlign.get());
|
|
125
|
+
}
|
|
126
|
+
if (oldProps == nullptr
|
|
127
|
+
? newProps->fontFamily.isProvided()
|
|
128
|
+
: !newProps->fontFamily.hasSameValue(oldProps->fontFamily)) {
|
|
129
|
+
hybridView->setFontFamily(newProps->fontFamily.get());
|
|
130
|
+
}
|
|
131
|
+
if (oldProps == nullptr
|
|
132
|
+
? newProps->fontWeight.isProvided()
|
|
133
|
+
: !newProps->fontWeight.hasSameValue(oldProps->fontWeight)) {
|
|
134
|
+
hybridView->setFontWeight(newProps->fontWeight.get());
|
|
135
|
+
}
|
|
136
|
+
if (oldProps == nullptr
|
|
137
|
+
? newProps->editable.isProvided()
|
|
138
|
+
: !newProps->editable.hasSameValue(oldProps->editable)) {
|
|
139
|
+
hybridView->setEditable(newProps->editable.get());
|
|
140
|
+
}
|
|
141
|
+
if (oldProps == nullptr
|
|
142
|
+
? newProps->keyboardType.isProvided()
|
|
143
|
+
: !newProps->keyboardType.hasSameValue(oldProps->keyboardType)) {
|
|
144
|
+
hybridView->setKeyboardType(newProps->keyboardType.get());
|
|
145
|
+
}
|
|
146
|
+
if (oldProps == nullptr
|
|
147
|
+
? newProps->returnKeyType.isProvided()
|
|
148
|
+
: !newProps->returnKeyType.hasSameValue(oldProps->returnKeyType)) {
|
|
149
|
+
hybridView->setReturnKeyType(newProps->returnKeyType.get());
|
|
150
|
+
}
|
|
151
|
+
if (oldProps == nullptr
|
|
152
|
+
? newProps->autoCorrect.isProvided()
|
|
153
|
+
: !newProps->autoCorrect.hasSameValue(oldProps->autoCorrect)) {
|
|
154
|
+
hybridView->setAutoCorrect(newProps->autoCorrect.get());
|
|
155
|
+
}
|
|
156
|
+
if (oldProps == nullptr
|
|
157
|
+
? newProps->autoCapitalize.isProvided()
|
|
158
|
+
: !newProps->autoCapitalize.hasSameValue(oldProps->autoCapitalize)) {
|
|
159
|
+
hybridView->setAutoCapitalize(newProps->autoCapitalize.get());
|
|
160
|
+
}
|
|
161
|
+
if (oldProps == nullptr
|
|
162
|
+
? newProps->selectionColor.isProvided()
|
|
163
|
+
: !newProps->selectionColor.hasSameValue(oldProps->selectionColor)) {
|
|
164
|
+
hybridView->setSelectionColor(newProps->selectionColor.get());
|
|
165
|
+
}
|
|
166
|
+
if (oldProps == nullptr
|
|
167
|
+
? newProps->prefixMarginRight.isProvided()
|
|
168
|
+
: !newProps->prefixMarginRight.hasSameValue(oldProps->prefixMarginRight)) {
|
|
169
|
+
hybridView->setPrefixMarginRight(newProps->prefixMarginRight.get());
|
|
170
|
+
}
|
|
171
|
+
if (oldProps == nullptr
|
|
172
|
+
? newProps->suffixMarginLeft.isProvided()
|
|
173
|
+
: !newProps->suffixMarginLeft.hasSameValue(oldProps->suffixMarginLeft)) {
|
|
174
|
+
hybridView->setSuffixMarginLeft(newProps->suffixMarginLeft.get());
|
|
175
|
+
}
|
|
176
|
+
if (oldProps == nullptr
|
|
177
|
+
? newProps->showBorder.isProvided()
|
|
178
|
+
: !newProps->showBorder.hasSameValue(oldProps->showBorder)) {
|
|
179
|
+
hybridView->setShowBorder(newProps->showBorder.get());
|
|
180
|
+
}
|
|
181
|
+
if (oldProps == nullptr
|
|
182
|
+
? newProps->inputBackgroundColor.isProvided()
|
|
183
|
+
: !newProps->inputBackgroundColor.hasSameValue(oldProps->inputBackgroundColor)) {
|
|
184
|
+
hybridView->setInputBackgroundColor(newProps->inputBackgroundColor.get());
|
|
185
|
+
}
|
|
186
|
+
if (oldProps == nullptr
|
|
187
|
+
? newProps->contentAutoWidth.isProvided()
|
|
188
|
+
: !newProps->contentAutoWidth.hasSameValue(oldProps->contentAutoWidth)) {
|
|
189
|
+
hybridView->setContentAutoWidth(newProps->contentAutoWidth.get());
|
|
190
|
+
}
|
|
191
|
+
if (oldProps == nullptr
|
|
192
|
+
? newProps->contentCentered.isProvided()
|
|
193
|
+
: !newProps->contentCentered.hasSameValue(oldProps->contentCentered)) {
|
|
194
|
+
hybridView->setContentCentered(newProps->contentCentered.get());
|
|
195
|
+
}
|
|
196
|
+
if (oldProps == nullptr
|
|
197
|
+
? newProps->onChangeText.isProvided()
|
|
198
|
+
: !newProps->onChangeText.hasSameValue(oldProps->onChangeText)) {
|
|
199
|
+
hybridView->setOnChangeText(newProps->onChangeText.get());
|
|
200
|
+
}
|
|
201
|
+
if (oldProps == nullptr
|
|
202
|
+
? newProps->onFocus.isProvided()
|
|
203
|
+
: !newProps->onFocus.hasSameValue(oldProps->onFocus)) {
|
|
204
|
+
hybridView->setOnFocus(newProps->onFocus.get());
|
|
205
|
+
}
|
|
206
|
+
if (oldProps == nullptr
|
|
207
|
+
? newProps->onBlur.isProvided()
|
|
208
|
+
: !newProps->onBlur.hasSameValue(oldProps->onBlur)) {
|
|
209
|
+
hybridView->setOnBlur(newProps->onBlur.get());
|
|
163
210
|
}
|
|
164
211
|
|
|
165
212
|
// Update hybridRef if it changed
|
|
166
|
-
if (
|
|
213
|
+
if (oldProps == nullptr
|
|
214
|
+
? newProps->hybridRef.isProvided()
|
|
215
|
+
: !newProps->hybridRef.hasSameValue(oldProps->hybridRef)) {
|
|
167
216
|
// hybridRef changed - call it with new this
|
|
168
|
-
const auto& maybeFunc =
|
|
217
|
+
const auto& maybeFunc = newProps->hybridRef.get();
|
|
169
218
|
if (maybeFunc.has_value()) {
|
|
170
219
|
maybeFunc.value()(hybridView);
|
|
171
220
|
}
|
|
172
|
-
props->hybridRef.isDirty = false;
|
|
173
221
|
}
|
|
174
222
|
}
|
|
175
223
|
|
|
@@ -31,7 +31,12 @@ public:
|
|
|
31
31
|
public:
|
|
32
32
|
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
33
|
jni::alias_ref<JHybridAutoSizeInputSpec::JavaPart> view,
|
|
34
|
-
jni::alias_ref<JStateWrapper::javaobject>
|
|
34
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
35
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState);
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
static std::shared_ptr<const HybridAutoSizeInputProps> getPropsFromStateWrapper(
|
|
39
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper);
|
|
35
40
|
|
|
36
41
|
public:
|
|
37
42
|
static void registerNatives() {
|
|
@@ -20,6 +20,14 @@ import com.margelo.nitro.autosizeinput.*
|
|
|
20
20
|
* Represents the React Native `ViewManager` for the "AutoSizeInput" Nitro HybridView.
|
|
21
21
|
*/
|
|
22
22
|
public class HybridAutoSizeInputManager: SimpleViewManager<View>() {
|
|
23
|
+
/**
|
|
24
|
+
* Represents the View and its last state snapshot (mutable)
|
|
25
|
+
*/
|
|
26
|
+
private class HybridViewHolder(
|
|
27
|
+
val hybridView: HybridAutoSizeInput,
|
|
28
|
+
var lastState: StateWrapper? = null,
|
|
29
|
+
)
|
|
30
|
+
|
|
23
31
|
init {
|
|
24
32
|
if (RecyclableView::class.java.isAssignableFrom(HybridAutoSizeInput::class.java)) {
|
|
25
33
|
// Enable view recycling
|
|
@@ -34,33 +42,41 @@ public class HybridAutoSizeInputManager: SimpleViewManager<View>() {
|
|
|
34
42
|
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
35
43
|
val hybridView = HybridAutoSizeInput(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
|
-
HybridAutoSizeInputStateUpdater.updateViewProps(hybridView,
|
|
58
|
+
HybridAutoSizeInputStateUpdater.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 HybridAutoSizeInputManager: 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 HybridAutoSizeInputStateUpdater {
|
|
|
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: HybridAutoSizeInputSpec,
|
|
21
|
+
external fun updateViewProps(view: HybridAutoSizeInputSpec, newState: StateWrapper, oldState: StateWrapper?)
|
|
22
22
|
}
|
|
23
23
|
}
|