public void ConfigureCodeProperty(string propertyName, CodeNode codeNode, StringBuilder code) { var frame = (FigmaFrame)codeNode.Node; if (!codeNode.Node.visible) { code.WritePropertyEquality(codeNode.Name, nameof(NSView.Hidden), true); } if (propertyName == Properties.EdgeInsets) { var edgeInsets = typeof(NSEdgeInsets).GetConstructor( frame.verticalPadding.ToString(), frame.horizontalPadding.ToString(), frame.verticalPadding.ToString(), frame.horizontalPadding.ToString()); code.WritePropertyEquality(codeNode.Name, nameof(NSStackView.EdgeInsets), edgeInsets); return; } if (propertyName == Properties.Spacing) { code.WritePropertyEquality(codeNode.Name, nameof(NSStackView.Spacing), frame.itemSpacing.ToDesignerString()); return; } if (propertyName == Properties.Orientation) { var orientation = frame.LayoutMode == FigmaLayoutMode.Horizontal ? NSUserInterfaceLayoutOrientation.Horizontal : NSUserInterfaceLayoutOrientation.Vertical; code.WritePropertyEquality(codeNode.Name, nameof(NSStackView.Orientation), orientation.GetFullName()); return; } if (propertyName == Properties.Distribution) { codeNode.Node.TryGetAttributeValue(DistributionPropertyName, out var value); NSStackViewDistribution distribution = NSStackViewDistribution.Fill; if (!string.IsNullOrEmpty(value)) { var parameter = typeof(NSStackViewDistribution).WithProperty(value.ToCamelCase()); Enum.TryParse(parameter, out distribution);; } code.WritePropertyEquality(codeNode.Name, nameof(NSStackView.Distribution), distribution.GetFullName()); return; } }
public void ConfigureProperty(string propertyName, FigmaNode node, IView view) { var frame = (FigmaFrame)node; var stackView = (NSStackView)view.NativeObject; if (!node.visible) { stackView.Hidden = true; } if (propertyName == Properties.EdgeInsets) { stackView.EdgeInsets = new NSEdgeInsets( top: frame.verticalPadding, left: frame.horizontalPadding, bottom: frame.verticalPadding, right: frame.horizontalPadding ); return; } if (propertyName == Properties.Spacing) { stackView.Spacing = frame.itemSpacing; return; } if (propertyName == Properties.Orientation) { stackView.Orientation = frame.LayoutMode == FigmaLayoutMode.Horizontal ? NSUserInterfaceLayoutOrientation.Horizontal : NSUserInterfaceLayoutOrientation.Vertical; return; } if (propertyName == Properties.Distribution) { node.TryGetAttributeValue(DistributionPropertyName, out var value); NSStackViewDistribution distribution = NSStackViewDistribution.Fill; if (!string.IsNullOrEmpty(value)) { Enum.TryParse(value.ToCamelCase(), out distribution); } stackView.Distribution = distribution; return; } }