Esempio n. 1
0
        public override string ConvertToCode(FigmaNode currentNode, FigmaCodeRendererService rendererService)
        {
            var           figmaText = ((FigmaText)currentNode);
            StringBuilder builder   = new StringBuilder();
            var           name      = "[NAME]";

            builder.AppendLine(string.Format("var {0} = {1};", name, FigmaExtensions.CreateLabelToDesignerString(figmaText.characters)));

            var nsFont = figmaText.style.ToNSFont();

            builder.AppendLine(string.Format("{0}.Font = {1};", name, figmaText.style.ToNSFontDesignerString()));

            builder.Configure(name, (FigmaText)currentNode);
            return(builder.ToString());
        }
Esempio n. 2
0
        public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
        {
            var figmaText = (FigmaText)currentNode.Node;

            StringBuilder builder = new StringBuilder();

            if (rendererService.NeedsRenderConstructor(currentNode, parentNode))
            {
                builder.WritePropertyEquality(currentNode.Name, null, FigmaExtensions.CreateLabelToDesignerString(figmaText.characters), instanciate: true);
            }

            //builder.Configure(figmaText, currentNode.Name);
            builder.Configure(currentNode.Node, currentNode.Name);

            var alignment = FigmaExtensions.ToNSTextAlignment(figmaText.style.textAlignHorizontal);

            if (alignment != default)
            {
                builder.WritePropertyEquality(currentNode.Name, nameof(AppKit.NSTextField.Alignment), alignment);
            }
            return(builder.ToString());
        }