mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-28 21:48:13 +08:00
feat(android): support padding for TextInput
This commit is contained in:
+9
-8
@@ -50,6 +50,7 @@ import com.tencent.mtt.hippy.views.hippypager.HippyPager;
|
||||
import com.tencent.renderer.NativeRender;
|
||||
import com.tencent.renderer.NativeRenderException;
|
||||
import com.tencent.renderer.NativeRendererManager;
|
||||
import com.tencent.renderer.component.text.TextRenderSupplier;
|
||||
import com.tencent.renderer.node.TextVirtualNode;
|
||||
import com.tencent.renderer.utils.ArrayUtils;
|
||||
|
||||
@@ -87,14 +88,14 @@ public class HippyTextInputController extends HippyViewController<HippyTextInput
|
||||
protected void updateExtra(@NonNull View view, Object object) {
|
||||
super.updateExtra(view, object);
|
||||
|
||||
// if (object instanceof TextExtra) {
|
||||
// TextExtra textExtra = (TextExtra) object;
|
||||
// HippyTextInput hippyTextInput = (HippyTextInput) view;
|
||||
// hippyTextInput.setPadding((int) Math.ceil(textExtra.mLeftPadding),
|
||||
// (int) Math.ceil(textExtra.mTopPadding),
|
||||
// (int) Math.ceil(textExtra.mRightPadding),
|
||||
// (int) Math.ceil(textExtra.mBottomPadding));
|
||||
// }
|
||||
if (object instanceof TextRenderSupplier) {
|
||||
TextRenderSupplier supplier = (TextRenderSupplier) object;
|
||||
HippyTextInput hippyTextInput = (HippyTextInput) view;
|
||||
hippyTextInput.setPadding((int) Math.ceil(supplier.leftPadding),
|
||||
(int) Math.ceil(supplier.topPadding),
|
||||
(int) Math.ceil(supplier.rightPadding),
|
||||
(int) Math.ceil(supplier.bottomPadding));
|
||||
}
|
||||
}
|
||||
|
||||
@HippyControllerProps(name = NodeProps.FONT_SIZE, defaultType = HippyControllerProps.NUMBER, defaultNumber = 14)
|
||||
|
||||
@@ -645,6 +645,7 @@ public class RenderNode {
|
||||
component.setTextLayout(object);
|
||||
setNodeFlag(FLAG_UPDATE_EXTRA);
|
||||
}
|
||||
mExtra = object;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
|
||||
+12
-7
@@ -138,7 +138,7 @@ public class VirtualNodeManager {
|
||||
public TextRenderSupplier updateLayout(int rootId, int nodeId, float width,
|
||||
Map<String, Object> layoutInfo) {
|
||||
VirtualNode node = getVirtualNode(rootId, nodeId);
|
||||
if (!(node instanceof TextVirtualNode) || node.mParent != null) {
|
||||
if (!(node instanceof TextVirtualNode || node instanceof TextInputVirtualNode) || node.mParent != null) {
|
||||
return null;
|
||||
}
|
||||
float leftPadding = 0;
|
||||
@@ -159,12 +159,17 @@ public class VirtualNodeManager {
|
||||
// just ignore this exception
|
||||
LogUtils.w(TAG, "VirtualNode updateLayout get padding exception: " + e.getMessage());
|
||||
}
|
||||
Layout layout = ((TextVirtualNode) node)
|
||||
.createLayout((width - leftPadding - rightPadding), FlexMeasureMode.EXACTLY);
|
||||
// Layout has update here, not need to rebuild in end batch, so remove node ref from mUpdateNodes.
|
||||
List<VirtualNode> updateNodes = mUpdateNodes.get(rootId);
|
||||
if (updateNodes != null) {
|
||||
updateNodes.remove(node);
|
||||
final Layout layout;
|
||||
if (node instanceof TextVirtualNode) {
|
||||
layout = ((TextVirtualNode) node)
|
||||
.createLayout((width - leftPadding - rightPadding), FlexMeasureMode.EXACTLY);
|
||||
// Layout has update here, not need to rebuild in end batch, so remove node ref from mUpdateNodes.
|
||||
List<VirtualNode> updateNodes = mUpdateNodes.get(rootId);
|
||||
if (updateNodes != null) {
|
||||
updateNodes.remove(node);
|
||||
}
|
||||
} else {
|
||||
layout = null;
|
||||
}
|
||||
return new TextRenderSupplier(layout, leftPadding, topPadding,
|
||||
rightPadding, bottomPadding);
|
||||
|
||||
Reference in New Issue
Block a user