mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Migrate ReactTextInputEndEditingEvent to Kotlin (#50201)
Summary: Migrate com.facebook.react.views.textinput.ReactTextInputEndEditingEvent to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.views.textinput.ReactTextInputEndEditingEvent to Kotlin Pull Request resolved: https://github.com/facebook/react-native/pull/50201 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: javache Differential Revision: D71681473 Pulled By: arushikesarwani94 fbshipit-source-id: 4a1e3f3b56fa425e8e2bbcf8251eb05a572b329f
This commit is contained in:
1 parent
795e573f00
commit
e797b1659e
2 files changed
+43
-54
No files matched your search
-54
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.views.textinput;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.uimanager.common.ViewUtil;
|
||||
import com.facebook.react.uimanager.events.Event;
|
||||
|
||||
/**
|
||||
* Event emitted by EditText native view when text editing ends, because of the user leaving the
|
||||
* text input.
|
||||
*/
|
||||
class ReactTextInputEndEditingEvent extends Event<ReactTextInputEndEditingEvent> {
|
||||
|
||||
private static final String EVENT_NAME = "topEndEditing";
|
||||
|
||||
private String mText;
|
||||
|
||||
@Deprecated
|
||||
public ReactTextInputEndEditingEvent(int viewId, String text) {
|
||||
this(ViewUtil.NO_SURFACE_ID, viewId, text);
|
||||
}
|
||||
|
||||
public ReactTextInputEndEditingEvent(int surfaceId, int viewId, String text) {
|
||||
super(surfaceId, viewId);
|
||||
mText = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventName() {
|
||||
return EVENT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCoalesce() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected WritableMap getEventData() {
|
||||
WritableMap eventData = Arguments.createMap();
|
||||
eventData.putInt("target", getViewTag());
|
||||
eventData.putString("text", mText);
|
||||
return eventData;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.views.textinput
|
||||
|
||||
import com.facebook.react.bridge.Arguments
|
||||
import com.facebook.react.bridge.WritableMap
|
||||
import com.facebook.react.uimanager.common.ViewUtil
|
||||
import com.facebook.react.uimanager.events.Event
|
||||
|
||||
/**
|
||||
* Event emitted by EditText native view when text editing ends, because of the user leaving the
|
||||
* text input.
|
||||
*/
|
||||
internal class ReactTextInputEndEditingEvent(
|
||||
surfaceId: Int,
|
||||
viewId: Int,
|
||||
private val text: String
|
||||
) : Event<ReactTextInputEndEditingEvent>(surfaceId, viewId) {
|
||||
@Deprecated(
|
||||
"Use the constructor with surfaceId instead",
|
||||
ReplaceWith("ReactTextInputEndEditingEvent(surfaceId, viewId, text)"))
|
||||
constructor(viewId: Int, text: String) : this(ViewUtil.NO_SURFACE_ID, viewId, text)
|
||||
|
||||
override fun getEventName(): String = EVENT_NAME
|
||||
|
||||
override fun canCoalesce(): Boolean = false
|
||||
|
||||
override fun getEventData(): WritableMap? {
|
||||
return Arguments.createMap().apply {
|
||||
putInt("target", viewTag)
|
||||
putString("text", text)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val EVENT_NAME = "topEndEditing"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user