forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-native+0.73.4+016+iOS-textinput-onscroll-event.patch
70 lines (67 loc) · 2.98 KB
/
react-native+0.73.4+016+iOS-textinput-onscroll-event.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
diff --git a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputEventEmitter.cpp b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputEventEmitter.cpp
index 88ae3f3..497569a 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputEventEmitter.cpp
+++ b/node_modules/react-native/ReactCommon/react/renderer/components/textinput/iostextinput/react/renderer/components/iostextinput/TextInputEventEmitter.cpp
@@ -36,6 +36,54 @@ static jsi::Value textInputMetricsPayload(
return payload;
};
+static jsi::Value textInputMetricsScrollPayload(
+ jsi::Runtime& runtime,
+ const TextInputMetrics& textInputMetrics) {
+ auto payload = jsi::Object(runtime);
+
+ {
+ auto contentOffset = jsi::Object(runtime);
+ contentOffset.setProperty(runtime, "x", textInputMetrics.contentOffset.x);
+ contentOffset.setProperty(runtime, "y", textInputMetrics.contentOffset.y);
+ payload.setProperty(runtime, "contentOffset", contentOffset);
+ }
+
+ {
+ auto contentInset = jsi::Object(runtime);
+ contentInset.setProperty(runtime, "top", textInputMetrics.contentInset.top);
+ contentInset.setProperty(
+ runtime, "left", textInputMetrics.contentInset.left);
+ contentInset.setProperty(
+ runtime, "bottom", textInputMetrics.contentInset.bottom);
+ contentInset.setProperty(
+ runtime, "right", textInputMetrics.contentInset.right);
+ payload.setProperty(runtime, "contentInset", contentInset);
+ }
+
+ {
+ auto contentSize = jsi::Object(runtime);
+ contentSize.setProperty(
+ runtime, "width", textInputMetrics.contentSize.width);
+ contentSize.setProperty(
+ runtime, "height", textInputMetrics.contentSize.height);
+ payload.setProperty(runtime, "contentSize", contentSize);
+ }
+
+ {
+ auto layoutMeasurement = jsi::Object(runtime);
+ layoutMeasurement.setProperty(
+ runtime, "width", textInputMetrics.layoutMeasurement.width);
+ layoutMeasurement.setProperty(
+ runtime, "height", textInputMetrics.layoutMeasurement.height);
+ payload.setProperty(runtime, "layoutMeasurement", layoutMeasurement);
+ }
+
+ payload.setProperty(runtime, "zoomScale", textInputMetrics.zoomScale ?: 1);
+
+
+ return payload;
+ };
+
static jsi::Value textInputMetricsContentSizePayload(
jsi::Runtime& runtime,
const TextInputMetrics& textInputMetrics) {
@@ -140,7 +188,9 @@ void TextInputEventEmitter::onKeyPressSync(
void TextInputEventEmitter::onScroll(
const TextInputMetrics& textInputMetrics) const {
- dispatchTextInputEvent("scroll", textInputMetrics);
+ dispatchEvent("scroll", [textInputMetrics](jsi::Runtime& runtime) {
+ return textInputMetricsScrollPayload(runtime, textInputMetrics);
+ });
}
void TextInputEventEmitter::dispatchTextInputEvent(