mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate ReactTextInputLocalData to Kotlin (#50183)
Summary: Migrate com.facebook.react.views.textinput.ReactTextInputLocalData to Kotlin. ## Changelog: [INTERNAL] - Migrate com.facebook.react.views.textinput.ReactTextInputLocalData to Kotlin Pull Request resolved: https://github.com/facebook/react-native/pull/50183 Test Plan: ```bash yarn test-android yarn android ``` Reviewed By: javache Differential Revision: D71589108 Pulled By: arushikesarwani94 fbshipit-source-id: e460518ffca43346f32ea0742ef656d72f5ed2d5
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a670c9aeb3
commit
7358fcf10f
@@ -7131,7 +7131,7 @@ public class com/facebook/react/views/textinput/ReactTextChangedEvent : com/face
|
||||
|
||||
public final class com/facebook/react/views/textinput/ReactTextInputLocalData {
|
||||
public fun <init> (Landroid/widget/EditText;)V
|
||||
public fun apply (Landroid/widget/EditText;)V
|
||||
public final fun apply (Landroid/widget/EditText;)V
|
||||
}
|
||||
|
||||
public class com/facebook/react/views/textinput/ReactTextInputManager : com/facebook/react/uimanager/BaseViewManager {
|
||||
|
||||
-44
@@ -1,44 +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 android.text.SpannableStringBuilder;
|
||||
import android.util.TypedValue;
|
||||
import android.widget.EditText;
|
||||
|
||||
/** Local state bearer for EditText instance. */
|
||||
public final class ReactTextInputLocalData {
|
||||
|
||||
private final SpannableStringBuilder mText;
|
||||
private final float mTextSize;
|
||||
private final int mMinLines;
|
||||
private final int mMaxLines;
|
||||
private final int mInputType;
|
||||
private final int mBreakStrategy;
|
||||
private final CharSequence mPlaceholder;
|
||||
|
||||
public ReactTextInputLocalData(EditText editText) {
|
||||
mText = new SpannableStringBuilder(editText.getText());
|
||||
mTextSize = editText.getTextSize();
|
||||
mInputType = editText.getInputType();
|
||||
mPlaceholder = editText.getHint();
|
||||
mMinLines = editText.getMinLines();
|
||||
mMaxLines = editText.getMaxLines();
|
||||
mBreakStrategy = editText.getBreakStrategy();
|
||||
}
|
||||
|
||||
public void apply(EditText editText) {
|
||||
editText.setText(mText);
|
||||
editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
|
||||
editText.setMinLines(mMinLines);
|
||||
editText.setMaxLines(mMaxLines);
|
||||
editText.setInputType(mInputType);
|
||||
editText.setHint(mPlaceholder);
|
||||
editText.setBreakStrategy(mBreakStrategy);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 android.text.SpannableStringBuilder
|
||||
import android.util.TypedValue
|
||||
import android.widget.EditText
|
||||
|
||||
/** Local state bearer for EditText instance. */
|
||||
public class ReactTextInputLocalData(editText: EditText) {
|
||||
private val text = SpannableStringBuilder(editText.text)
|
||||
private val textSize = editText.textSize
|
||||
private val minLines = editText.minLines
|
||||
private val maxLines = editText.maxLines
|
||||
private val inputType = editText.inputType
|
||||
private val breakStrategy = editText.breakStrategy
|
||||
private val placeholder: CharSequence? = editText.hint
|
||||
|
||||
public fun apply(editText: EditText) {
|
||||
editText.text = text
|
||||
editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
editText.minLines = minLines
|
||||
editText.maxLines = maxLines
|
||||
editText.inputType = inputType
|
||||
editText.hint = placeholder
|
||||
editText.breakStrategy = breakStrategy
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user