mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate ReactTextInputKeyPressEvent to Kotlin (#50184)
Summary: Migrate com.facebook.react.views.textinput.ReactTextInputKeyPressEvent to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.views.textinput.ReactTextInputKeyPressEvent to Kotlin Pull Request resolved: https://github.com/facebook/react-native/pull/50184 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: javache Differential Revision: D71588770 Pulled By: arushikesarwani94 fbshipit-source-id: 53354d9cd8cc24b9ec6f84de689ea4b2839e49ce
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d9876d8dc9
commit
345403f042
-51
@@ -1,51 +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 key pressed */
|
||||
/* package */ class ReactTextInputKeyPressEvent extends Event<ReactTextInputKeyPressEvent> {
|
||||
|
||||
public static final String EVENT_NAME = "topKeyPress";
|
||||
|
||||
private String mKey;
|
||||
|
||||
@Deprecated
|
||||
ReactTextInputKeyPressEvent(int viewId, final String key) {
|
||||
this(ViewUtil.NO_SURFACE_ID, viewId, key);
|
||||
}
|
||||
|
||||
ReactTextInputKeyPressEvent(int surfaceId, int viewId, final String key) {
|
||||
super(surfaceId, viewId);
|
||||
mKey = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventName() {
|
||||
return EVENT_NAME;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected WritableMap getEventData() {
|
||||
WritableMap eventData = Arguments.createMap();
|
||||
eventData.putString("key", mKey);
|
||||
return eventData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCoalesce() {
|
||||
// We don't want to miss any textinput event, as event data is incremental.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 key pressed. */
|
||||
internal class ReactTextInputKeyPressEvent(surfaceId: Int, viewId: Int, private val key: String) :
|
||||
Event<ReactTextInputKeyPressEvent>(surfaceId, viewId) {
|
||||
@Deprecated(
|
||||
"Use the constructor with surfaceId instead",
|
||||
ReplaceWith("ReactTextInputKeyPressEvent(surfaceId, viewId, key)"))
|
||||
constructor(viewId: Int, key: String) : this(ViewUtil.NO_SURFACE_ID, viewId, key)
|
||||
|
||||
override fun getEventName(): String = EVENT_NAME
|
||||
|
||||
override fun getEventData(): WritableMap? {
|
||||
return Arguments.createMap().apply { putString("key", key) }
|
||||
}
|
||||
|
||||
// We don't want to miss any textinput event, as event data is incremental.
|
||||
override fun canCoalesce(): Boolean = false
|
||||
|
||||
companion object {
|
||||
const val EVENT_NAME: String = "topKeyPress"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user