mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate ReactTextInputSelectionEvent to Kotlin (#50182)
Summary: Migrate com.facebook.react.views.textinput.ReactTextInputSelectionEvent to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.views.textinput.ReactTextInputSelectionEvent to Kotlin Pull Request resolved: https://github.com/facebook/react-native/pull/50182 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: javache Differential Revision: D71589613 Pulled By: arushikesarwani94 fbshipit-source-id: 5a93834b8e450e63629f409cd7711b7b0850e288
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c72d4c5ee9
commit
a670c9aeb3
-53
@@ -1,53 +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 the text selection changes. */
|
||||
/* package */ class ReactTextInputSelectionEvent extends Event<ReactTextInputSelectionEvent> {
|
||||
|
||||
private static final String EVENT_NAME = "topSelectionChange";
|
||||
|
||||
private int mSelectionStart;
|
||||
private int mSelectionEnd;
|
||||
|
||||
@Deprecated
|
||||
public ReactTextInputSelectionEvent(int viewId, int selectionStart, int selectionEnd) {
|
||||
this(ViewUtil.NO_SURFACE_ID, viewId, selectionStart, selectionEnd);
|
||||
}
|
||||
|
||||
public ReactTextInputSelectionEvent(
|
||||
int surfaceId, int viewId, int selectionStart, int selectionEnd) {
|
||||
super(surfaceId, viewId);
|
||||
mSelectionStart = selectionStart;
|
||||
mSelectionEnd = selectionEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventName() {
|
||||
return EVENT_NAME;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected WritableMap getEventData() {
|
||||
WritableMap eventData = Arguments.createMap();
|
||||
|
||||
WritableMap selectionData = Arguments.createMap();
|
||||
selectionData.putInt("end", mSelectionEnd);
|
||||
selectionData.putInt("start", mSelectionStart);
|
||||
|
||||
eventData.putMap("selection", selectionData);
|
||||
return eventData;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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 the text selection changes. */
|
||||
internal class ReactTextInputSelectionEvent(
|
||||
surfaceId: Int,
|
||||
viewId: Int,
|
||||
private val selectionStart: Int,
|
||||
private val selectionEnd: Int
|
||||
) : Event<ReactTextInputSelectionEvent>(surfaceId, viewId) {
|
||||
@Deprecated(
|
||||
"Use the constructor with surfaceId instead",
|
||||
ReplaceWith("ReactTextInputSelectionEvent(surfaceId, viewId, selectionStart, selectionEnd)"))
|
||||
constructor(
|
||||
viewId: Int,
|
||||
selectionStart: Int,
|
||||
selectionEnd: Int
|
||||
) : this(ViewUtil.NO_SURFACE_ID, viewId, selectionStart, selectionEnd)
|
||||
|
||||
override fun getEventName(): String = EVENT_NAME
|
||||
|
||||
override fun getEventData(): WritableMap? {
|
||||
val selectionData =
|
||||
Arguments.createMap().apply {
|
||||
putInt("end", selectionEnd)
|
||||
putInt("start", selectionStart)
|
||||
}
|
||||
|
||||
return Arguments.createMap().apply { putMap("selection", selectionData) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val EVENT_NAME = "topSelectionChange"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user