Esempio n. 1
0
        public ExampleViewManager(IScrollView scrollView, FigmaViewConverter[] converters)
        {
            fileProvider    = new FigmaRemoteFileProvider();
            RendererService = new FigmaFileRendererService(fileProvider, converters);

            var options = new FigmaViewRendererServiceOptions()
            {
                ScanChildrenFromFigmaInstances = false
            };

            RendererService.Start(fileName, scrollView.ContentView, options);

            distributionService = new FigmaViewRendererDistributionService(RendererService);
            distributionService.Start();

            //We want know the background color of the figma camvas and apply to our scrollview
            var canvas = fileProvider.Nodes.OfType <FigmaCanvas>().FirstOrDefault();

            if (canvas != null)
            {
                scrollView.BackgroundColor = canvas.backgroundColor;
            }


            scrollView.AdjustToContent();
        }
Esempio n. 2
0
        public ExampleViewManager(IScrollView scrollView)
        {
            //we get the default basic view converters from the current loaded toolkit
            var converters = FigmaSharp.AppContext.Current.GetFigmaConverters();

            //TIP: the render consist in 2 steps:
            //1) generate all the views, decorating and calculate sizes
            //2) with this views we generate the hierarchy and position all the views based in the
            //native toolkit positioning system

            //in this case we want use a remote file provider (figma url from our document)
            fileProvider = new FigmaRemoteFileProvider();

            //we initialize our renderer service, this uses all the converters passed
            //and generate a collection of NodesProcessed which is basically contains <FigmaModel, IView, FigmaParentModel>
            var rendererService = new FigmaFileRendererService(fileProvider, converters);

            rendererService.Start(fileName, scrollView);

            //now we have all the views processed and the relationship we can distribute all the views into the desired base view
            var distributionService = new FigmaViewRendererDistributionService(rendererService);

            distributionService.Start();

            //We want know the background color of the figma camvas and apply to our scrollview
            var canvas = fileProvider.Nodes.OfType <FigmaCanvas>().FirstOrDefault();

            if (canvas != null)
            {
                scrollView.BackgroundColor = canvas.backgroundColor;
            }

            //NOTE: some toolkits requires set the real size of the content of the scrollview before position layers
            scrollView.AdjustToContent();
        }
Esempio n. 3
0
        public DocumentExample(IScrollView scrollView, FigmaFile storyboard)
        {
            //we set our storyboard like the content view of the scrollview
            scrollView.ContentView = storyboard.ContentView;

            //we need reload after set the content to ensure the scrollview
            storyboard.Reload();

            //now we want recalculate all the bounds based in all the views generated
            scrollView.AdjustToContent();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            FigmaApplication.Init(Environment.GetEnvironmentVariable("TOKEN"));

            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            var stackView = new StackView()
            {
                Orientation = LayoutOrientation.Vertical
            };

            scrollView = new ScrollView();

            var mainWindow = new Window(new Rectangle(0, 0, 540, 800))
            {
                Content = scrollView
            };

            mainWindow.Closing += delegate { NSRunningApplication.CurrentApplication.Terminate(); };

            //TIP: the render consist in 2 steps:
            //1) generate all the views, decorating and calculate sizes
            //2) with this views we generate the hierarchy and position all the views based in the
            //native toolkit positioning system

            //in this case we want use a remote file provider (figma url from our document)
            var fileProvider = new FigmaRemoteFileProvider();

            //we initialize our renderer service, this uses all the converters passed
            //and generate a collection of NodesProcessed which is basically contains <FigmaModel, IView, FigmaParentModel>
            var rendererService = new FigmaViewRendererService(fileProvider);

            rendererService.Start(fileName, scrollView.ContentView);

            //now we have all the views processed and the relationship we can distribute all the views into the desired base view
            var layoutManager = new StoryboardLayoutManager();

            layoutManager.Run(scrollView.ContentView, rendererService);

            //NOTE: some toolkits requires set the real size of the content of the scrollview before position layers
            scrollView.AdjustToContent();

            mainWindow.Show();
            //mainWindow.Title = manager.WindowTitle;

            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
        }
Esempio n. 5
0
        void Session_ReloadFinished(object sender, EventArgs e)
        {
            scrollViewWrapper.ClearSubviews();

            foreach (var items in session.MainViews)
            {
                scrollViewWrapper.AddChild(items.View);
            }

            var mainNodes = session.ProcessedNodes
                            .Where(s => s.ParentView == null)
                            .ToArray();

            Reposition(mainNodes);

            //we need reload after set the content to ensure the scrollview
            scrollViewWrapper.AdjustToContent();
        }