Exemple #1
0
        public void Start(string figmaName, IView container, FigmaViewRendererServiceOptions options = null)
        {
            if (options == null)
            {
                options = new FigmaViewRendererServiceOptions();
            }

            Console.WriteLine("[FigmaViewRenderer] Starting process..");
            Console.WriteLine($"Reading {figmaName} from resources..");

            this.container = container;

            try
            {
                if (options.LoadFileProvider)
                {
                    fileProvider.Load(figmaName ?? fileProvider.File);
                }

                //we generate all the processed nodes
                Refresh(options);

                //we render only if there is a canvas and GenerateViews is enabled
                var canvas = NodesProcessed.FirstOrDefault(s => s.FigmaNode is FigmaCanvas);
                if (canvas != null && options.ConfigureViews)
                {
                    RecursivelyConfigureViews(canvas, options);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error reading resource");
                Console.WriteLine(ex);
            }
        }
 internal ViewNode[] GetProcessedNodes(FigmaNode[] mainNodes)
 {
     ViewNode[] resultNodes = new ViewNode[mainNodes.Length];
     for (int i = 0; i < mainNodes.Length; i++)
     {
         var currentNode = mainNodes[i];
         resultNodes[i] = NodesProcessed.FirstOrDefault(s => s.Node == currentNode);
     }
     return(resultNodes);
 }