in FigmaSharp.Controls/FigmaSharp.Controls.Cocoa/Converters/Controls/BoxConverter.cs [55:111]
protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
{
var frame = (FigmaFrame)currentNode;
var box = new NSBox();
currentNode.TryGetNativeControlType(out FigmaControlType controlType);
if (controlType == FigmaControlType.Separator)
box.BoxType = NSBoxType.NSBoxSeparator;
if (controlType == FigmaControlType.BoxCustom)
{
box.BoxType = NSBoxType.NSBoxCustom;
box.BorderWidth = 0;
RectangleVector rectangle = frame.children
.OfType<RectangleVector>()
.FirstOrDefault();
if (rectangle != null)
{
if (rectangle.styles != null)
{
foreach (var styleMap in rectangle.styles)
{
if (rendererService.NodeProvider.TryGetStyle(styleMap.Value, out FigmaStyle style))
{
if (styleMap.Key == "fill")
box.FillColor = ColorService.GetNSColor(style.name);
if (styleMap.Key == "stroke")
{
box.BorderColor = ColorService.GetNSColor(style.name);
box.BorderWidth = rectangle.strokeWeight;
}
}
}
}
box.CornerRadius = rectangle.cornerRadius;
}
}
if (controlType == FigmaControlType.Box)
{
FigmaText text = frame.children
.OfType<FigmaText>()
.FirstOrDefault(s => (s.name == ComponentString.TITLE && s.visible));
if (text != null)
box.Title = rendererService.GetTranslatedText (text);
else
box.Title = string.Empty;
}
return new View(box);
}