Fix TextInput's initial layout measurements
Reviewed By: mdvacca Differential Revision: D7732819 fbshipit-source-id: 0ca4e5643d2cfefe304d7f189474a671c4bcb31e
This commit is contained in:
parent
5fc42f308a
commit
c6b4f9f2ce
|
@ -9,16 +9,19 @@ package com.facebook.react.views.textinput;
|
|||
|
||||
import android.os.Build;
|
||||
import android.text.Layout;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.uimanager.LayoutShadowNode;
|
||||
import com.facebook.react.uimanager.PixelUtil;
|
||||
import com.facebook.react.uimanager.ReactShadowNodeImpl;
|
||||
import com.facebook.react.uimanager.Spacing;
|
||||
import com.facebook.react.uimanager.ThemedReactContext;
|
||||
import com.facebook.react.uimanager.UIViewOperationQueue;
|
||||
import com.facebook.react.uimanager.ViewDefaults;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.views.text.ReactBaseTextShadowNode;
|
||||
import com.facebook.react.views.text.ReactTextUpdate;
|
||||
|
@ -127,12 +130,24 @@ public class ReactTextInputShadowNode extends ReactBaseTextShadowNode
|
|||
// measure() should never be called before setThemedContext()
|
||||
EditText editText = Assertions.assertNotNull(mDummyEditText);
|
||||
|
||||
if (mLocalData == null) {
|
||||
// No local data, no intrinsic size.
|
||||
return YogaMeasureOutput.make(0, 0);
|
||||
if (mLocalData != null) {
|
||||
mLocalData.apply(editText);
|
||||
} else {
|
||||
editText.setTextSize(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
mFontSize == UNSET ?
|
||||
(int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);
|
||||
|
||||
if (mNumberOfLines != UNSET) {
|
||||
editText.setLines(mNumberOfLines);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
|
||||
editText.getBreakStrategy() != mTextBreakStrategy) {
|
||||
editText.setBreakStrategy(mTextBreakStrategy);
|
||||
}
|
||||
}
|
||||
|
||||
mLocalData.apply(editText);
|
||||
|
||||
editText.measure(
|
||||
MeasureUtil.getMeasureSpec(width, widthMode),
|
||||
|
|
Loading…
Reference in New Issue