protected override IView OnConvertToView()

in FigmaSharp.Controls/FigmaSharp.Controls.Cocoa/Converters/Controls/OutlineViewConverter.cs [53:124]


        protected override IView OnConvertToView (FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var frame = (FigmaFrame)currentNode;
            var outlineView = new NSOutlineView();


            var columnNodes = frame.FirstChild (s => s.name == ComponentString.COLUMNS && s.visible);

            NSScrollView scrollView = new NSScrollView();
            scrollView.AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable;
            scrollView.BorderType = NSBorderType.BezelBorder;
            scrollView.DrawsBackground = true;
            scrollView.DocumentView = outlineView;

            outlineView.DataSource = new OutlineDataSource();
            outlineView.Delegate   = new OutlineDelegate();

            if (columnNodes == null)
            {
                outlineView.HeaderView = null;
                return new View(scrollView);
            }

            // TODO: Parse options layers
            outlineView.UsesAlternatingRowBackgroundColors = false;
            outlineView.AllowsMultipleSelection = false;
            outlineView.AllowsColumnResizing = true;
            outlineView.AllowsColumnReordering = false;
            outlineView.AllowsEmptySelection = false;

            int columnCount = 1;
            foreach (FigmaNode tableColumNode in columnNodes.GetChildren(t => t.visible))
            {
                FigmaText text = tableColumNode.FirstChild(s => s.name == ComponentString.TITLE) as FigmaText;

                if (text == null)
                    continue;
                
                string title = text.characters;

                NSTableColumn column = new NSTableColumn();

                column.HeaderCell.Alignment = Helpers.ViewHelper.GetNSTextAlignment(text);
                column.Identifier = "Column" + columnCount;
                column.Title = rendererService.GetTranslatedText(text);
                column.Width = (tableColumNode as FigmaFrame).absoluteBoundingBox.Width;

                if (columnCount == 1)
                    outlineView.OutlineTableColumn = column;

                outlineView.AddColumn(column);
                columnCount++;
            }


            var rectangle = (RectangleVector) frame.FirstChild(s => s.name == ComponentString.BACKGROUND && s.visible);

            if (rectangle != null)
            {
                foreach (var styleMap in rectangle.styles)
                {
                    if (rendererService.NodeProvider.TryGetStyle(styleMap.Value, out FigmaStyle style) &&
                        styleMap.Key == "fill")
                    {
                            outlineView.BackgroundColor = ColorService.GetNSColor(style.name);
                    }
                }
            }


            return new View(scrollView);
        }