protected void RecursivelyConfigureViews(ProcessedNode parentNode, FigmaViewRendererServiceOptions options) { var children = NodesProcessed.Where(s => s.ParentView == parentNode); foreach (var child in children) { if (child.View == null) { Console.WriteLine("Node {0} has no view to process... skipping", child.FigmaNode); continue; } if (RendersAddChild(child, parentNode, this)) { PropertySetter.Configure(CodeProperties.AddChild, child.View, child.FigmaNode, parentNode.View, parentNode.FigmaNode, this); } if (RendersSize(child, parentNode, this)) { PropertySetter.Configure(CodeProperties.Frame, child.View, child.FigmaNode, parentNode.View, parentNode.FigmaNode, this); } if (RendersConstraints(child, parentNode, this)) { PropertySetter.Configure(CodeProperties.Constraints, child.View, child.FigmaNode, parentNode.View, parentNode.FigmaNode, this); } RecursivelyConfigureViews(child, options); } }
void Recursively(ProcessedNode parentNode) { var children = NodesProcessed.Where(s => s.ParentView == parentNode); foreach (var child in children) { if (child.View == null) { Console.WriteLine("Node {0} has no view to process... skipping", child.FigmaNode); continue; } if (child.FigmaNode is IAbsoluteBoundingBox absoluteBounding && parentNode.FigmaNode is IAbsoluteBoundingBox parentAbsoluteBoundingBox) { parentNode.View.AddChild(child.View); var x = Math.Max(absoluteBounding.absoluteBoundingBox.X - parentAbsoluteBoundingBox.absoluteBoundingBox.X, 0); float y; if (AppContext.Current.IsVerticalAxisFlipped) { var parentY = parentAbsoluteBoundingBox.absoluteBoundingBox.Y + parentAbsoluteBoundingBox.absoluteBoundingBox.Height; var actualY = absoluteBounding.absoluteBoundingBox.Y + absoluteBounding.absoluteBoundingBox.Height; y = parentY - actualY; } else { y = absoluteBounding.absoluteBoundingBox.Y - parentAbsoluteBoundingBox.absoluteBoundingBox.Y; } child.View.SetAllocation(x, y, Math.Max(absoluteBounding.absoluteBoundingBox.Width, 1), Math.Max(1, absoluteBounding.absoluteBoundingBox.Height) ); //we need to ensure current view is in height //var instrinsic = child.View.IntrinsicContentSize; //child.View.SetAllocation(x, y, // Math.Max (instrinsic.Width, Math.Max(absoluteBounding.absoluteBoundingBox.Width, 1)), // Math.Max (instrinsic.Height, Math.Max(1, absoluteBounding.absoluteBoundingBox.Height)) // ); } Recursively(child); } }