public void GetCode(StringBuilder builder, FigmaNode node, string name, string parent)
        {
            if (parent == null)
            {
                identifiers.Clear();
            }

            var converter = GetConverter(node, customConverters);

            bool navigateChild = true;

            if (converter == null)
            {
                converter = GetConverter(node, figmaConverters);
            }
            else
            {
                navigateChild = false;
            }

            if (converter != null)
            {
                var code = converter.ConvertToCode(node, this);

                if (name == null)
                {
                    name = TryAddIdentifier(node.GetType());
                }

                builder.AppendLine(code.Replace("[NAME]", name));
                if (parent != null)
                {
                    builder.AppendLine(codeAddChildConverter.ConvertToCode(parent, name, node));
                    builder.AppendLine(codePositionConverter.ConvertToCode(parent, name, node));
                }
            }

            if (navigateChild && node is IFigmaNodeContainer nodeContainer)
            {
                foreach (var item in nodeContainer.children)
                {
                    GetCode(builder, item, null, name);
                }
            }
        }
 public override bool CanConvert(FigmaNode currentNode)
 {
     return(currentNode.GetType() == typeof(FigmaText));
 }
Example #3
0
 public override bool CanConvert(FigmaNode currentNode)
 {
     return(currentNode.GetType() == typeof(FigmaRegularPolygon));
 }
Example #4
0
        //TODO: This
        protected void GenerateViewsRecursively(FigmaNode currentNode, ViewNode parent, ViewRenderServiceOptions options)
        {
            Console.WriteLine("[{0}.{1}] Processing {2}..", currentNode?.id, currentNode?.name, currentNode?.GetType());

            //if (currentNode.name.StartsWith ("#") || currentNode.name.StartsWith ("//")) {
            //    Console.WriteLine ("[{0}.{1}] Detected skipped flag in name.. Skipping...", currentNode?.id, currentNode?.name, currentNode?.GetType ());
            //    return;
            //}

            if (SkipsNode(currentNode, parent, options))
            {
                return;
            }

            var converter = GetConverter(currentNode);

            ViewNode currentProcessedNode = null;

            if (converter != null)
            {
                var currentView = options.IsToViewProcessed ? converter.ConvertToView(currentNode, parent, this) : null;
                currentProcessedNode = new ViewNode(currentNode, currentView, parent);
                NodesProcessed.Add(currentProcessedNode);
            }
            else
            {
                Console.WriteLine("[{1}.{2}] There is no Converter for this type: {0}", currentNode.GetType(), currentNode.id, currentNode.name);
            }

            if (NodeScansChildren(currentNode, converter, options))
            {
                foreach (var item in GetCurrentChildren(currentNode, parent?.Node, converter, options))
                {
                    GenerateViewsRecursively(item, currentProcessedNode ?? parent, options);
                }
            }
        }
Example #5
0
 public override bool CanConvert(FigmaNode currentNode)
 {
     return(currentNode.GetType() == typeof(RectangleVector));
 }
Example #6
0
        //TODO: This
        protected void GenerateViewsRecursively(FigmaNode currentNode, ProcessedNode parent, FigmaViewRendererServiceOptions options)
        {
            Console.WriteLine("[{0}.{1}] Processing {2}..", currentNode?.id, currentNode?.name, currentNode?.GetType());

            bool scanChildren = true;

            var converter = GetProcessedConverter(currentNode, CustomConverters);

            if (converter == null)
            {
                converter = GetProcessedConverter(currentNode, DefaultConverters);
            }

            ProcessedNode currentProcessedNode = null;

            if (converter != null)
            {
                var currentView = options.IsToViewProcessed ? converter.ConvertTo(currentNode, parent, this) : null;
                currentProcessedNode = new ProcessedNode()
                {
                    FigmaNode = currentNode, View = currentView, ParentView = parent
                };
                NodesProcessed.Add(currentProcessedNode);

                //TODO: this need to be improved, handles special cases for native controls
                scanChildren = currentNode is FigmaInstance && options.ScanChildrenFromFigmaInstances ? true : converter.ScanChildren(currentNode);
            }
            else
            {
                scanChildren = false;
                Console.WriteLine("[{1}.{2}] There is no Converter for this type: {0}", currentNode.GetType(), currentNode.id, currentNode.name);
            }

            if (scanChildren && currentNode is IFigmaNodeContainer nodeContainer)
            {
                foreach (var item in nodeContainer.children)
                {
                    GenerateViewsRecursively(item, currentProcessedNode ?? parent, options);
                }
            }
        }
Example #7
0
 public override bool CanConvert(FigmaNode currentNode)
 {
     return(currentNode.GetType() == typeof(FigmaLine) || (currentNode.type == "VECTOR" && currentNode.name == "sep"));
 }
 public override bool CanConvert(FigmaNode currentNode)
 {
     return(currentNode.GetType() == typeof(FigmaVectorEntity));
 }