diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index f5c0584047e..41ac4b42f16 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -7,10 +7,6 @@ package com.facebook.react.views.textinput; -import static com.facebook.react.uimanager.UIManagerHelper.PADDING_BOTTOM_INDEX; -import static com.facebook.react.uimanager.UIManagerHelper.PADDING_END_INDEX; -import static com.facebook.react.uimanager.UIManagerHelper.PADDING_START_INDEX; -import static com.facebook.react.uimanager.UIManagerHelper.PADDING_TOP_INDEX; import static com.facebook.react.uimanager.UIManagerHelper.getReactContext; import android.content.Context; @@ -1241,38 +1237,6 @@ public class ReactTextInputManager extends BaseViewManagergetSurfaceId(); - float defaultThemePaddingStart = NAN; - float defaultThemePaddingEnd = NAN; - float defaultThemePaddingTop = NAN; - float defaultThemePaddingBottom = NAN; - + YGStyle::Edges theme; + // TODO: figure out RTL/start/end/left/right stuff here if (surfaceIdToThemePaddingMap_.find(surfaceId) != surfaceIdToThemePaddingMap_.end()) { - YGStyle::Edges theme = surfaceIdToThemePaddingMap_[surfaceId]; - defaultThemePaddingStart = ((YGValue)theme[YGEdgeStart]).value; - defaultThemePaddingEnd = ((YGValue)theme[YGEdgeEnd]).value; - defaultThemePaddingTop = ((YGValue)theme[YGEdgeTop]).value; - defaultThemePaddingBottom = ((YGValue)theme[YGEdgeBottom]).value; + theme = surfaceIdToThemePaddingMap_[surfaceId]; } else { const jni::global_ref &fabricUIManager = contextContainer_->at>("FabricUIManager"); @@ -63,10 +56,12 @@ class AndroidTextInputComponentDescriptor final fabricUIManager, surfaceId, defaultTextInputPaddingArray)) { jfloat *defaultTextInputPadding = env->GetFloatArrayElements(defaultTextInputPaddingArray, 0); - defaultThemePaddingStart = defaultTextInputPadding[0]; - defaultThemePaddingEnd = defaultTextInputPadding[1]; - defaultThemePaddingTop = defaultTextInputPadding[2]; - defaultThemePaddingBottom = defaultTextInputPadding[3]; + theme[YGEdgeStart] = (YGValue){defaultTextInputPadding[0], YGUnitPoint}; + theme[YGEdgeEnd] = (YGValue){defaultTextInputPadding[1], YGUnitPoint}; + theme[YGEdgeTop] = (YGValue){defaultTextInputPadding[2], YGUnitPoint}; + theme[YGEdgeBottom] = + (YGValue){defaultTextInputPadding[3], YGUnitPoint}; + surfaceIdToThemePaddingMap_.emplace(std::make_pair(surfaceId, theme)); } env->DeleteLocalRef(defaultTextInputPaddingArray); } @@ -80,10 +75,10 @@ class AndroidTextInputComponentDescriptor final {}, {}, textLayoutManager_, - defaultThemePaddingStart, - defaultThemePaddingEnd, - defaultThemePaddingTop, - defaultThemePaddingBottom)), + ((YGValue)theme[YGEdgeStart]).value, + ((YGValue)theme[YGEdgeEnd]).value, + ((YGValue)theme[YGEdgeTop]).value, + ((YGValue)theme[YGEdgeBottom]).value)), family); } @@ -100,27 +95,7 @@ class AndroidTextInputComponentDescriptor final textInputShadowNode->setContextContainer( const_cast(getContextContainer().get())); - // Get theme padding from cache, or set it from State. - // In theory, the Java ViewManager for TextInput should need to set state - // *exactly once* per surface to communicate the correct default padding, - // which will be cached here in C++. - // TODO T63008435: can this feature be removed entirely? - // TODO: figure out RTL/start/end/left/right stuff here int surfaceId = textInputShadowNode->getSurfaceId(); - const AndroidTextInputState &state = textInputShadowNode->getStateData(); - if (surfaceIdToThemePaddingMap_.find(surfaceId) == - surfaceIdToThemePaddingMap_.end() && - !isnan(state.defaultThemePaddingStart)) { - YGStyle::Edges result; - result[YGEdgeStart] = - (YGValue){state.defaultThemePaddingStart, YGUnitPoint}; - result[YGEdgeEnd] = (YGValue){state.defaultThemePaddingEnd, YGUnitPoint}; - result[YGEdgeTop] = (YGValue){state.defaultThemePaddingTop, YGUnitPoint}; - result[YGEdgeBottom] = - (YGValue){state.defaultThemePaddingBottom, YGUnitPoint}; - surfaceIdToThemePaddingMap_.emplace(std::make_pair(surfaceId, result)); - } - if (surfaceIdToThemePaddingMap_.find(surfaceId) != surfaceIdToThemePaddingMap_.end()) { YGStyle::Edges theme = surfaceIdToThemePaddingMap_[surfaceId]; diff --git a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp index 0128c17f00e..4e37be0aa6f 100644 --- a/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp +++ b/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp @@ -21,7 +21,6 @@ folly::dynamic AndroidTextInputState::getDynamic() const { newState["attributedString"] = toDynamic(attributedString); newState["paragraphAttributes"] = toDynamic(paragraphAttributes); newState["hash"] = newState["attributedString"]["hash"]; - newState["hasThemeData"] = !isnan(defaultThemePaddingStart); return newState; } #endif