Dont measure edittext with padding
Reviewed By: astreet Differential Revision: D4383821 fbshipit-source-id: 9a75b7131ba8e79671f6793276a18efea10b60d1
This commit is contained in:
parent
8f87ab648c
commit
ef9e855692
|
@ -43,7 +43,6 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
|
||||||
YogaMeasureFunction {
|
YogaMeasureFunction {
|
||||||
|
|
||||||
private @Nullable EditText mEditText;
|
private @Nullable EditText mEditText;
|
||||||
private @Nullable float[] mComputedPadding;
|
|
||||||
private int mJsEventCount = UNSET;
|
private int mJsEventCount = UNSET;
|
||||||
|
|
||||||
public ReactTextInputShadowNode() {
|
public ReactTextInputShadowNode() {
|
||||||
|
@ -69,12 +68,7 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
|
||||||
setDefaultPadding(Spacing.TOP, mEditText.getPaddingTop());
|
setDefaultPadding(Spacing.TOP, mEditText.getPaddingTop());
|
||||||
setDefaultPadding(Spacing.END, mEditText.getPaddingEnd());
|
setDefaultPadding(Spacing.END, mEditText.getPaddingEnd());
|
||||||
setDefaultPadding(Spacing.BOTTOM, mEditText.getPaddingBottom());
|
setDefaultPadding(Spacing.BOTTOM, mEditText.getPaddingBottom());
|
||||||
mComputedPadding = new float[] {
|
mEditText.setPadding(0, 0, 0, 0);
|
||||||
getPadding(Spacing.START),
|
|
||||||
getPadding(Spacing.TOP),
|
|
||||||
getPadding(Spacing.END),
|
|
||||||
getPadding(Spacing.BOTTOM),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,17 +85,6 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
|
||||||
TypedValue.COMPLEX_UNIT_PX,
|
TypedValue.COMPLEX_UNIT_PX,
|
||||||
mFontSize == UNSET ?
|
mFontSize == UNSET ?
|
||||||
(int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);
|
(int) Math.ceil(PixelUtil.toPixelFromSP(ViewDefaults.FONT_SIZE_SP)) : mFontSize);
|
||||||
mComputedPadding = new float[] {
|
|
||||||
getPadding(Spacing.START),
|
|
||||||
getPadding(Spacing.TOP),
|
|
||||||
getPadding(Spacing.END),
|
|
||||||
getPadding(Spacing.BOTTOM),
|
|
||||||
};
|
|
||||||
editText.setPadding(
|
|
||||||
(int) Math.floor(getPadding(Spacing.START)),
|
|
||||||
(int) Math.floor(getPadding(Spacing.TOP)),
|
|
||||||
(int) Math.floor(getPadding(Spacing.END)),
|
|
||||||
(int) Math.floor(getPadding(Spacing.BOTTOM)));
|
|
||||||
|
|
||||||
if (mNumberOfLines != UNSET) {
|
if (mNumberOfLines != UNSET) {
|
||||||
editText.setLines(mNumberOfLines);
|
editText.setLines(mNumberOfLines);
|
||||||
|
@ -151,19 +134,6 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
|
||||||
@Override
|
@Override
|
||||||
public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
|
public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
|
||||||
super.onCollectExtraUpdates(uiViewOperationQueue);
|
super.onCollectExtraUpdates(uiViewOperationQueue);
|
||||||
if (mComputedPadding != null) {
|
|
||||||
float[] updatedPadding = mComputedPadding;
|
|
||||||
if (getLayoutDirection() == YogaDirection.RTL) {
|
|
||||||
updatedPadding = new float[] {
|
|
||||||
getPadding(Spacing.END),
|
|
||||||
getPadding(Spacing.TOP),
|
|
||||||
getPadding(Spacing.START),
|
|
||||||
getPadding(Spacing.BOTTOM),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), updatedPadding);
|
|
||||||
mComputedPadding = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mJsEventCount != UNSET) {
|
if (mJsEventCount != UNSET) {
|
||||||
Spannable preparedSpannableText = fromTextCSSNode(this);
|
Spannable preparedSpannableText = fromTextCSSNode(this);
|
||||||
|
@ -172,9 +142,9 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
|
||||||
preparedSpannableText,
|
preparedSpannableText,
|
||||||
mJsEventCount,
|
mJsEventCount,
|
||||||
mContainsImages,
|
mContainsImages,
|
||||||
getPadding(Spacing.START),
|
getPadding(Spacing.LEFT),
|
||||||
getPadding(Spacing.TOP),
|
getPadding(Spacing.TOP),
|
||||||
getPadding(Spacing.END),
|
getPadding(Spacing.RIGHT),
|
||||||
getPadding(Spacing.BOTTOM),
|
getPadding(Spacing.BOTTOM),
|
||||||
mTextAlign,
|
mTextAlign,
|
||||||
mTextBreakStrategy
|
mTextBreakStrategy
|
||||||
|
@ -186,12 +156,6 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
|
||||||
@Override
|
@Override
|
||||||
public void setPadding(int spacingType, float padding) {
|
public void setPadding(int spacingType, float padding) {
|
||||||
super.setPadding(spacingType, padding);
|
super.setPadding(spacingType, padding);
|
||||||
mComputedPadding = new float[] {
|
|
||||||
getPadding(Spacing.START),
|
|
||||||
getPadding(Spacing.TOP),
|
|
||||||
getPadding(Spacing.END),
|
|
||||||
getPadding(Spacing.BOTTOM),
|
|
||||||
};
|
|
||||||
markUpdated();
|
markUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue