Fix setting component padding in Fabric

Summary: This diff fixes the issue with view paddings in Fabric introduced in D17081799. In Paper setting padding on a view was only supported for Text and TextInput components (see https://fburl.com/codesearch/6r6lu5vd). We want to keep Fabric backwards compatible, so we delegate setting the padding to the view manager instead of setting it directly on the view. In this way we can have a no-op implementation in the base view manager and implement this method only in view managers that support setting padding (ReactTextInputManager and ReactTextViewManager at the moment).

Reviewed By: JoshuaGross

Differential Revision: D17665011

fbshipit-source-id: 38bc56278e002bd34881cfcb9ed79df579f79e28
This commit is contained in:
Oleksandr Melnykov authored and Facebook Github Bot committed 2019-10-01 11:38:21 -07:00
1 parent 601981a67d
commit 769d51824e
4 files changed
+23 -3

No files matched your search

@@ -297,4 +297,10 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
YogaMeasureMode heightMode) {
return 0;
}
/**
* Subclasses can override this method to set padding for the given View in Fabric. Since not all
* components support setting padding, the default implementation of this method does nothing.
*/
public void setPadding(T view, int left, int top, int right, int bottom) {}
}