recombineNode method

void recombineNode(
  1. int instanceId,
  2. List<int> moveIds,
  3. int oldPId,
  4. int moveIndex,
  5. int newPId,
)

用于跨父节点移动子节点

Implementation

void recombineNode(
  int instanceId,
  List<int> moveIds,
  int oldPId,
  int moveIndex,
  int newPId,
) {
  var parentNode = controllerManager.findNode(instanceId, oldPId);
  var newParent = controllerManager.findNode(instanceId, newPId);
  if (parentNode != null && newParent != null) {
    var arrayList = <RenderNode>[];

    var i = 0;
    for (var moveId in moveIds) {
      var renderNode = controllerManager.findNode(instanceId, moveId);
      if (renderNode != null) {
        LogUtils.dRender(
          "ID:$moveId, move node ID:$moveId from ${parentNode.id} to ${newParent.id}",
        );
        arrayList.add(renderNode);
        parentNode.removeChild(renderNode, needRemoveChild: false);
        newParent.addChild(renderNode, i + moveIndex);
        i++;
      }
    }
    parentNode.move(arrayList, newParent);
    addUpdateNodeIfNeeded(newParent);
  }
}