public static void Configure(this Widget view, FigmaVectorEntity child) { Configure(view, (FigmaNode)child); if (child.HasFills && child.fills[0].color != null) { if (child.fills[0].color.a > 0) { if (view is Fixed fixedView) { fixedView.HasWindow = true; fixedView.ModifyBg(StateType.Normal, child.fills[0].color.ToGdkColor()); } } } var strokes = child.strokes.FirstOrDefault(); if (strokes != null) { //TODO: NOT IMPLEMENTED //if (strokes.color != null) //{ // view.Layer.BorderColor = strokes.color.ToNSColor().CGColor; //} //view.Layer.BorderWidth = child.strokeWeight; } }
protected override StringBuilder OnConvertToCode(FigmaCodeNode currentNode, FigmaCodeNode parentNode, FigmaCodeRendererService rendererService) { var code = new StringBuilder(); string name = FigmaSharp.Resources.Ids.Conversion.NameIdentifier; var frame = (FigmaFrame)currentNode.Node; currentNode.Node.TryGetNativeControlType(out NativeControlType controlType); currentNode.Node.TryGetNativeControlVariant(out NativeControlVariant controlVariant); if (rendererService.NeedsRenderConstructor(currentNode, parentNode)) { code.WriteConstructor(name, GetControlType(currentNode.Node), rendererService.NodeRendersVar(currentNode, parentNode)); } FigmaVectorEntity rectangle = frame.children .OfType <FigmaVectorEntity>() .FirstOrDefault(s => s.name == ComponentString.VALUE); foreach (var styleMap in rectangle?.styles) { if ((rendererService.figmaProvider as FigmaFileProvider).TryGetStyle(styleMap.Value, out FigmaStyle style)) { if (styleMap.Key == "fill") { code.WriteEquality(name, nameof(NSColorWell.Color), CocoaCodeHelpers.GetNSColorString(style.name)); } } } return(code); }
protected override IView OnConvertToView(FigmaNode currentNode, ProcessedNode parentNode, FigmaRendererService rendererService) { var frame = (FigmaFrame)currentNode; var box = new NSBox(); currentNode.TryGetNativeControlType(out NativeControlType controlType); if (controlType == NativeControlType.Separator) { box.BoxType = NSBoxType.NSBoxSeparator; } if (controlType == NativeControlType.BoxCustom) { box.BoxType = NSBoxType.NSBoxCustom; box.BorderWidth = 0; FigmaVectorEntity rectangle = frame.children .OfType <FigmaVectorEntity>() .FirstOrDefault(); foreach (var styleMap in rectangle?.styles) { if (rendererService.FileProvider.TryGetStyle(styleMap.Value, out FigmaStyle style)) { if (styleMap.Key == "fill") { box.FillColor = CocoaHelpers.GetNSColor(style.name); } if (styleMap.Key == "stroke") { box.BorderColor = CocoaHelpers.GetNSColor(style.name); box.BorderWidth = rectangle.strokeWeight; } } } } if (controlType == NativeControlType.Box) { FigmaText text = frame.children .OfType <FigmaText>() .FirstOrDefault(s => (s.name == ComponentString.TITLE && s.visible)); if (text != null) { box.Title = text.characters; } else { box.Title = ""; } } return(new View(box)); }
public static void Configure(this FrameworkElement view, FigmaVectorEntity child) { Configure(view, (FigmaNode)child); if (view is Panel canvas) { if (child.HasFills && child.fills[0].color != null) { canvas.Background = child.fills[0].color.ToColor(); } } }
public static void Configure(this StringBuilder builder, string name, FigmaVectorEntity child) { Configure(builder, name, (FigmaNode)child); if (child.HasFills && child.fills[0].color != null) { builder.AppendLine(string.Format("{0}.HasWindow = true;", name)); builder.AppendLine(string.Format("{0}.ModifyBg(Gtk.StateType.Normal, {1});", name, child.fills[0].color.ToDesignerString())); } //var strokes = child.strokes.FirstOrDefault(); //if (strokes != null) //{ // //if (strokes.color != null) // //{ // // builder.AppendLine(string.Format("{0}.Layer.BorderColor = {1};", name, strokes.color.ToDesignerString(true))); // //} // builder.AppendLine(string.Format("{0}.Layer.BorderWidth = {1};", name, child.strokeWeight)); //} }
protected override IView OnConvertToView(FigmaNode currentNode, ProcessedNode parentNode, FigmaRendererService rendererService) { var colorWell = new NSColorWell(); var frame = (FigmaFrame)currentNode; FigmaVectorEntity rectangle = frame.children .OfType <FigmaVectorEntity>() .FirstOrDefault(s => s.name == ComponentString.VALUE); foreach (var styleMap in rectangle?.styles) { if (rendererService.FileProvider.TryGetStyle(styleMap.Value, out FigmaStyle style)) { if (styleMap.Key == "fill") { colorWell.Color = CocoaHelpers.GetNSColor(style.name); } } } return(new View(colorWell)); }
public static void Configure(this StringBuilder builder, string name, FigmaVectorEntity child) { Configure(builder, name, (FigmaNode)child); var fills = child.strokes.FirstOrDefault(); if (fills != null && fills.visible) { builder.AppendLine(string.Format("{0}.Layer.BackgroundColor = {1};", name, child.fills[0].color.ToDesignerString(true))); } var strokes = child.strokes.FirstOrDefault(); if (strokes != null && strokes.visible) { if (strokes.color != null) { builder.AppendLine(string.Format("{0}.Layer.BorderColor = {1};", name, strokes.color.ToDesignerString(true))); } builder.AppendLine(string.Format("{0}.Layer.BorderWidth = {1};", name, child.strokeWeight)); } }
public static void Configure(this UIView view, FigmaVectorEntity child) { Configure(view, (FigmaNode)child); //if (child.HasFills && child.fills[0].color != null) //{ // view.Layer.BackgroundColor = child.fills[0].color.ToUIColor().CGColor; //} //var currengroupView = new UIView() { TranslatesAutoresizingMaskIntoConstraints = false }; //currengroupView.Configure(rectangleVector); //var strokes = child.strokes.FirstOrDefault(); //if (strokes != null) //{ // if (strokes.color != null) // { // view.Layer.BorderColor = strokes.color.ToUIColor().CGColor; // } // view.Layer.BorderWidth = child.strokeWeight; //} }
public static void Configure(this NSView view, FigmaVectorEntity child) { Configure(view, (FigmaNode)child); view.AlphaValue = child.opacity; }
public static void Configure(this Xamarin.Forms.View view, FigmaVectorEntity child) { Configure(view, (FigmaNode)child); }
protected override StringBuilder OnConvertToCode(FigmaCodeNode currentNode, FigmaCodeNode parentNode, FigmaCodeRendererService rendererService) { var code = new StringBuilder(); string name = FigmaSharp.Resources.Ids.Conversion.NameIdentifier; var frame = (FigmaFrame)currentNode.Node; currentNode.Node.TryGetNativeControlType(out NativeControlType controlType); currentNode.Node.TryGetNativeControlVariant(out NativeControlVariant controlVariant); if (rendererService.NeedsRenderConstructor(currentNode, parentNode)) { code.WriteConstructor(name, GetControlType(currentNode.Node), rendererService.NodeRendersVar(currentNode, parentNode)); } if (controlType == NativeControlType.Separator) { code.WriteEquality(name, nameof(NSBox.BoxType), NSBoxType.NSBoxSeparator); } if (controlType == NativeControlType.BoxCustom) { code.WriteEquality(name, nameof(NSBox.BoxType), NSBoxType.NSBoxCustom); bool borderSet = false; FigmaVectorEntity rectangle = frame.children .OfType <FigmaVectorEntity>() .FirstOrDefault(); foreach (var styleMap in rectangle?.styles) { if ((rendererService.figmaProvider as FigmaFileProvider).TryGetStyle(styleMap.Value, out FigmaStyle style)) { if (styleMap.Key == "fill") { code.WriteEquality(name, nameof(NSBox.FillColor), CocoaCodeHelpers.GetNSColorString(style.name)); } if (styleMap.Key == "stroke") { code.WriteEquality(name, nameof(NSBox.BorderColor), CocoaCodeHelpers.GetNSColorString(style.name)); code.WriteEquality(name, nameof(NSBox.BorderWidth), rectangle.strokeWeight.ToString()); borderSet = true; } } } if (!borderSet) { code.WriteEquality(name, nameof(NSBox.BorderWidth), "0"); } } FigmaText text = frame.children .OfType <FigmaText>() .FirstOrDefault(s => (s.name == ComponentString.TITLE && s.visible)); if (text != null) { string stringTitle = NativeControlHelper.GetTranslatableString(text.characters, rendererService.CurrentRendererOptions.TranslateLabels); code.WriteEquality(name, nameof(NSBox.Title), stringTitle, inQuotes: !rendererService.CurrentRendererOptions.TranslateLabels); } else { code.WriteEquality(name, nameof(NSBox.Title), "", inQuotes: true); } return(code); }