Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,53 @@ 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this check needed? Isn't zoomScale always set from Objective-C?

If is isn't, wouldn't it be better to assign a default value to zoomScale?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just kept the same as Old arch

. Seems the default zoomScale should be 1.0, and we think 0 is a invalid value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's fair. Thanks for the clarification.


return payload;
};

static jsi::Value textInputMetricsContentSizePayload(
jsi::Runtime& runtime,
const TextInputMetrics& textInputMetrics) {
Expand Down Expand Up @@ -121,7 +168,12 @@ void TextInputEventEmitter::onKeyPress(

void TextInputEventEmitter::onScroll(
const TextInputMetrics& textInputMetrics) const {
dispatchTextInputEvent("scroll", textInputMetrics);
dispatchEvent(
"scroll",
[textInputMetrics](jsi::Runtime& runtime) {
return textInputMetricsScrollPayload(runtime, textInputMetrics);
},
EventPriority::AsynchronousBatched);
}

void TextInputEventEmitter::dispatchTextInputEvent(
Expand Down