This commit is contained in:
Javier Suárez 2022-10-23 16:56:17 +02:00
Родитель a2c4a2d221
Коммит 37884f1054
152 изменённых файлов: 10556 добавлений и 5 удалений

Просмотреть файл

@ -0,0 +1,61 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>AlohaKit.UI.Figma</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>AlohaKit.UI.Figma</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.alohakit.ui.figma</ApplicationId>
<ApplicationIdGuid>bd33300f-7d11-47df-95ae-c835a27d86e1</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0-rc.2.22430.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AlohaKit.UI\AlohaKit.UI.csproj" />
<ProjectReference Include="..\FigmaSharp.Views\FigmaSharp.Views.csproj" />
<ProjectReference Include="..\FigmaSharp\FigmaSharp.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AlohaKit.UI.Figma"
x:Class="AlohaKit.UI.Figma.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,12 @@
namespace AlohaKit.UI.Figma
{
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new AppShell();
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="AlohaKit.UI.Figma.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:AlohaKit.UI.Figma"
Shell.FlyoutBehavior="Disabled">
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
</Shell>

Просмотреть файл

@ -0,0 +1,10 @@
namespace AlohaKit.UI.Figma
{
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,19 @@
using System.Globalization;
namespace AlohaKit.UI.Figma.Converters
{
internal class IsGeneratingToVisibleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var text = (string)value;
return !string.IsNullOrEmpty(text);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,96 @@
using FigmaSharp.Converters;
using AlohaKit.UI.Figma.Extensions;
using FigmaSharp.Models;
using FigmaSharp.Services;
using System.Globalization;
using System.Text;
namespace AlohaKit.UI.Figma.Converters
{
internal class ElipseConverter : ElipseConverterBase
{
public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
{
if (currentNode.Node is not FigmaElipse elipseNode)
{
return string.Empty;
}
StringBuilder builder = new StringBuilder();
builder.AppendLine("<alohakit:Ellipse");
var bounds = elipseNode.absoluteBoundingBox;
NumberFormatInfo nfi = new NumberFormatInfo
{
NumberDecimalSeparator = "."
};
builder.AppendLine($"\tX=\"{bounds.X.ToString(nfi)}\"");
builder.AppendLine($"\tY=\"{bounds.Y.ToString(nfi)}\"");
builder.AppendLine($"\tWidthRequest=\"{bounds.Width.ToString(nfi)}\"");
builder.AppendLine($"\tHeightRequest=\"{bounds.Height.ToString(nfi)}\"");
if (elipseNode.HasStrokes)
{
var strokePaint = elipseNode.strokes.FirstOrDefault();
if (strokePaint.color != null)
{
builder.AppendLine($"\tStroke=\"{strokePaint.color.ToCodeString()}\"");
}
if (elipseNode.strokeWeight != 0)
{
var strokeSize = elipseNode.strokeWeight;
builder.AppendLine($"\tStrokeThickness=\"{strokeSize}\"");
}
}
builder.Append("\t>");
if (elipseNode.HasFills)
{
var backgroundPaint = elipseNode.fills.FirstOrDefault();
if (backgroundPaint != null && backgroundPaint.visible)
{
builder.AppendLine("\n\t<alohakit:Ellipse.Fill>");
if (backgroundPaint.color != null)
{
builder.AppendLine($"\t\t<SolidColorBrush Color=\"{backgroundPaint.color.ToCodeString()}\" />");
}
if (backgroundPaint.gradientStops != null)
{
if (backgroundPaint.type.Equals("GRADIENT_LINEAR", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToLinearGradientPaint()}");
if (backgroundPaint.type.Equals("GRADIENT_RADIAL", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToRadialGradientPaint()}");
}
if (backgroundPaint.imageRef != null)
builder.AppendLine("\t\t<SolidColorBrush Color=\"White\" />");
builder.AppendLine("\t</alohakit:Ellipse.Fill>");
}
}
builder.AppendLine("</alohakit:Ellipse>");
return builder.ToString();
}
public override FigmaSharp.Views.IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
{
throw new NotImplementedException();
}
public override Type GetControlType(FigmaNode currentNode)
=> typeof(View);
}
}

Просмотреть файл

@ -0,0 +1,102 @@
using AlohaKit.UI.Figma.Extensions;
using FigmaSharp.Converters;
using FigmaSharp.Models;
using FigmaSharp.Services;
using System.Globalization;
using System.Text;
namespace AlohaKit.UI.Figma.Converters
{
public class FrameConverter : FrameConverterBase
{
public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
{
if (currentNode.Node is not FigmaFrame frameNode)
{
return string.Empty;
}
StringBuilder builder = new StringBuilder();
builder.AppendLine("<alohakit:RoundRectangle");
var bounds = frameNode.absoluteBoundingBox;
NumberFormatInfo nfi = new NumberFormatInfo
{
NumberDecimalSeparator = "."
};
builder.AppendLine($"\tX=\"{bounds.X.ToString(nfi)}\"");
builder.AppendLine($"\tY=\"{bounds.Y.ToString(nfi)}\"");
builder.AppendLine($"\tWidthRequest=\"{bounds.Width.ToString(nfi)}\"");
builder.AppendLine($"\tHeightRequest=\"{bounds.Height.ToString(nfi)}\"");
var cornerRadius = frameNode.cornerRadius;
builder.AppendLine($"\tCornerRadius=\"{cornerRadius.ToString(nfi)}\"");
if (frameNode.HasStrokes)
{
var strokePaint = frameNode.strokes.FirstOrDefault();
if (strokePaint.color != null)
{
builder.AppendLine($"\tStroke=\"{strokePaint.color.ToCodeString()}\"");
}
if (frameNode.strokeWeight != 0)
{
var strokeSize = frameNode.strokeWeight;
builder.AppendLine($"\tStrokeThickness=\"{strokeSize}\"");
}
}
builder.Append("\t>");
if (frameNode.HasFills)
{
var backgroundPaint = frameNode.fills.FirstOrDefault();
if (backgroundPaint != null && backgroundPaint.visible)
{
builder.AppendLine("\n\t<alohakit:RoundRectangle.Fill>");
if (backgroundPaint.color != null)
{
builder.AppendLine($"\t\t<SolidColorBrush Color=\"{backgroundPaint.color.ToCodeString()}\" />");
}
if (backgroundPaint.gradientStops != null)
{
if (backgroundPaint.type.Equals("GRADIENT_LINEAR", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToLinearGradientPaint()}");
if (backgroundPaint.type.Equals("GRADIENT_RADIAL", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToRadialGradientPaint()}");
}
if (backgroundPaint.imageRef != null)
builder.AppendLine("\t\t<SolidColorBrush Color=\"White\" />");
builder.AppendLine("\t</alohakit:RoundRectangle.Fill>");
}
}
builder.AppendLine("</alohakit:RoundRectangle>");
return builder.ToString();
}
public override FigmaSharp.Views.IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
{
throw new NotImplementedException();
}
public override Type GetControlType(FigmaNode currentNode)
=> typeof(View);
public override bool ScanChildren(FigmaNode currentNode)
=> true;
}
}

Просмотреть файл

@ -0,0 +1,111 @@
using AlohaKit.UI.Figma.Extensions;
using FigmaSharp.Converters;
using FigmaSharp.Models;
using FigmaSharp.Services;
using System.Globalization;
using System.Text;
using System.Xml.Linq;
namespace AlohaKit.UI.Figma.Converters
{
internal class ImageConverter : NodeConverter
{
public override bool CanConvert(FigmaNode currentNode)
=> currentNode.GetType() == typeof(FigmaVector);
public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
{
if (currentNode.Node is not FigmaVector figmaVector)
{
return string.Empty;
}
if (figmaVector.fillGeometry == null || figmaVector.fillGeometry.Length == 0)
{
return string.Empty;
}
StringBuilder builder = new StringBuilder();
NumberFormatInfo nfi = new NumberFormatInfo
{
NumberDecimalSeparator = "."
};
builder.AppendLine("<alohakit:Path");
var bounds = figmaVector.absoluteBoundingBox;
builder.AppendLine($"\tX=\"{bounds.X.ToString(nfi)}\"");
builder.AppendLine($"\tY=\"{bounds.Y.ToString(nfi)}\"");
builder.AppendLine($"\tWidthRequest=\"{bounds.Width.ToString(nfi)}\"");
builder.AppendLine($"\tHeightRequest=\"{bounds.Height.ToString(nfi)}\"");
if(figmaVector.fillGeometry.Length > 0)
{
var geometry = figmaVector.fillGeometry[0];
builder.AppendLine($"\tData=\"{geometry.path}\"");
}
if (figmaVector.HasStrokes)
{
var strokePaint = figmaVector.strokes.FirstOrDefault();
if (strokePaint.color != null)
{
builder.AppendLine($"\tStroke=\"{strokePaint.color.ToCodeString()}\"");
}
if (figmaVector.strokeWeight != 0)
{
var strokeSize = figmaVector.strokeWeight;
builder.AppendLine($"\tStrokeThickness=\"{strokeSize}\"");
}
}
builder.Append("\t>");
if (figmaVector.HasFills)
{
var backgroundPaint = figmaVector.fills.FirstOrDefault();
if (backgroundPaint != null && backgroundPaint.visible)
{
builder.AppendLine("\n\t<alohakit:Path.Fill>");
if (backgroundPaint.color != null)
{
builder.AppendLine($"\t\t<SolidColorBrush Color=\"{backgroundPaint.color.ToCodeString()}\" />");
}
if (backgroundPaint.gradientStops != null)
{
if (backgroundPaint.type.Equals("GRADIENT_LINEAR", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToLinearGradientPaint()}");
if (backgroundPaint.type.Equals("GRADIENT_RADIAL", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToRadialGradientPaint()}");
}
if (backgroundPaint.imageRef != null)
builder.AppendLine("\t\t<SolidColorBrush Color=\"White\" />");
builder.AppendLine("\t</alohakit:Path.Fill>");
}
}
builder.AppendLine("</alohakit:Path>");
return builder.ToString();
}
public override FigmaSharp.Views.IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
{
throw new NotImplementedException();
}
public override Type GetControlType(FigmaNode currentNode)
=> typeof(View);
}
}

Просмотреть файл

@ -0,0 +1,22 @@
using FigmaSharp.Converters;
using FigmaSharp.Models;
using FigmaSharp.Services;
namespace AlohaKit.UI.Figma.Converters
{
internal class LineConverter : LineConverterBase
{
public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
{
return "<!-- Line -->";
}
public override FigmaSharp.Views.IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
{
throw new NotImplementedException();
}
public override Type GetControlType(FigmaNode currentNode)
=> typeof(View);
}
}

Просмотреть файл

@ -0,0 +1,22 @@
using FigmaSharp.Converters;
using FigmaSharp.Models;
using FigmaSharp.Services;
namespace AlohaKit.UI.Figma.Converters
{
internal class PolygonConverter : RegularPolygonConverterBase
{
public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
{
return "<!-- Polygon -->";
}
public override FigmaSharp.Views.IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
{
throw new NotImplementedException();
}
public override Type GetControlType(FigmaNode currentNode)
=> typeof(View);
}
}

Просмотреть файл

@ -0,0 +1,96 @@
using AlohaKit.UI.Figma.Extensions;
using FigmaSharp.Converters;
using FigmaSharp.Models;
using FigmaSharp.Services;
using System.Globalization;
using System.Text;
namespace AlohaKit.UI.Figma.Converters
{
internal class RectangleConverter : RectangleVectorConverterBase
{
public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
{
if (currentNode.Node is not RectangleVector rectangleVector)
{
return string.Empty;
}
StringBuilder builder = new StringBuilder();
builder.AppendLine("<alohakit:Rectangle");
var bounds = rectangleVector.absoluteBoundingBox;
NumberFormatInfo nfi = new NumberFormatInfo
{
NumberDecimalSeparator = "."
};
builder.AppendLine($"\tX=\"{bounds.X.ToString(nfi)}\"");
builder.AppendLine($"\tY=\"{bounds.Y.ToString(nfi)}\"");
builder.AppendLine($"\tWidthRequest=\"{bounds.Width.ToString(nfi)}\"");
builder.AppendLine($"\tHeightRequest=\"{bounds.Height.ToString(nfi)}\"");
if (rectangleVector.HasStrokes)
{
var strokePaint = rectangleVector.strokes.FirstOrDefault();
if (strokePaint.color != null)
{
builder.AppendLine($"\tStroke=\"{strokePaint.color.ToCodeString()}\"");
}
if (rectangleVector.strokeWeight != 0)
{
var strokeSize = rectangleVector.strokeWeight;
builder.AppendLine($"\tStrokeThickness=\"{strokeSize}\"");
}
}
builder.Append("\t>");
if (rectangleVector.HasFills)
{
var backgroundPaint = rectangleVector.fills.FirstOrDefault();
if (backgroundPaint != null && backgroundPaint.visible)
{
builder.AppendLine("\n\t<alohakit:Rectangle.Fill>");
if (backgroundPaint.color != null)
{
builder.AppendLine($"\t\t<SolidColorBrush Color=\"{backgroundPaint.color.ToCodeString()}\" />");
}
if (backgroundPaint.gradientStops != null)
{
if (backgroundPaint.type.Equals("GRADIENT_LINEAR", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToLinearGradientPaint()}");
if (backgroundPaint.type.Equals("GRADIENT_RADIAL", StringComparison.CurrentCultureIgnoreCase))
builder.AppendLine($"{backgroundPaint.gradientStops.ToRadialGradientPaint()}");
}
if (backgroundPaint.imageRef != null)
builder.AppendLine("\t\t<SolidColorBrush Color=\"White\" />");
builder.AppendLine("\t</alohakit:Rectangle.Fill>");
}
}
builder.AppendLine("</alohakit:Rectangle>");
return builder.ToString();
}
public override FigmaSharp.Views.IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
{
throw new NotImplementedException();
}
public override Type GetControlType(FigmaNode currentNode)
=> typeof(View);
}
}

Просмотреть файл

@ -0,0 +1,70 @@
using FigmaSharp.Converters;
using AlohaKit.UI.Figma.Extensions;
using FigmaSharp.Models;
using FigmaSharp.Services;
using System.Globalization;
using System.Text;
namespace AlohaKit.UI.Figma.Converters
{
internal class TextConverter : TextConverterBase
{
public override string ConvertToCode(CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService)
{
if (currentNode.Node is not FigmaText textNode)
{
return string.Empty;
}
StringBuilder builder = new StringBuilder();
builder.AppendLine("<alohakit:Label");
NumberFormatInfo nfi = new NumberFormatInfo
{
NumberDecimalSeparator = "."
};
var bounds = textNode.absoluteBoundingBox;
builder.AppendLine($"\tX=\"{bounds.X.ToString(nfi)}\"");
builder.AppendLine($"\tY=\"{bounds.Y.ToString(nfi)}\"");
builder.AppendLine($"\tWidthRequest=\"{bounds.Width.ToString(nfi)}\"");
builder.AppendLine($"\tHeightRequest=\"{bounds.Height.ToString(nfi)}\"");
if (textNode.HasFills)
{
var textPaint = textNode.fills.FirstOrDefault();
if (textPaint.color != null)
{
builder.AppendLine($"\tTextColor=\"{textPaint.color.ToCodeString()}\"");
}
}
var textStyle = textNode.style;
if (textStyle != null)
{
var fontSize = textStyle.fontSize;
builder.AppendLine($"\tFontSize=\"{fontSize}\"");
}
string text = textNode.characters ?? textNode.name;
builder.AppendLine($"\tText=\"{text}\"");
builder.Append("\t/>");
return builder.ToString();
}
public override FigmaSharp.Views.IView ConvertToView(FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService)
{
throw new NotImplementedException();
}
public override Type GetControlType(FigmaNode currentNode)
=> typeof(View);
}
}

Просмотреть файл

@ -0,0 +1,174 @@
using AlohaKit.UI.Figma.Helpers;
using FigmaSharp;
using FigmaSharp.Models;
using FigmaSharp.Services;
using System.Text;
namespace AlohaKit.UI.Figma.Extensions
{
public static class CodeGenerationExtensions
{
public static string GetFullProperty(this Enum enumeration, string property)
{
return enumeration.GetType().WithProperty(property.ToCamelCase());
}
public static string WithProperty(this Type type, string property)
{
return string.Format("{0}.{1}", type.FullName, property);
}
public static string CreatePropertyName(this CodeNode sender, string propertyName)
{
return string.Format("{0}.{1}", sender.Name, propertyName);
}
public static string CreateChildObjectName(this CodeNode sender, string propertyName)
{
return string.Format("{0}{1}", sender.Name, propertyName);
}
public static string GetConstructor(this Type type, params string[] parameters)
{
string args;
if (parameters.Length > 0)
{
args = string.Join(", ", parameters);
}
else
{
args = string.Empty;
}
return $"new {type.FullName} ({args})";
}
public static string GetMethod(this Type type, string methodName, string parameters, bool inQuotes = false, bool includesSemicolon = true)
{
return CodeGenerationHelpers.GetMethod(type.FullName, methodName, parameters, inQuotes, includesSemicolon);
}
public static string GetFullName(this Enum myEnum)
{
return string.Format("{0}.{1}", myEnum.GetType().Name, myEnum.ToString());
}
public static string GetConstructor(this CodeNode sender, Type type, bool includesVar = true)
{
return GetConstructor(sender, type.FullName, includesVar);
}
public static string GetConstructor(this CodeNode sender, string typeFullName, bool includesVar = true)
{
return CodeGenerationHelpers.GetConstructor(sender.Name, typeFullName, includesVar);
}
public static string GetPropertyEquality(this CodeNode sender, string propertyName, Enum value)
{
return GetPropertyEquality(sender, propertyName, value.GetFullName());
}
public static string GetPropertyEquality(this CodeNode sender, string propertyName, bool value)
{
return GetPropertyEquality(sender, propertyName, value.ToString());
}
public static string GetPropertyEquality(this CodeNode sender, string propertyName, string value, bool inQuotes = false)
{
return CodeGenerationHelpers.GetPropertyEquality(sender.Name, propertyName, value, inQuotes);
}
public static string GetMethod(this CodeNode sender, string methodName, Enum parameter)
{
return GetMethod(sender, methodName, parameter.GetFullName());
}
public static string GetMethod(this CodeNode sender, string methodName, bool parameter)
{
return CodeGenerationHelpers.GetMethod(sender.Name, methodName, parameter);
}
public static string GetMethod(this CodeNode sender, string methodName, string parameters, bool inQuotes = false)
{
return CodeGenerationHelpers.GetMethod(sender.Name, methodName, parameters, inQuotes);
}
#region StringBuilder Code Generation
public static void WriteConstructor(this StringBuilder builder, string viewName, Type type, bool includesVar = true)
{
WriteConstructor(builder, viewName, type.FullName, includesVar);
}
public static void WriteConstructor(this StringBuilder builder, string viewName, string typeFullName, bool includesVar = true)
{
builder.AppendLine(CodeGenerationHelpers.GetConstructor(viewName, typeFullName, includesVar));
}
public static void WritePropertyEquality(this StringBuilder builder, string viewName, string propertyName, Enum value)
{
WritePropertyEquality(builder, viewName, propertyName, value.GetFullName());
}
public static void WriteEquality(this StringBuilder builder, string viewName, string value, bool inQuotes = false, bool instanciate = false)
{
builder.AppendLine(CodeGenerationHelpers.GetEquality(viewName, value, inQuotes, instanciate));
}
public static void WritePropertyEquality(this StringBuilder builder, string viewName, string propertyName, bool value)
{
WritePropertyEquality(builder, viewName, propertyName, value.ToString());
}
public static void WritePropertyEquality(this StringBuilder builder, string viewName, string propertyName, string value, bool inQuotes = false, bool instanciate = false)
{
builder.AppendLine(CodeGenerationHelpers.GetPropertyEquality(viewName, propertyName, value, inQuotes, instanciate));
}
public static void WriteTranslatedEquality(this StringBuilder builder, string viewName, string propertyName, FigmaText value, ICodeRenderService codeRenderService, bool instanciate = false)
{
WriteTranslatedEquality(builder, viewName, propertyName, value.characters, codeRenderService, instanciate, value.visible);
}
public static void WriteTranslatedEquality(this StringBuilder builder, string viewName, string propertyName, string value, ICodeRenderService codeRenderService, bool instanciate = false, bool textCondition = true)
{
bool needQuotes;
string result;
if (textCondition && !string.IsNullOrEmpty(value))
{
if (codeRenderService.Options != null && codeRenderService.Options.TranslateLabels)
{
result = codeRenderService.GetTranslatedText(value);
needQuotes = false;
}
else
{
result = value;
needQuotes = true;
}
}
else
{
result = string.Empty;
needQuotes = true;
}
builder.AppendLine(CodeGenerationHelpers.GetPropertyEquality(viewName, propertyName, result, inQuotes: needQuotes, instanciate: instanciate));
}
public static void WriteMethod(this StringBuilder builder, string viewName, string methodName, Enum parameter)
{
WriteMethod(builder, viewName, methodName, parameter.GetFullName());
}
public static void WriteMethod(this StringBuilder builder, string viewName, string methodName, bool parameter)
{
WriteMethod(builder, viewName, methodName, parameter.ToString());
}
public static void WriteMethod(this StringBuilder builder, string viewName, string methodName, string parameters, bool inQuotes = false)
{
builder.AppendLine(CodeGenerationHelpers.GetMethod(viewName, methodName, parameters, inQuotes));
}
#endregion
}
}

Просмотреть файл

@ -0,0 +1,136 @@
using FigmaSharp.Models;
using System.Text;
namespace AlohaKit.UI.Figma.Extensions
{
public static class FigmaExtensions
{
public static string ToCodeString(this FigmaSharp.Color color)
{
int red = Convert.ToInt32(color.R * 255);
int green = Convert.ToInt32(color.G * 255);
int blue = Convert.ToInt32(color.B * 255);
return "#" + red.ToString("X2") + green.ToString("X2") + blue.ToString("X2");
}
public static string ToLinearGradientPaint(this ColorStop[] colorStops)
{
StringBuilder builder = new StringBuilder();
builder.Append("\t\t<LinearGradientBrush>");
builder.AppendLine("\n\t\t\t<LinearGradientBrush.GradientStops>");
foreach (var colorStop in colorStops)
{
var color = colorStop.color;
string hexColor = color.ToCodeString();
builder.AppendLine($"\t\t\t\t<GradientStop Offset=\"{colorStop.position}\" Color= \"{hexColor}\" />");
}
builder.AppendLine("\t\t\t</LinearGradientBrush.GradientStops>");
builder.Append("\t\t</LinearGradientBrush>");
return builder.ToString();
}
public static string ToRadialGradientPaint(this ColorStop[] colorStops)
{
StringBuilder builder = new StringBuilder();
builder.Append("\t\t<RadialGradientBrush>");
builder.AppendLine("\n\t\t\t<RadialGradientBrush.GradientStops>");
foreach (var colorStop in colorStops)
{
var color = colorStop.color;
string hexColor = color.ToCodeString();
builder.AppendLine($"\t\t\t\t<GradientStop Offset=\"{colorStop.position}\" Color= \"{hexColor}\" />");
}
builder.AppendLine("\t\t\t</RadialGradientBrush.GradientStops>");
builder.Append("\t\t</RadialGradientBrush>");
return builder.ToString();
}
public static string ToCodeString(this float[] values)
{
StringBuilder builder = new StringBuilder();
builder.Append("new float[] {");
var separator = ",";
int i = 0;
foreach (var value in values)
{
builder.Append($"{ToCodeString(value)}{(i < values.Length ? separator : string.Empty)}");
i++;
}
builder.Append("}");
return builder.ToString();
}
public static string ToCodeString(this float value)
{
return string.Concat(value.ToString(), "f");
}
public static string ToCodeString(this double value)
{
return string.Concat(value.ToString(), "f");
}
public static string ToCodeString(this FigmaTypeStyle style)
{
var fontFamily = style.fontPostScriptName ?? style.fontFamily;
var fontWeight = style.fontWeight;
string fontStyleType = "FontStyleType.Normal";
if (!string.IsNullOrEmpty(fontFamily) && fontFamily.Contains("Italic", StringComparison.CurrentCultureIgnoreCase))
fontStyleType = "FontStyleType.Italic";
return $"new Microsoft.Maui.Graphics.Font(\"{fontFamily}\", {fontWeight}, {fontStyleType})";
}
public static string ToHorizontalAignment(this string value)
{
switch(value)
{
case "LEFT":
return "HorizontalAlignment.Left";
case "CENTER":
return "HorizontalAlignment.Center";
case "RIGHT":
return "HorizontalAlignment.Right";
case "SCALE":
return "HorizontalAlignment.Justified";
default:
return "HorizontalAlignment.Left";
}
}
public static string ToVerticalAlignment(this string value)
{
switch (value)
{
case "TOP":
return "VerticalAlignment.Top";
case "CENTER":
case "SCALE":
return "VerticalAlignment.Center";
case "BOTTOM":
return "VerticalAlignment.Bottom";
default:
return "VerticalAlignment.Top";
}
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
namespace AlohaKit.UI.Figma
{
public class FigmaApplication
{
public static void Init(string token)
{
var applicationDelegate = new FigmaDelegate();
FigmaSharp.AppContext.Current.Configuration(applicationDelegate, token);
}
}
}

Просмотреть файл

@ -0,0 +1,77 @@
using AlohaKit.UI.Figma.Converters;
using FigmaSharp;
using FigmaSharp.Converters;
using FigmaSharp.PropertyConfigure;
using FigmaSharp.Views;
using System.Reflection;
namespace AlohaKit.UI.Figma
{
public class FigmaDelegate : IFigmaDelegate
{
public bool IsVerticalAxisFlipped => false;
public void BeginInvoke(Action handler)
{
throw new NotImplementedException();
}
public FigmaSharp.Views.IView CreateEmptyView()
{
throw new NotImplementedException();
}
public CodePropertyConfigureBase GetCodePropertyConfigure()
{
throw new NotImplementedException();
}
public NodeConverter[] GetFigmaConverters()
{
return new NodeConverter[]{
new ElipseConverter(),
new FrameConverter(),
new ImageConverter(),
new LineConverter(),
new PolygonConverter(),
new RectangleConverter(),
new TextConverter()
};
}
public FigmaSharp.Views.IImage GetImage(string url)
{
throw new NotImplementedException();
}
public FigmaSharp.Views.IImage GetImageFromFilePath(string filePath)
{
throw new NotImplementedException();
}
public FigmaSharp.Views.IImage GetImageFromManifest(Assembly assembly, string imageRef)
{
throw new NotImplementedException();
}
public IImageView GetImageView(FigmaSharp.Views.IImage image)
{
throw new NotImplementedException();
}
public string GetManifestResource(Assembly assembly, string file)
{
throw new NotImplementedException();
}
public string GetSvgData(string url)
{
throw new NotImplementedException();
}
public ViewPropertyConfigureBase GetViewPropertyConfigure()
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,65 @@
using AlohaKit.UI.Figma.Extensions;
namespace AlohaKit.UI.Figma.Helpers
{
public static class CodeGenerationHelpers
{
public static string GetConstructor(string viewName, Type type, bool includesVar = true)
{
return GetConstructor(viewName, type.FullName, includesVar);
}
public static string GetConstructor(string viewName, string typeFullName, bool includesVar = true)
{
return $"{(includesVar ? "var " : string.Empty)}{viewName} = new {typeFullName}();";
}
public static string GetPropertyEquality(string viewName, string propertyName, Enum value)
{
return GetPropertyEquality(viewName, propertyName, value.GetFullName());
}
public static string GetPropertyEquality(string viewName, string propertyName, bool value)
{
return GetPropertyEquality(viewName, propertyName, value.ToString());
}
public static string GetPropertyEquality(string viewName, string propertyName, string value, bool inQuotes = false, bool instanciate = false)
{
string fullPropertyName;
if (string.IsNullOrEmpty(propertyName))
fullPropertyName = viewName;
else
fullPropertyName = $"{viewName}.{propertyName}";
return GetEquality(fullPropertyName, value, inQuotes, instanciate);
}
public static string GetEquality(string viewName, string value, bool inQuotes = false, bool instanciate = false)
{
if (inQuotes)
{
value = string.Format("\"{0}\"", value.Replace("\n", "\\n"));
}
var instanciateText = instanciate ? "var " : "";
return $"{instanciateText}{viewName} = {value};";
}
public static string GetMethod(string viewName, string methodName, Enum parameter)
{
return GetMethod(viewName, methodName, parameter.GetFullName());
}
public static string GetMethod(string viewName, string methodName, bool value)
{
return GetMethod(viewName, methodName, value.ToString());
}
public static string GetMethod(string viewName, string methodName, string parameters, bool inQuotes = false, bool includesSemicolon = true)
{
parameters = inQuotes ? $"\"{parameters}\"" : parameters;
var semicolon = includesSemicolon ? ";" : "";
return $"{viewName}.{methodName} ({parameters}){semicolon}";
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using FigmaSharp.Converters;
using FigmaSharp.PropertyConfigure;
using FigmaSharp.Services;
namespace AlohaKit.UI.Figma.PropertyConfigure
{
public class CodePropertyConfigure : CodePropertyConfigureBase
{
public override string ConvertToCode(string propertyName, CodeNode currentNode, CodeNode parentNode, NodeConverter converter, CodeRenderService rendererService)
{
return string.Empty;
}
}
}

Просмотреть файл

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="AlohaKit.UI.Figma.MainPage"
xmlns:converters="clr-namespace:AlohaKit.UI.Figma.Converters"
xmlns:viewModels="clr-namespace:AlohaKit.UI.Figma.ViewModels"
Title="Figma to AlohaKit UI">
<ContentPage.Resources>
<ResourceDictionary>
<converters:IsGeneratingToVisibleConverter x:Key="IsGeneratingToVisibleConverter" />
<Style x:Key="FigmaBorderStyle" TargetType="Border">
<Setter Property="StrokeThickness" Value="2" />
<Setter Property="Margin" Value="6" />
</Style>
<Style x:Key="FigmaLayoutStyle" TargetType="StackLayout">
<Setter Property="Padding" Value="12" />
</Style>
<Style x:Key="HeaderTextStyle" TargetType="Label">
<Setter Property="FontSize" Value="9" />
</Style>
<Style x:Key="GenerateButtonStyle" TargetType="Button">
<Setter Property="FontSize" Value="9" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Margin" Value="0, 12" />
</Style>
<Style x:Key="CodeEditorStyle" TargetType="Editor">
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="IsSpellCheckEnabled" Value="False" />
<Setter Property="IsTextPredictionEnabled" Value="False" />
</Style>
<Style x:Key="ExportButtonStyle" TargetType="Button">
<Setter Property="FontSize" Value="9" />
<Setter Property="VerticalOptions" Value="End" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Margin" Value="0, 12" />
</Style>
<Style x:Key="LogListStyle" TargetType="ListView">
<Setter Property="SelectionMode" Value="None" />
<Setter Property="SeparatorVisibility" Value="Default" />
<Setter Property="MinimumHeightRequest" Value="150" />
</Style>
<Style x:Key="PreviewerStyle" TargetType="GraphicsView">
<Setter Property="MinimumWidthRequest" Value="250" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.BindingContext>
<viewModels:MainViewModel />
</ContentPage.BindingContext>
<Grid>
<!-- CONTENT -->
<Grid
ColumnDefinitions="Auto, *, Auto"
RowDefinitions="*, Auto">
<!-- SETTINGS -->
<Border
Style="{StaticResource FigmaBorderStyle}">
<StackLayout
Style="{StaticResource FigmaLayoutStyle}">
<Label
Text="Figma Access Token"
Style="{StaticResource HeaderTextStyle}"/>
<Entry
Placeholder="Insert your Access Token"
Text="{Binding Token, Mode=TwoWay}"/>
<Label
Text="Figma FileId"
Style="{StaticResource HeaderTextStyle}"/>
<Entry
Placeholder="Insert your FileId"
Text="{Binding FileId, Mode=TwoWay}"/>
<Button
Text="Generate"
Command="{Binding GenerateCommand}"
Style="{StaticResource GenerateButtonStyle}" />
</StackLayout>
</Border>
<!-- CODE EDITOR -->
<Border
Grid.Column="1"
Style="{StaticResource FigmaBorderStyle}">
<Grid
RowDefinitions="Auto, *, Auto"
IsVisible="{Binding Code, Converter={StaticResource IsGeneratingToVisibleConverter}}"
Style="{StaticResource FigmaLayoutStyle}">
<Label
Text="Code"
Style="{StaticResource HeaderTextStyle}"/>
<ScrollView
Grid.Row="1">
<Editor
x:Name="CodeEditor"
Text="{Binding Code}"
Style="{StaticResource CodeEditorStyle}"/>
</ScrollView>
<Button
Grid.Row="2"
Text="Export"
Command="{Binding ExportCommand}"
Style="{StaticResource ExportButtonStyle}"/>
</Grid>
</Border>
<!-- PREVIEWER -->
<Border
Grid.Column="2"
Style="{StaticResource FigmaBorderStyle}"
IsVisible="False">
<Grid
RowDefinitions="Auto, *">
<Label
Text="Previewer"
Style="{StaticResource HeaderTextStyle}"/>
<GraphicsView
Grid.Row="1"
Style="{StaticResource PreviewerStyle}"/>
</Grid>
</Border>
<!-- OUTPUT -->
<Border
Grid.Row="1"
Grid.ColumnSpan="3"
Style="{StaticResource FigmaBorderStyle}">
<Grid
RowDefinitions="Auto, *">
<Label
Text="Output"
Style="{StaticResource HeaderTextStyle}"/>
<ListView
Grid.Row="1"
ItemsSource="{Binding Log}"
Style="{StaticResource LogListStyle}"/>
</Grid>
</Border>
</Grid>
<!-- LOADING -->
<Grid>
<ActivityIndicator
IsRunning="{Binding IsGenerating}"/>
</Grid>
</Grid>
</ContentPage>

Просмотреть файл

@ -0,0 +1,10 @@
namespace AlohaKit.UI.Figma
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
using Microsoft.Extensions.Logging;
namespace AlohaKit.UI.Figma
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>

Просмотреть файл

@ -0,0 +1,11 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
namespace AlohaKit.UI.Figma
{
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
}

Просмотреть файл

@ -0,0 +1,16 @@
using Android.App;
using Android.Runtime;
namespace AlohaKit.UI.Figma
{
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>

Просмотреть файл

@ -0,0 +1,10 @@
using Foundation;
namespace AlohaKit.UI.Figma
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}

Просмотреть файл

@ -0,0 +1,83 @@
using AlohaKit.UI.Figma.Services;
using Foundation;
using UIKit;
namespace AlohaKit.UI.Figma
{
public class FolderPicker : IFolderPicker
{
class PickerDelegate : UIDocumentPickerDelegate
{
public Action<NSUrl[]> PickHandler { get; set; }
public override void WasCancelled(UIDocumentPickerViewController controller)
=> PickHandler?.Invoke(null);
public override void DidPickDocument(UIDocumentPickerViewController controller, NSUrl[] urls)
=> PickHandler?.Invoke(urls);
public override void DidPickDocument(UIDocumentPickerViewController controller, NSUrl url)
=> PickHandler?.Invoke(new NSUrl[] { url });
}
static void GetFileResults(NSUrl[] urls, TaskCompletionSource<string> tcs)
{
try
{
tcs.TrySetResult(urls?[0]?.ToString() ?? "");
}
catch (Exception ex)
{
tcs.TrySetException(ex);
}
}
public async Task<string> PickFolder()
{
var allowedTypes = new string[]
{
"public.folder"
};
var picker = new UIDocumentPickerViewController(allowedTypes, UIDocumentPickerMode.Open);
var tcs = new TaskCompletionSource<string>();
picker.Delegate = new PickerDelegate
{
PickHandler = urls => GetFileResults(urls, tcs)
};
if (picker.PresentationController != null)
{
picker.PresentationController.Delegate =
new UIPresentationControllerDelegate(() => GetFileResults(null, tcs));
}
var parentController = Platform.GetCurrentUIViewController();
parentController.PresentViewController(picker, true, null);
return await tcs.Task;
}
internal class UIPresentationControllerDelegate : UIAdaptivePresentationControllerDelegate
{
Action dismissHandler;
internal UIPresentationControllerDelegate(Action dismissHandler)
=> this.dismissHandler = dismissHandler;
public override void DidDismiss(UIPresentationController presentationController)
{
dismissHandler?.Invoke();
dismissHandler = null;
}
protected override void Dispose(bool disposing)
{
dismissHandler?.Invoke();
base.Dispose(disposing);
}
}
}
}

Просмотреть файл

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,16 @@
using ObjCRuntime;
using UIKit;
namespace AlohaKit.UI.Figma
{
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}

Просмотреть файл

@ -0,0 +1,17 @@
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
using System;
namespace AlohaKit.UI.Figma
{
internal class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="7" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="maui-application-id-placeholder" exec="AlohaKit.UI.Figma.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>maui-application-title-placeholder</label>
<icon>maui-appicon-placeholder</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
<shortcut-list />
<privileges>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
<dependencies />
<provides-appdefined-privileges />
</manifest>

Просмотреть файл

@ -0,0 +1,8 @@
<maui:MauiWinUIApplication
x:Class="AlohaKit.UI.Figma.WinUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maui="using:Microsoft.Maui"
xmlns:local="using:AlohaKit.UI.Figma.WinUI">
</maui:MauiWinUIApplication>

Просмотреть файл

@ -0,0 +1,24 @@
using Microsoft.UI.Xaml;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace AlohaKit.UI.Figma.WinUI
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : MauiWinUIApplication
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}

Просмотреть файл

@ -0,0 +1,26 @@
using AlohaKit.UI.Figma.Services;
using WindowsFolderPicker = Windows.Storage.Pickers.FolderPicker;
namespace AlohaKit.UI.Figma
{
public class FolderPicker : IFolderPicker
{
public async Task<string> PickFolder()
{
var folderPicker = new WindowsFolderPicker();
// Might be needed to make it work on Windows 10
folderPicker.FileTypeFilter.Add("*");
// Get the current window's HWND by passing in the Window object
var hwnd = ((MauiWinUIWindow)App.Current.Windows[0].Handler.PlatformView).WindowHandle;
// Associate the HWND with the file picker
WinRT.Interop.InitializeWithWindow.Initialize(folderPicker, hwnd);
var result = await folderPicker.PickSingleFolderAsync();
return result?.Path;
}
}
}

Просмотреть файл

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />
<Properties>
<DisplayName>$placeholder$</DisplayName>
<PublisherDisplayName>User Name</PublisherDisplayName>
<Logo>$placeholder$.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="$placeholder$"
Description="$placeholder$"
Square150x150Logo="$placeholder$.png"
Square44x44Logo="$placeholder$.png"
BackgroundColor="transparent">
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />
<uap:SplashScreen Image="$placeholder$.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="AlohaKit.UI.Figma.WinUI.app"/>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<!-- The combination of below two tags have the following effect:
1) Per-Monitor for >= Windows 10 Anniversary Update
2) System < Windows 10 Anniversary Update
-->
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</windowsSettings>
</application>
</assembly>

Просмотреть файл

@ -0,0 +1,10 @@
using Foundation;
namespace AlohaKit.UI.Figma
{
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,16 @@
using ObjCRuntime;
using UIKit;
namespace AlohaKit.UI.Figma
{
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
{
"profiles": {
"Windows Machine": {
"commandName": "MsixPackage",
"nativeDebugging": false
}
}
}

Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="456" height="456" fill="#512BD4" />
</svg>

После

Ширина:  |  Высота:  |  Размер: 228 B

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="m 105.50037,281.60863 c -2.70293,0 -5.00091,-0.90042 -6.893127,-2.70209 -1.892214,-1.84778 -2.837901,-4.04181 -2.837901,-6.58209 0,-2.58722 0.945687,-4.80389 2.837901,-6.65167 1.892217,-1.84778 4.190197,-2.77167 6.893127,-2.77167 2.74819,0 5.06798,0.92389 6.96019,2.77167 1.93749,1.84778 2.90581,4.06445 2.90581,6.65167 0,2.54028 -0.96832,4.73431 -2.90581,6.58209 -1.89221,1.80167 -4.212,2.70209 -6.96019,2.70209 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 213.56111,280.08446 H 195.99044 L 149.69953,207.0544 c -1.17121,-1.84778 -2.14037,-3.76515 -2.90581,-5.75126 h -0.40578 c 0.36051,2.12528 0.54076,6.67515 0.54076,13.6496 v 65.13172 h -15.54349 v -99.36009 h 18.71925 l 44.7374,71.29798 c 1.89222,2.95695 3.1087,4.98917 3.64945,6.09751 h 0.26996 c -0.45021,-2.6325 -0.67573,-7.09015 -0.67573,-13.37293 v -64.02256 h 15.47557 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="m 289.25134,280.08446 h -54.40052 v -99.36009 h 52.23835 v 13.99669 h -36.15411 v 28.13085 h 33.31621 v 13.9271 h -33.31621 v 29.37835 h 38.31628 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 366.56466,194.72106 H 338.7222 v 85.3634 h -16.08423 v -85.3634 h -27.77455 v -13.99669 h 71.70124 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
</svg>

После

Ширина:  |  Высота:  |  Размер: 1.8 KiB

Двоичные данные
src/AlohaKit.UI.Figma/Resources/Fonts/OpenSans-Regular.ttf Normal file

Двоичный файл не отображается.

Двоичные данные
src/AlohaKit.UI.Figma/Resources/Fonts/OpenSans-Semibold.ttf Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,93 @@
<svg width="419" height="519" viewBox="0 0 419 519" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M284.432 247.568L284.004 221.881C316.359 221.335 340.356 211.735 355.308 193.336C382.408 159.996 372.893 108.183 372.786 107.659L398.013 102.831C398.505 105.432 409.797 167.017 375.237 209.53C355.276 234.093 324.719 246.894 284.432 247.568Z" fill="#8A6FE8"/>
<path d="M331.954 109.36L361.826 134.245C367.145 138.676 375.055 137.959 379.497 132.639C383.928 127.32 383.211 119.41 377.891 114.969L348.019 90.0842C342.7 85.6531 334.79 86.3702 330.348 91.6896C325.917 97.0197 326.634 104.929 331.954 109.36Z" fill="#8A6FE8"/>
<path d="M407.175 118.062L417.92 94.2263C420.735 87.858 417.856 80.4087 411.488 77.5831C405.12 74.7682 397.67 77.6473 394.845 84.0156L383.831 108.461L407.175 118.062Z" fill="#8A6FE8"/>
<path d="M401.363 105.175L401.234 69.117C401.181 62.1493 395.498 56.541 388.53 56.5945C381.562 56.648 375.954 62.3313 376.007 69.2989L376.018 96.11L401.363 105.175Z" fill="#8A6FE8"/>
<path d="M386.453 109.071L378.137 73.9548C376.543 67.169 369.757 62.9628 362.971 64.5575C356.185 66.1523 351.979 72.938 353.574 79.7237L362.04 115.482L386.453 109.071Z" fill="#8A6FE8"/>
<path d="M381.776 142.261C396.359 142.261 408.181 130.44 408.181 115.857C408.181 101.274 396.359 89.4527 381.776 89.4527C367.194 89.4527 355.372 101.274 355.372 115.857C355.372 130.44 367.194 142.261 381.776 142.261Z" fill="url(#paint0_radial)"/>
<path d="M248.267 406.979C248.513 384.727 245.345 339.561 222.376 301.736L199.922 315.372C220.76 349.675 222.323 389.715 221.841 407.182C221.798 408.627 235.263 409.933 248.267 406.979Z" fill="url(#paint1_linear)"/>
<path d="M221.841 406.936L242.637 406.84L262.052 518.065L220.311 518.258C217.132 518.269 214.724 515.711 214.938 512.532L221.841 406.936Z" fill="#522CD5"/>
<path d="M306.566 488.814C310.173 491.661 310.109 495.782 309.831 500.127L308.964 513.452C308.803 515.839 306.727 517.798 304.34 517.809L260.832 518.012C258.125 518.023 256.08 515.839 256.262 513.142L256.551 499.335C256.883 494.315 255.192 492.474 251.307 487.744C244.649 479.663 224.967 435.62 226.84 406.925L248.256 406.829C249.691 423.858 272.167 461.682 306.566 488.814Z" fill="url(#paint2_linear)"/>
<path d="M309.82 500.127C310.023 497.088 310.077 494.176 308.889 491.715L254.635 491.961C256.134 494.166 256.765 496.092 256.562 499.314L256.273 513.121C256.091 515.828 258.146 518.012 260.843 517.99L304.34 517.798C306.727 517.787 308.803 515.828 308.964 513.442L309.82 500.127Z" fill="url(#paint3_radial)"/>
<path d="M133.552 407.471C133.103 385.22 135.864 340.021 158.49 301.993L181.073 315.425C160.545 349.921 159.346 389.972 159.989 407.428C160.042 408.884 146.578 410.318 133.552 407.471Z" fill="url(#paint4_linear)"/>
<path d="M110.798 497.152C110.765 494.187 111.204 491.575 112.457 487.23C131.882 434.132 133.52 407.364 133.52 407.364L159.999 407.246C159.999 407.246 161.819 433.512 181.716 486.427C183.289 490.195 183.471 493.641 183.674 496.831L183.792 513.816C183.803 516.374 181.716 518.483 179.158 518.494L177.873 518.504L116.781 518.782L115.496 518.793C112.927 518.804 110.83 516.728 110.819 514.159L110.798 497.152Z" fill="url(#paint5_linear)"/>
<path d="M110.798 497.152C110.798 496.67 110.808 496.199 110.83 495.739C110.969 494.262 111.643 492.603 114.875 492.582L180.207 492.282C182.561 492.367 183.343 494.176 183.589 495.311C183.621 495.814 183.664 496.328 183.696 496.82L183.813 513.806C183.824 515.411 183.011 516.824 181.769 517.669C181.031 518.172 180.132 518.472 179.179 518.483L177.895 518.494L116.802 518.772L115.528 518.782C114.244 518.793 113.077 518.269 112.232 517.434C111.386 516.599 110.862 515.432 110.851 514.148L110.798 497.152Z" fill="url(#paint6_radial)"/>
<path d="M314.979 246.348C324.162 210.407 318.008 181.777 318.008 181.777L326.452 181.734L326.656 181.574C314.262 115.75 256.326 66.0987 186.949 66.4198C108.796 66.773 45.7233 130.424 46.0765 208.577C46.4297 286.731 110.08 349.803 188.234 349.45C249.905 349.172 302.178 309.474 321.304 254.343C321.872 251.999 321.797 247.804 314.979 246.348Z" fill="url(#paint7_radial)"/>
<path d="M310.237 279.035L65.877 280.148C71.3998 289.428 77.95 298.012 85.3672 305.761L290.972 304.829C298.336 297.005 304.8 288.368 310.237 279.035Z" fill="#D8CFF7"/>
<path d="M235.062 312.794L280.924 312.585L280.74 272.021L234.877 272.23L235.062 312.794Z" fill="#512BD4"/>
<path d="M243.001 297.626C242.691 297.626 242.434 297.53 242.22 297.327C242.006 297.123 241.899 296.866 241.899 296.588C241.899 296.299 242.006 296.042 242.22 295.839C242.434 295.625 242.691 295.528 243.001 295.528C243.312 295.528 243.568 295.635 243.782 295.839C243.996 296.042 244.114 296.299 244.114 296.588C244.114 296.877 244.007 297.123 243.793 297.327C243.568 297.519 243.312 297.626 243.001 297.626Z" fill="white"/>
<path d="M255.192 297.434H253.212L247.967 289.203C247.839 289 247.721 288.775 247.636 288.55H247.593C247.636 288.786 247.657 289.299 247.657 290.091L247.668 297.444H245.912L245.891 286.228H247.999L253.062 294.265C253.276 294.597 253.415 294.833 253.479 294.95H253.511C253.458 294.651 253.437 294.148 253.437 293.441L253.426 286.217H255.17L255.192 297.434Z" fill="white"/>
<path d="M263.733 297.412L257.589 297.423L257.568 286.206L263.465 286.195V287.779L259.387 287.79L259.398 290.969L263.155 290.958V292.532L259.398 292.542L259.409 295.86L263.733 295.85V297.412Z" fill="white"/>
<path d="M272.445 287.758L269.298 287.769L269.32 297.401H267.5L267.479 287.769L264.343 287.779V286.195L272.434 286.174L272.445 287.758Z" fill="white"/>
<path d="M315.279 246.337C324.355 210.836 318.457 182.483 318.308 181.798L171.484 182.462C171.484 182.462 162.226 181.563 162.268 190.018C162.311 198.463 162.761 222.341 162.878 248.746C162.9 254.172 167.363 256.773 170.863 256.751C170.874 256.751 311.618 252.213 315.279 246.337Z" fill="url(#paint8_radial)"/>
<path d="M227.685 246.798C227.685 246.798 250.183 228.827 254.571 225.499C258.959 222.17 262.812 221.977 266.869 225.445C270.925 228.913 293.616 246.498 293.616 246.498L227.685 246.798Z" fill="#A08BE8"/>
<path d="M320.748 256.141C320.748 256.141 324.943 248.414 315.279 246.348C315.289 246.305 170.927 246.894 170.927 246.894C167.566 246.905 163.232 244.925 162.846 241.671C162.857 244.004 162.878 246.369 162.889 248.756C162.91 253.68 166.582 256.27 169.878 256.698C170.21 256.73 170.542 256.773 170.874 256.773L180.742 256.73L320.748 256.141Z" fill="#512BD4"/>
<path d="M206.4 233.214C212.511 233.095 217.302 224.667 217.102 214.39C216.901 204.112 211.785 195.878 205.674 195.997C199.563 196.116 194.772 204.544 194.973 214.821C195.173 225.099 200.289 233.333 206.4 233.214Z" fill="#512BD4"/>
<path d="M306.249 214.267C306.356 203.989 301.488 195.605 295.377 195.541C289.266 195.478 284.225 203.758 284.118 214.037C284.011 224.315 288.878 232.699 294.99 232.763C301.101 232.826 306.142 224.545 306.249 214.267Z" fill="#512BD4"/>
<path d="M205.905 205.291C208.152 203.022 211.192 202.016 214.157 202.262C215.912 205.495 217.014 209.733 217.111 214.389C217.164 217.3 216.811 220.04 216.158 222.513C212.669 223.519 208.752 222.662 205.979 219.922C201.912 215.909 201.88 209.348 205.905 205.291Z" fill="#8065E0"/>
<path d="M294.996 204.285C297.255 202.016 300.294 200.999 303.259 201.256C305.164 204.628 306.309 209.209 306.256 214.239C306.224 216.808 305.892 219.259 305.303 221.485C301.793 222.523 297.843 221.678 295.061 218.916C291.004 214.892 290.972 208.342 294.996 204.285Z" fill="#8065E0"/>
<path d="M11.6342 357.017C10.9171 354.716 -5.72611 300.141 21.3204 258.903C36.9468 235.078 63.3083 221.035 99.6664 217.15L102.449 243.276C74.3431 246.273 54.4676 256.345 43.3579 273.202C23.0971 303.941 36.5722 348.733 36.7113 349.183L11.6342 357.017Z" fill="url(#paint9_linear)"/>
<path d="M95.1498 252.802C109.502 252.802 121.137 241.167 121.137 226.815C121.137 212.463 109.502 200.828 95.1498 200.828C80.7976 200.828 69.1628 212.463 69.1628 226.815C69.1628 241.167 80.7976 252.802 95.1498 252.802Z" fill="url(#paint10_radial)"/>
<path d="M72.0098 334.434L33.4683 329.307C26.597 328.397 20.2929 333.214 19.3725 340.085C18.4627 346.956 23.279 353.26 30.1504 354.181L68.6919 359.308C75.5632 360.217 81.8673 355.401 82.7878 348.53C83.6975 341.658 78.8705 335.344 72.0098 334.434Z" fill="#8A6FE8"/>
<path d="M3.73535 367.185L7.35297 393.076C8.36975 399.968 14.7702 404.731 21.6629 403.725C28.5556 402.708 33.3185 396.308 32.3124 389.415L28.5984 362.861L3.73535 367.185Z" fill="#8A6FE8"/>
<path d="M15.5194 374.988L34.849 405.427C38.6058 411.292 46.4082 413.005 52.2735 409.248C58.1387 405.491 59.8512 397.689 56.0945 391.823L41.7953 369.144L15.5194 374.988Z" fill="#8A6FE8"/>
<path d="M26.0511 363.739L51.8026 389.019C56.7688 393.911 64.7532 393.846 69.6445 388.88C74.5358 383.914 74.4715 375.929 69.516 371.038L43.2937 345.297L26.0511 363.739Z" fill="#8A6FE8"/>
<path d="M26.4043 381.912C40.987 381.912 52.8086 370.091 52.8086 355.508C52.8086 340.925 40.987 329.104 26.4043 329.104C11.8216 329.104 0 340.925 0 355.508C0 370.091 11.8216 381.912 26.4043 381.912Z" fill="url(#paint11_radial)"/>
<path d="M184.73 63.6308L157.819 66.5892L158.561 38.5412L177.888 36.4178L184.73 63.6308Z" fill="#8A6FE8"/>
<path d="M170.018 41.647C180.455 39.521 187.193 29.3363 185.067 18.8988C182.941 8.46126 172.757 1.72345 162.319 3.84944C151.882 5.97543 145.144 16.1601 147.27 26.5976C149.396 37.0351 159.58 43.773 170.018 41.647Z" fill="#D8CFF7"/>
<path d="M196.885 79.385C198.102 79.2464 198.948 78.091 198.684 76.8997C195.851 64.2818 183.923 55.5375 170.773 56.9926C157.622 58.4371 147.886 69.5735 147.865 82.4995C147.863 83.7232 148.949 84.6597 150.168 84.5316L196.885 79.385Z" fill="url(#paint12_radial)"/>
<defs>
<radialGradient id="paint0_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(382.004 103.457) scale(26.4058)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
<linearGradient id="paint1_linear" x1="214.439" y1="303.482" x2="236.702" y2="409.505" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<linearGradient id="paint2_linear" x1="231.673" y1="404.144" x2="297.805" y2="522.048" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<radialGradient id="paint3_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(280.957 469.555) rotate(-0.260742) scale(45.8326)">
<stop offset="0.034" stop-color="#522CD5"/>
<stop offset="0.9955" stop-color="#8A6FE8"/>
</radialGradient>
<linearGradient id="paint4_linear" x1="166.061" y1="303.491" x2="144.763" y2="409.709" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<linearGradient id="paint5_linear" x1="146.739" y1="407.302" x2="147.246" y2="518.627" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<radialGradient id="paint6_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(148.63 470.023) rotate(179.739) scale(50.2476)">
<stop offset="0.034" stop-color="#522CD5"/>
<stop offset="0.9955" stop-color="#8A6FE8"/>
</radialGradient>
<radialGradient id="paint7_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(219.219 153.929) rotate(179.739) scale(140.935)">
<stop offset="0.4744" stop-color="#A08BE8"/>
<stop offset="0.8618" stop-color="#8065E0"/>
</radialGradient>
<radialGradient id="paint8_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(314.861 158.738) rotate(179.739) scale(146.053)">
<stop offset="0.0933" stop-color="#E1DFDD"/>
<stop offset="0.6573" stop-color="white"/>
</radialGradient>
<linearGradient id="paint9_linear" x1="54.1846" y1="217.159" x2="54.1846" y2="357.022" gradientUnits="userSpaceOnUse">
<stop offset="0.3344" stop-color="#9780E6"/>
<stop offset="0.8488" stop-color="#8A6FE8"/>
</linearGradient>
<radialGradient id="paint10_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(90.3494 218.071) rotate(-0.260742) scale(25.9924)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
<radialGradient id="paint11_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(25.805 345.043) scale(26.4106)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
<radialGradient id="paint12_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(169.113 67.3662) rotate(-32.2025) scale(21.0773)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
</defs>
</svg>

После

Ширина:  |  Высота:  |  Размер: 12 KiB

Просмотреть файл

@ -0,0 +1,15 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories). Deployment of the asset to your application
is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
These files will be deployed with you package and will be accessible using Essentials:
async Task LoadMauiAsset()
{
using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
using var reader = new StreamReader(stream);
var contents = reader.ReadToEnd();
}

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="m 105.50037,281.60863 c -2.70293,0 -5.00091,-0.90042 -6.893127,-2.70209 -1.892214,-1.84778 -2.837901,-4.04181 -2.837901,-6.58209 0,-2.58722 0.945687,-4.80389 2.837901,-6.65167 1.892217,-1.84778 4.190197,-2.77167 6.893127,-2.77167 2.74819,0 5.06798,0.92389 6.96019,2.77167 1.93749,1.84778 2.90581,4.06445 2.90581,6.65167 0,2.54028 -0.96832,4.73431 -2.90581,6.58209 -1.89221,1.80167 -4.212,2.70209 -6.96019,2.70209 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 213.56111,280.08446 H 195.99044 L 149.69953,207.0544 c -1.17121,-1.84778 -2.14037,-3.76515 -2.90581,-5.75126 h -0.40578 c 0.36051,2.12528 0.54076,6.67515 0.54076,13.6496 v 65.13172 h -15.54349 v -99.36009 h 18.71925 l 44.7374,71.29798 c 1.89222,2.95695 3.1087,4.98917 3.64945,6.09751 h 0.26996 c -0.45021,-2.6325 -0.67573,-7.09015 -0.67573,-13.37293 v -64.02256 h 15.47557 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="m 289.25134,280.08446 h -54.40052 v -99.36009 h 52.23835 v 13.99669 h -36.15411 v 28.13085 h 33.31621 v 13.9271 h -33.31621 v 29.37835 h 38.31628 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 366.56466,194.72106 H 338.7222 v 85.3634 h -16.08423 v -85.3634 h -27.77455 v -13.99669 h 71.70124 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
</svg>

После

Ширина:  |  Высота:  |  Размер: 1.8 KiB

Просмотреть файл

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="Primary">#512BD4</Color>
<Color x:Key="Secondary">#DFD8F7</Color>
<Color x:Key="Tertiary">#2B0B98</Color>
<Color x:Key="White">White</Color>
<Color x:Key="Black">Black</Color>
<Color x:Key="Gray100">#E1E1E1</Color>
<Color x:Key="Gray200">#C8C8C8</Color>
<Color x:Key="Gray300">#ACACAC</Color>
<Color x:Key="Gray400">#919191</Color>
<Color x:Key="Gray500">#6E6E6E</Color>
<Color x:Key="Gray600">#404040</Color>
<Color x:Key="Gray900">#212121</Color>
<Color x:Key="Gray950">#141414</Color>
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource Primary}"/>
<SolidColorBrush x:Key="SecondaryBrush" Color="{StaticResource Secondary}"/>
<SolidColorBrush x:Key="TertiaryBrush" Color="{StaticResource Tertiary}"/>
<SolidColorBrush x:Key="WhiteBrush" Color="{StaticResource White}"/>
<SolidColorBrush x:Key="BlackBrush" Color="{StaticResource Black}"/>
<SolidColorBrush x:Key="Gray100Brush" Color="{StaticResource Gray100}"/>
<SolidColorBrush x:Key="Gray200Brush" Color="{StaticResource Gray200}"/>
<SolidColorBrush x:Key="Gray300Brush" Color="{StaticResource Gray300}"/>
<SolidColorBrush x:Key="Gray400Brush" Color="{StaticResource Gray400}"/>
<SolidColorBrush x:Key="Gray500Brush" Color="{StaticResource Gray500}"/>
<SolidColorBrush x:Key="Gray600Brush" Color="{StaticResource Gray600}"/>
<SolidColorBrush x:Key="Gray900Brush" Color="{StaticResource Gray900}"/>
<SolidColorBrush x:Key="Gray950Brush" Color="{StaticResource Gray950}"/>
<Color x:Key="Yellow100Accent">#F7B548</Color>
<Color x:Key="Yellow200Accent">#FFD590</Color>
<Color x:Key="Yellow300Accent">#FFE5B9</Color>
<Color x:Key="Cyan100Accent">#28C2D1</Color>
<Color x:Key="Cyan200Accent">#7BDDEF</Color>
<Color x:Key="Cyan300Accent">#C3F2F4</Color>
<Color x:Key="Blue100Accent">#3E8EED</Color>
<Color x:Key="Blue200Accent">#72ACF1</Color>
<Color x:Key="Blue300Accent">#A7CBF6</Color>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,403 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xaml-comp compile="true" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Style TargetType="ActivityIndicator">
<Setter Property="Color" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
</Style>
<Style TargetType="IndicatorView">
<Setter Property="IndicatorColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}"/>
<Setter Property="SelectedIndicatorColor" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray100}}"/>
</Style>
<Style TargetType="Border">
<Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="StrokeShape" Value="Rectangle"/>
<Setter Property="StrokeThickness" Value="1"/>
</Style>
<Style TargetType="BoxView">
<Setter Property="Color" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray200}}" />
</Style>
<Style TargetType="Button">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Primary}}" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="14,10"/>
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray200}}" />
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="CheckBox">
<Setter Property="Color" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Color" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="DatePicker">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Editor">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14" />
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Entry">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14" />
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Frame">
<Setter Property="HasShadow" Value="False" />
<Setter Property="BorderColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />
<Setter Property="CornerRadius" Value="8" />
</Style>
<Style TargetType="ImageButton">
<Setter Property="Opacity" Value="1" />
<Setter Property="BorderColor" Value="Transparent"/>
<Setter Property="BorderWidth" Value="0"/>
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Opacity" Value="0.5" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Label">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="ListView">
<Setter Property="SeparatorColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray500}}" />
<Setter Property="RefreshControlColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
</Style>
<Style TargetType="Picker">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="TitleColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
<Setter Property="TitleColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="ProgressBar">
<Setter Property="ProgressColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="ProgressColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="RadioButton">
<Setter Property="BackgroundColor" Value="Transparent"/>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" />
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="RefreshView">
<Setter Property="RefreshColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
</Style>
<Style TargetType="SearchBar">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="PlaceholderColor" Value="{StaticResource Gray500}" />
<Setter Property="CancelButtonColor" Value="{StaticResource Gray500}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="SearchHandler">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="PlaceholderColor" Value="{StaticResource Gray500}" />
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="FontFamily" Value="OpenSansRegular" />
<Setter Property="FontSize" Value="14" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
<Setter Property="PlaceholderColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Shadow">
<Setter Property="Radius" Value="15" />
<Setter Property="Opacity" Value="0.5" />
<Setter Property="Brush" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource White}}" />
<Setter Property="Offset" Value="10,10" />
</Style>
<Style TargetType="Slider">
<Setter Property="MinimumTrackColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="MaximumTrackColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray600}}" />
<Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="MinimumTrackColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}"/>
<Setter Property="MaximumTrackColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}"/>
<Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="SwipeItem">
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
</Style>
<Style TargetType="Switch">
<Setter Property="OnColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="ThumbColor" Value="{StaticResource White}" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="OnColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
<Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="On">
<VisualState.Setters>
<Setter Property="OnColor" Value="{AppThemeBinding Light={StaticResource Secondary}, Dark={StaticResource Gray200}}" />
<Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Off">
<VisualState.Setters>
<Setter Property="ThumbColor" Value="{AppThemeBinding Light={StaticResource Gray400}, Dark={StaticResource Gray500}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="TimePicker">
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource White}}" />
<Setter Property="BackgroundColor" Value="Transparent"/>
<Setter Property="FontFamily" Value="OpenSansRegular"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="MinimumHeightRequest" Value="44"/>
<Setter Property="MinimumWidthRequest" Value="44"/>
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray300}, Dark={StaticResource Gray600}}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style TargetType="Page" ApplyToDerivedTypes="True">
<Setter Property="Padding" Value="0"/>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
</Style>
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
<Setter Property="Shell.ForegroundColor" Value="{OnPlatform WinUI={StaticResource Primary}, Default={StaticResource White}}" />
<Setter Property="Shell.TitleColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource White}}" />
<Setter Property="Shell.DisabledColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />
<Setter Property="Shell.UnselectedColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray200}}" />
<Setter Property="Shell.NavBarHasShadow" Value="False" />
<Setter Property="Shell.TabBarBackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" />
<Setter Property="Shell.TabBarForegroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="Shell.TabBarTitleColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="Shell.TabBarUnselectedColor" Value="{AppThemeBinding Light={StaticResource Gray900}, Dark={StaticResource Gray200}}" />
</Style>
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
<Setter Property="BarTextColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource White}}" />
<Setter Property="IconColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource White}}" />
</Style>
<Style TargetType="TabbedPage">
<Setter Property="BarBackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray950}}" />
<Setter Property="BarTextColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource White}}" />
<Setter Property="UnselectedTabColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />
<Setter Property="SelectedTabColor" Value="{AppThemeBinding Light={StaticResource Gray950}, Dark={StaticResource Gray200}}" />
</Style>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,28 @@
namespace AlohaKit.UI.Figma.Services
{
public class DialogService
{
static DialogService _instance;
public static DialogService Instance
{
get
{
if (_instance == null)
_instance = new DialogService();
return _instance;
}
}
public void DisplayAlert(string title, string message)
{
var mainPage = Application.Current.MainPage;
if (mainPage == null)
return;
mainPage.DisplayAlert(title, message, "Ok");
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
namespace AlohaKit.UI.Figma.Services
{
public interface IFolderPicker
{
Task<string> PickFolder();
}
}

Просмотреть файл

@ -0,0 +1,179 @@
using AlohaKit.UI.Figma.PropertyConfigure;
using AlohaKit.UI.Figma.Services;
using FigmaSharp.Services;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
namespace AlohaKit.UI.Figma.ViewModels
{
public class MainViewModel : BindableObject
{
string _token;
string _fileId;
bool _isGenerating;
string _code;
ObservableCollection<string> _log;
public MainViewModel()
{
#if DEBUG
// INSERT YOUR FIGMA ACCESS TOKEN
Token = "";
// INSERT THE FILE ID
FileId = "";
#endif
Log = new ObservableCollection<string>();
}
public string Token
{
get { return _token; }
set
{
_token = value;
OnPropertyChanged();
}
}
public string FileId
{
get { return _fileId; }
set
{
_fileId = value;
OnPropertyChanged();
}
}
public bool IsGenerating
{
get { return _isGenerating; }
set
{
_isGenerating = value;
OnPropertyChanged();
}
}
public string Code
{
get { return _code; }
set
{
_code = value;
OnPropertyChanged();
}
}
public ObservableCollection<string> Log
{
get { return _log; }
set
{
_log = value;
OnPropertyChanged();
}
}
public ICommand GenerateCommand => new Command(async () => await GenerateCodeAsync());
public ICommand ExportCommand => new Command(async () => await Export());
async Task GenerateCodeAsync()
{
try
{
if (string.IsNullOrEmpty(Token))
{
var message = "In order to obtain the necessary information from Figma, it is necessary to use a Personal Access Token.";
Log.Add(message);
DialogService.Instance.DisplayAlert("Information", message);
return;
}
FigmaApplication.Init(Token);
if (string.IsNullOrEmpty(FileId))
{
var message = "In order to obtain the necessary information from Figma, it is necessary to use a FileId.";
Log.Add(message);
DialogService.Instance.DisplayAlert("Information", message);
return;
}
IsGenerating = true;
Log.Add("Request the data to the Figma API.");
var remoteNodeProvider = new RemoteNodeProvider();
await remoteNodeProvider.LoadAsync(FileId);
Log.Add($"Data obtained successfully. {remoteNodeProvider.Nodes.Count} nodes found.");
Log.Add("Initializing the code generator.");
var converters = FigmaSharp.AppContext.Current.GetFigmaConverters();
var codePropertyConfigure = new CodePropertyConfigure();
var codeRenderer = new CodeRenderService(remoteNodeProvider, converters, codePropertyConfigure);
Log.Add("Code generator initialized successfully.");
var stringBuilder = new StringBuilder();
var node = codeRenderer.NodeProvider.Nodes[0];
Log.Add($"Node {node.id} found successfully.");
Log.Add("Generating source code...");
var codeNode = new CodeNode(node);
codeRenderer.GetCode(stringBuilder, codeNode, currentRendererOptions: new CodeRenderServiceOptions
{
ShowComments = false
});
var code = stringBuilder.ToString();
Code = code;
Log.Add("Source Code generated successfully.");
}
catch (Exception ex)
{
Log.Add(ex.Message);
}
finally
{
IsGenerating = false;
}
}
async Task Export()
{
if (string.IsNullOrEmpty(Code))
{
string message = "The generated code is not correct.";
Log.Add(message);
DialogService.Instance.DisplayAlert("Information", message);
return;
}
#if MACCATALYST || WINDOWS
try
{
var folderPicker = new FolderPicker();
string folder = await folderPicker.PickFolder();
string path = System.IO.Path.Combine(folder, "FigmaToMauiGraphics.txt");
await File.WriteAllTextAsync(path, Code);
string message = "The file has been created successfully.";
Log.Add(message);
DialogService.Instance.DisplayAlert("Information", message);
}
catch(Exception ex)
{
Log.Add(ex.Message);
}
#endif
}
}
}

Просмотреть файл

@ -3,9 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33015.44
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlohaKit.UI", "AlohaKit.UI\AlohaKit.UI.csproj", "{0E6FAD63-6F1A-4CA7-A16F-3F0765DC95A6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AlohaKit.UI", "AlohaKit.UI\AlohaKit.UI.csproj", "{0E6FAD63-6F1A-4CA7-A16F-3F0765DC95A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlohaKit.UI.Gallery", "AlohaKit.UI.Gallery\AlohaKit.UI.Gallery.csproj", "{09500699-E9A5-40B9-B72E-00E6B2CD4B38}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AlohaKit.UI.Gallery", "AlohaKit.UI.Gallery\AlohaKit.UI.Gallery.csproj", "{09500699-E9A5-40B9-B72E-00E6B2CD4B38}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlohaKit.UI.Figma", "AlohaKit.UI.Figma\AlohaKit.UI.Figma.csproj", "{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Figma", "Figma", "{530D3C98-F65E-4631-8FF6-0E5120568BB5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FigmaSharp", "FigmaSharp\FigmaSharp.csproj", "{06D8C80F-2794-47A7-BA8A-5BEDDFC9D5AA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FigmaSharp.Views", "FigmaSharp.Views\FigmaSharp.Views.csproj", "{47B4F2A7-6F3F-4AF3-B48D-FF2AF74A4E0B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -23,10 +31,29 @@ Global
{09500699-E9A5-40B9-B72E-00E6B2CD4B38}.Release|Any CPU.ActiveCfg = Release|Any CPU
{09500699-E9A5-40B9-B72E-00E6B2CD4B38}.Release|Any CPU.Build.0 = Release|Any CPU
{09500699-E9A5-40B9-B72E-00E6B2CD4B38}.Release|Any CPU.Deploy.0 = Release|Any CPU
{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF}.Release|Any CPU.Build.0 = Release|Any CPU
{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF}.Release|Any CPU.Deploy.0 = Release|Any CPU
{06D8C80F-2794-47A7-BA8A-5BEDDFC9D5AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06D8C80F-2794-47A7-BA8A-5BEDDFC9D5AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06D8C80F-2794-47A7-BA8A-5BEDDFC9D5AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06D8C80F-2794-47A7-BA8A-5BEDDFC9D5AA}.Release|Any CPU.Build.0 = Release|Any CPU
{47B4F2A7-6F3F-4AF3-B48D-FF2AF74A4E0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47B4F2A7-6F3F-4AF3-B48D-FF2AF74A4E0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47B4F2A7-6F3F-4AF3-B48D-FF2AF74A4E0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47B4F2A7-6F3F-4AF3-B48D-FF2AF74A4E0B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9BC3D8C4-A21E-4F4E-BAC1-DB24CC81CCEF} = {530D3C98-F65E-4631-8FF6-0E5120568BB5}
{06D8C80F-2794-47A7-BA8A-5BEDDFC9D5AA} = {530D3C98-F65E-4631-8FF6-0E5120568BB5}
{47B4F2A7-6F3F-4AF3-B48D-FF2AF74A4E0B} = {530D3C98-F65E-4631-8FF6-0E5120568BB5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4704EC8E-DEA6-47CF-95CE-896B3E8949D1}
EndGlobalSection

Просмотреть файл

@ -12,7 +12,9 @@
public class Element : VisualElement, IElement
{
IElement _parent;
RectF _childrenBounds;
public Element()
{
Children = new ElementsCollection(this);

Просмотреть файл

@ -18,12 +18,12 @@ namespace AlohaKit.UI
public override void Draw(ICanvas canvas, RectF bounds)
{
canvas.SaveState();
base.Draw(canvas, bounds);
if (Stroke != null)
{
canvas.SaveState();
canvas.Translate(X, Y);
if (Stroke is SolidColorBrush solidColorBrush)
@ -39,9 +39,27 @@ namespace AlohaKit.UI
var path = GetPath();
canvas.DrawPath(path);
canvas.RestoreState();
}
canvas.RestoreState();
if (Fill != null)
{
canvas.SaveState();
canvas.Translate(X, Y);
if (Fill is SolidColorBrush solidColorBrush)
canvas.FillColor = solidColorBrush.Color;
else
canvas.SetFillPaint(Fill, new RectF(X, Y, WidthRequest, HeightRequest));
var path = GetPath();
canvas.FillPath(path);
canvas.RestoreState();
}
}
PathF GetPath()

Просмотреть файл

@ -0,0 +1,53 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace FigmaSharp
{
[Flags]
public enum AnchorStyles
{
//
// Summary:
// The control is not anchored to any edges of its container.
None = 0,
//
// Summary:
// The control is anchored to the top edge of its container.
Top = 1,
//
// Summary:
// The control is anchored to the bottom edge of its container.
Bottom = 2,
//
// Summary:
// The control is anchored to the left edge of its container.
Left = 4,
//
// Summary:
// The control is anchored to the right edge of its container.
Right = 8
}
}

Просмотреть файл

@ -0,0 +1,59 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp
{
public class Color
{
public Color () { }
public Color (double r, double g, double b, double a)
{
R = r;
G = g;
B = b;
A = a;
}
public Color (double r, double g, double b)
{
R = r;
G = g;
B = b;
A = 1;
}
public double R { get; set; }
public double G { get; set; }
public double B { get; set; }
public double A { get; set; }
public static Color Red => new Color (1, 0, 0, 1);
public static Color Green => new Color (0, 1, 0, 1);
public static Color Blue => new Color (0, 0, 1, 1);
public static Color Black => new Color (0, 0, 0, 1);
public static Color White => new Color (1, 1, 1, 1);
public static Color Transparent => new Color (0, 0, 0, 0);
}
}

Просмотреть файл

@ -0,0 +1,34 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Linq;
namespace FigmaSharp.Views
{
public static class Extensions
{
public static bool In (this string sender, params string[] values) =>
values.Any (s => s == sender);
}
}

Просмотреть файл

@ -0,0 +1,222 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace FigmaSharp
{
public class Point : IEquatable<Point>
{
public Point () { }
public Point (float x, float y)
{
X = x;
Y = y;
}
public float X { get; set; }
public float Y { get; set; }
public bool Equals (Point other)
{
if (X != other.X || Y != other.Y) {
return false;
}
return true;
}
public override bool Equals (object obj)
{
if (obj == null) return false;
if (!(obj is Size)) return false;
return Equals ((Size)obj);
}
public override string ToString ()
{
return string.Format ("{{{0},{1}}}", X, Y);
}
public static Point Zero { get; set; } = new Point ();
public Point Substract(Point center)
{
return new Point(X - center.X, Y - center.Y);
}
public Point UnionWith (Point center)
{
return new Point(X + center.X, Y + center.Y);
}
}
public class Size : IEquatable<Size>
{
public Size () { }
public Size (float width, float height)
{
Width = width;
Height = height;
}
public float Width { get; set; }
public float Height { get; set; }
public bool Equals (Size other)
{
if (Width != other.Width || Height != other.Height) {
return false;
}
return true;
}
public override bool Equals (object obj)
{
if (obj == null) return false;
if (!(obj is Size)) return false;
return Equals ((Size)obj);
}
public override string ToString ()
{
return string.Format ("{{{0},{1}}}", Width, Height);
}
public static Size Zero { get; set; } = new Size ();
}
public class Rectangle : IEquatable<Rectangle>
{
readonly Size size = new Size ();
public Size Size {
get => size;
set {
size.Width = value.Width;
size.Height = value.Height;
}
}
readonly Point origin = new Point ();
public Point Origin {
get => origin;
set {
origin.X = value.X;
origin.Y = value.Y;
}
}
public float X {
get => origin.X;
set => origin.X = value;
}
public float Y {
get => origin.Y;
set => origin.Y = value;
}
public float Width {
get => size.Width;
set => size.Width = value;
}
public float Height {
get => size.Height;
set => size.Height = value;
}
public float Left => X;
public float Right => X + Width;
public float Top => Y;
public float Bottom => Y + Height;
public static Rectangle Zero { get; set; } = new Rectangle ();
public Rectangle ()
{
}
public Rectangle (Point origin, Size size)
{
this.origin = origin;
this.size = size;
}
public Rectangle (float x, float y, float width, float height)
{
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
}
public Rectangle UnionWith (Rectangle allocation)
{
//TODO: improve
float xMin = Math.Min (X, allocation.X);
float yMin = Math.Min (Y, allocation.Y);
float xMax = Math.Max (X + Width, allocation.X + allocation.Width);
float yMax = Math.Max (Y + Height, allocation.Y + allocation.Height);
return new Rectangle (xMin, yMin, xMax - xMin, yMax - yMin);
}
public bool Equals (Rectangle other)
{
if (size.Equals (other.Size) && origin.Equals (other.Origin)) {
return true;
}
return false;
}
public override bool Equals (object obj)
{
if (obj == null) return false;
if (!(obj is Rectangle)) return false;
return Equals ((Rectangle)obj);
}
public bool IntersectsWith (Rectangle allocation)
{
return (Left < allocation.Right && Right > allocation.Left &&
Top < allocation.Bottom && Bottom > allocation.Top);
}
public bool IntersectsWith (Rectangle allocation, bool reversed)
{
return (Left < allocation.Right && Right > allocation.Left &&
Top <= allocation.Bottom && Bottom >= allocation.Top);
}
public override string ToString ()
{
return string.Format ("{{{0},{1},{2},{3}}}", X, Y, Width, Height);
}
public Point Center => new Point (Width / 2f, Height / 2f);
public Rectangle Copy() => new Rectangle(X, Y, Width, Height);
}
}

Просмотреть файл

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
</PropertyGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
<Folder Include="Svg\" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,77 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Reflection;
namespace FigmaSharp.Views.Helpers
{
public static class FileHelper
{
public static string GetFileDataFromBundle (string fileName, Assembly assembly = null)
{
if (assembly == null)
assembly = Assembly.GetEntryAssembly();
var path = System.IO.Path.GetDirectoryName(System.IO.Path.GetDirectoryName(assembly.Location));
path = System.IO.Path.Combine(path, "Resources", "svg", fileName);
var data = System.IO.File.ReadAllText(path);
return data;
}
public static string GetManifestResource(Assembly assembly, string resource)
{
if (assembly == null)
{
assembly = Assembly.GetEntryAssembly();
}
try
{
var resources = assembly.GetManifestResourceNames();
var fullResourceName = string.Format("{0}.{1}", assembly.GetName().Name, resource);
foreach (var item in new string[] { resource, fullResourceName })
{
//TODO: not safe
using (var stream = assembly.GetManifestResourceStream(item))
{
if (stream == null)
continue;
using (TextReader tr = new StreamReader(stream))
return tr.ReadToEnd();
}
}
}
catch (System.Exception ex)
{
Console.WriteLine("Cannot read resource '{0}' in assembly '{1}'", resource, ex);
return null;
}
Console.WriteLine("Resource '{0}' not found in assembly '{1}'", resource, assembly.FullName); ;
return null;
}
}
}

Просмотреть файл

@ -0,0 +1,39 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface ITransitableButton : IButton, IViewTransitable
{
}
public interface IViewTransitable
{
string TransitionNodeID { get; set; }
float TransitionDuration { get; set; }
string TransitionEasing { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,41 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace FigmaSharp.Views
{
public interface IImageButton : IButton
{
}
public interface IButton : IView
{
bool Border { get; set; }
event EventHandler Clicked;
string Text { get; set; }
IImage Image { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface IRadioBox : IView
{
bool IsChecked { get; set; }
string Text { get; set; }
}
public interface ICheckBox : IView
{
bool IsChecked { get; set; }
string Text { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,32 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface IComboBox
{
void AddItem (string Text);
void RemoveItem (string Text);
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace FigmaSharp.Views
{
public interface IDeviceWindow : IObject, IDisposable
{
Color BackgroundColor { get; set; }
IView Content { get; set; }
void AddChild (IWindow window);
void RemoveChild (IWindow window);
}
}

Просмотреть файл

@ -0,0 +1,31 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface IHorizontalBar : IView
{
}
}

Просмотреть файл

@ -0,0 +1,31 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface IImage : IObject
{
Size Size { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,36 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface IImageView : IView
{
IImage Image { get; set; }
}
public interface ISvgView : IView
{
void Load(string image);
}
}

Просмотреть файл

@ -0,0 +1,33 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface ILabel : IView
{
string Text { get; set; }
Color ForegroundColor { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,33 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace FigmaSharp.Views
{
public interface IObject : IDisposable
{
object NativeObject { get; }
}
}

Просмотреть файл

@ -0,0 +1,38 @@
/*
* FigmaImageView.cs - NSImageView which stores it's associed Figma Id
*
* Author:
* Jose Medrano <josmed@microsoft.com>
*
* Copyright (C) 2018 Microsoft, Corp
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
namespace FigmaSharp.Views
{
public interface IScrollView : IView
{
void AdjustToContent ();
void SetContentSize (float width, float height);
IView ContentView { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,31 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface ISearchBox : ITextBox, IView
{
}
}

Просмотреть файл

@ -0,0 +1,31 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface ISlider : IView
{
}
}

Просмотреть файл

@ -0,0 +1,44 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface IDisclosureTriangle : IButton
{
}
public interface IStepper : IView
{
}
public interface IProgressBar : IView
{
}
public interface ISpinner : IView
{
void Start ();
void Stop ();
}
}

Просмотреть файл

@ -0,0 +1,37 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public enum LayoutOrientation
{
Horizontal,
Vertical
}
public interface IStackView : IView
{
LayoutOrientation Orientation { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,50 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public enum TextAlignment
{
/// <summary>Indicates that text will be aligned to the left or top of horizontally or vertically aligned text, respectively.</summary>
Start,
/// <summary>Indicates that text will be aligned in the middle of either horizontally or vertically aligned text.</summary>
Center,
/// <summary>Indicates that text will be aligned to the right or bottom of horizontally or vertically aligned text, respectively.</summary>
End
}
public interface ITextBox : IView
{
string Text { get; set; }
string PlaceHolderString { get; set; }
Color ForegroundColor { get; set; }
}
public interface ITextView : IView
{
//string Text { get; set; }
//Color ForegroundColor { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,34 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public interface ITransform : IObject
{
float RotateAngle { get; set; }
void Rotate (float angle);
void Scale (float x, float y);
void Translate (float x, float y);
}
}

Просмотреть файл

@ -0,0 +1,67 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
namespace FigmaSharp.Views
{
public interface IView : IObject
{
float Width { get; set; }
float Height { get; set; }
bool Hidden { get; set; }
string Identifier { get; set; }
string NodeName { get; set; }
float CornerRadius { get; set; }
bool MovableByWindowBackground { get; set; }
Size Size { get; set; }
Rectangle Allocation { get; }
Size IntrinsicContentSize { get; }
IView Parent { get; set; }
Color BackgroundColor { get; set; }
AnchorStyles Anchor { get; set; }
IReadOnlyList<IView> Children { get; }
void Focus ();
void SetPosition (float x, float y);
void SetAllocation (float x, float y, float width, float height);
void SetAlignmentRect (float x, float y, float width, float height);
void SetPosition (Point origin);
void SetAllocation (Point origin, Size size);
void AddChild (IView view);
void RemoveChild (IView view);
void ClearSubviews ();
void OnChangeFrameSize (Size newSize);
}
}

Просмотреть файл

@ -0,0 +1,56 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace FigmaSharp.Views
{
public interface IWindow : IObject, IDisposable
{
string Title { get; set; }
Color BackgroundColor { get; set; }
bool Borderless { get; set; }
bool Resizable { get; set; }
bool IsFullSizeContentView { get; set; }
bool IsClosable { get; set; }
Size Size { get; set; }
bool IsOpaque { get; set; }
bool MovableByWindowBackground { get; set; }
bool ShowCloseButton { get; set; }
bool ShowZoomButton { get; set; }
bool ShowMiniaturizeButton { get; set; }
bool ShowTitle { get; set; }
IView Content { get; set; }
void AddChild (IWindow window);
void RemoveChild (IWindow window);
void ShowDialog ();
void Show ();
void Center ();
}
}

151
src/FigmaSharp.Views/Key.cs Normal file
Просмотреть файл

@ -0,0 +1,151 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
namespace FigmaSharp
{
[Flags]
public enum Key : ulong
{
A = 0uL,
S = 1uL,
D = 2uL,
F = 3uL,
H = 4uL,
G = 5uL,
Z = 6uL,
X = 7uL,
C = 8uL,
V = 9uL,
B = 11uL,
Q = 12uL,
W = 13uL,
E = 14uL,
R = 0xF,
Y = 0x10,
T = 17uL,
D1 = 18uL,
D2 = 19uL,
D3 = 20uL,
D4 = 21uL,
D6 = 22uL,
D5 = 23uL,
Equal = 24uL,
D9 = 25uL,
D7 = 26uL,
Minus = 27uL,
D8 = 28uL,
D0 = 29uL,
RightBracket = 30uL,
O = 0x1F,
U = 0x20,
LeftBracket = 33uL,
I = 34uL,
P = 35uL,
L = 37uL,
J = 38uL,
Quote = 39uL,
K = 40uL,
Semicolon = 41uL,
Backslash = 42uL,
Comma = 43uL,
Slash = 44uL,
N = 45uL,
M = 46uL,
Period = 47uL,
Grave = 50uL,
KeypadDecimal = 65uL,
KeypadMultiply = 67uL,
KeypadPlus = 69uL,
KeypadClear = 71uL,
KeypadDivide = 75uL,
KeypadEnter = 76uL,
KeypadMinus = 78uL,
KeypadEquals = 81uL,
Keypad0 = 82uL,
Keypad1 = 83uL,
Keypad2 = 84uL,
Keypad3 = 85uL,
Keypad4 = 86uL,
Keypad5 = 87uL,
Keypad6 = 88uL,
Keypad7 = 89uL,
Keypad8 = 91uL,
Keypad9 = 92uL,
Return = 36uL,
Tab = 48uL,
Space = 49uL,
Delete = 51uL,
Escape = 53uL,
Command = 55uL,
Shift = 56uL,
CapsLock = 57uL,
Option = 58uL,
Control = 59uL,
RightShift = 60uL,
RightOption = 61uL,
RightControl = 62uL,
Function = 0x3F,
VolumeUp = 72uL,
VolumeDown = 73uL,
Mute = 74uL,
ForwardDelete = 117uL,
ISOSection = 10uL,
JISYen = 93uL,
JISUnderscore = 94uL,
JISKeypadComma = 95uL,
JISEisu = 102uL,
JISKana = 104uL,
F18 = 79uL,
F19 = 80uL,
F20 = 90uL,
F5 = 96uL,
F6 = 97uL,
F7 = 98uL,
F3 = 99uL,
F8 = 100uL,
F9 = 101uL,
F11 = 103uL,
F13 = 105uL,
F16 = 106uL,
F14 = 107uL,
F10 = 109uL,
F12 = 111uL,
F15 = 113uL,
Help = 114uL,
Home = 115uL,
PageUp = 116uL,
F4 = 118uL,
End = 119uL,
F2 = 120uL,
PageDown = 121uL,
F1 = 122uL,
LeftArrow = 123uL,
RightArrow = 124uL,
DownArrow = 125uL,
UpArrow = 126uL
}
}

Просмотреть файл

@ -0,0 +1,48 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp
{
public class Padding
{
public Padding () { }
public Padding (float value) : this (value, value, value, value)
{
}
public Padding (float top, float left, float bottom, float right)
{
Left = left;
Right = right;
Top = top;
Bottom = bottom;
}
public float Left { get; set; }
public float Right { get; set; }
public float Top { get; set; }
public float Bottom { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,120 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml;
using System.Xml.Serialization;
namespace FigmaSharp.Views.Graphics
{
[Serializable()]
public class Definitions : HtmlElement
{
}
[Serializable()]
public class StyleDefinition : Definitions
{
[XmlAttribute(attributeName: "type")]
public string ContentType { get; set; }
public string Content { get; set; }
[XmlText]
public XmlNode[] CDataContent
{
get
{
var dummy = new XmlDocument();
return new XmlNode[] { dummy.CreateCDataSection(Content) };
}
set
{
if (value == null)
{
Content = null;
return;
}
if (value.Length != 1)
{
throw new InvalidOperationException(
String.Format(
"Invalid array length {0}", value.Length));
}
Content = value[0].Value;
}
}
}
[Serializable()]
public class MarkerDefinition : Definitions
{
[XmlAttribute(attributeName: "type")]
public float StyleType { get; set; }
[XmlAttribute(attributeName: "markerWidth")]
public float MarkerWidth { get; set; }
[XmlAttribute(attributeName: "markerHeight")]
public float MarkerHeight { get; set; }
[XmlAttribute(attributeName: "orient")]
public string Orient { get; set; }
[XmlAttribute(attributeName: "viewBox")]
public string viewBox { get; set; }
[XmlIgnore()]
public ViewBoxRectangle ViewBox
{
get
{
if (!string.IsNullOrEmpty(viewBox))
{
var splitt = viewBox.Split(' ');
if (splitt.Length == 4)
{
var rectangle = new ViewBoxRectangle()
{
X = float.Parse(splitt[0]),
Y = float.Parse(splitt[1]),
Width = float.Parse(splitt[2]),
Height = float.Parse(splitt[3]),
};
return rectangle;
}
}
return null;
}
}
[XmlElement("g", Type = typeof(GPath))]
[XmlElement("path", Type = typeof(Path))]
[XmlElement("circle", Type = typeof(CirclePath))]
public HtmlElement[] Vectors { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,189 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml.Serialization;
namespace FigmaSharp.Views.Graphics
{
[Serializable()]
public class HtmlElement
{
[XmlAttribute(attributeName: "class")]
public string Class { get; set; }
[XmlAttribute(attributeName: "id")]
public string Id { get; set; }
}
[Serializable()]
public class Mask : HtmlElement
{
[XmlAttribute(attributeName: "x")]
public float X { get; set; }
[XmlAttribute(attributeName: "y")]
public float Y { get; set; }
[XmlAttribute(attributeName: "width")]
public float Width { get; set; }
[XmlAttribute(attributeName: "height")]
public float Height { get; set; }
[XmlAttribute(attributeName: "maskUnits")]
public string Units { get; set; }
[XmlAttribute(attributeName: "mask-type")]
public string MaskType { get; set; }
[XmlElement("g", Type = typeof(GPath))]
[XmlElement("path", Type = typeof(Path))]
[XmlElement("circle", Type = typeof(CirclePath))]
public HtmlElement[] Paths { get; set; }
}
[Serializable()]
public class TextPath : HtmlElement
{
[XmlAttribute(attributeName: "font-size")]
public float FontSize { get; set; }
[XmlAttribute(attributeName: "x")]
public float X { get; set; }
[XmlAttribute(attributeName: "rx")]
public float RX { get; set; }
[XmlAttribute(attributeName: "y")]
public float Y { get; set; }
[XmlAttribute(attributeName: "ry")]
public float RY { get; set; }
}
[Serializable()]
public class RectanglePath : LayerHtmlElement
{
[XmlAttribute(attributeName: "x")]
public float X { get; set; }
[XmlAttribute(attributeName: "y")]
public float Y { get; set; }
[XmlAttribute(attributeName: "rx")]
public float RX { get; set; }
[XmlAttribute(attributeName: "ry")]
public float RY { get; set; }
[XmlAttribute(attributeName: "width")]
public float Width { get; set; }
[XmlAttribute(attributeName: "height")]
public float Height { get; set; }
}
[Serializable()]
public class GPath : HtmlElement
{
[XmlAttribute(attributeName: "mask")]
public string Mask { get; set; }
[XmlElement("g", Type = typeof(GPath))]
[XmlElement("path", Type = typeof(Path))]
[XmlElement("circle", Type = typeof(CirclePath))]
[XmlElement("rect", Type = typeof(RectanglePath))]
[XmlElement("line", Type = typeof(LinePath))]
[XmlElement("text", Type = typeof(TextPath))]
public HtmlElement[] Paths { get; set; }
}
[Serializable()]
public abstract class LayerHtmlElement : HtmlElement
{
[XmlAttribute(attributeName: "fill-opacity")]
public float FillOpacity { get; set; }
[XmlAttribute(attributeName: "transform")]
public string Transform { get; set; }
[XmlAttribute(attributeName: "fill")]
public string Fill { get; set; }
[XmlAttribute(attributeName: "stroke")]
public string Stroke { get; set; }
[XmlAttribute(attributeName: "stroke-width")]
public float StrokeWidth { get; set; }
[XmlAttribute(attributeName: "stroke-linecap")]
public string StrokeLineCap { get; set; }
[XmlAttribute(attributeName: "stroke-linejoin")]
public string StrokeLineJoin { get; set; }
}
[Serializable()]
public class CirclePath : LayerHtmlElement
{
[XmlAttribute(attributeName: "x")]
public float X { get; set; }
[XmlAttribute(attributeName: "rx")]
public float RX { get; set; }
[XmlAttribute(attributeName: "y")]
public float Y { get; set; }
[XmlAttribute(attributeName: "ry")]
public float RY { get; set; }
[XmlAttribute(attributeName: "r")]
public float Radio { get; set; }
}
[Serializable()]
public class LinePath : LayerHtmlElement
{
[XmlAttribute(attributeName: "x1")]
public float X1 { get; set; }
[XmlAttribute(attributeName: "x2")]
public float X2 { get; set; }
[XmlAttribute(attributeName: "y1")]
public float Y1 { get; set; }
[XmlAttribute(attributeName: "y2")]
public float Y2 { get; set; }
}
[Serializable()]
public class Path : LayerHtmlElement
{
[XmlAttribute(attributeName: "d")]
public string d { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,120 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Linq;
using System.Xml.Serialization;
namespace FigmaSharp.Views.Graphics
{
[Serializable()]
[XmlRoot("svg")]
public class Svg
{
[XmlAttribute(attributeName: "id")]
public string Id { get; set; }
[XmlAttribute(attributeName: "width")]
public float Width { get; set; }
[XmlAttribute(attributeName: "height")]
public float Height { get; set; }
[XmlAttribute(attributeName: "version")]
public float Version { get; set; }
#region Titles
[XmlElement(elementName: "title")]
public string Title { get; set; }
[XmlElement(elementName: "drawing-type")]
public string DrawingType { get; set; }
#endregion
[XmlElement("mask")]
public Mask[] Mask { get; set; }
[XmlElement("svg")]
public Svg[] Svgs { get; set; }
[XmlElement("g", Type = typeof(GPath))]
[XmlElement("path", Type = typeof(Path))]
[XmlElement("circle", Type = typeof(CirclePath))]
[XmlElement("rect", Type = typeof(RectanglePath))]
[XmlElement("line", Type = typeof(LinePath))]
[XmlElement("text", Type = typeof(TextPath))]
public HtmlElement[] Vectors { get; set; }
[XmlArray("defs")]
[XmlArrayItem("style", typeof(StyleDefinition))]
[XmlArrayItem("marker", typeof(MarkerDefinition))]
public Definitions[] Definitions { get; set; }
[XmlAttribute(attributeName: "viewBox")]
public string viewBox { get; set; }
[XmlIgnore()]
public ViewBoxRectangle ViewBox
{
get
{
if (!string.IsNullOrEmpty(viewBox))
{
var splitt = viewBox.Split(' ');
if (splitt.Length == 4)
{
var rectangle = new ViewBoxRectangle()
{
X = float.Parse(splitt[0]),
Y = float.Parse(splitt[1]),
Width = float.Parse(splitt[2]),
Height = float.Parse(splitt[3]),
};
return rectangle;
}
}
return null;
}
}
public static Svg FromData (string data)
{
data = data
.Replace("xmlns=\"http://www.w3.org/2000/svg\"", "")
.Replace("xmlns=\"http://www.w3.org/1999/xlink\"", "");
XmlSerializer serializer = new XmlSerializer(typeof(Svg));
Svg result;
using (TextReader r = new StringReader(data))
result = (Svg)serializer.Deserialize(r);
return result;
//Parse(xml.Root);
}
}
}

Просмотреть файл

@ -0,0 +1,52 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Xml.Serialization;
namespace FigmaSharp.Views.Graphics
{
[Serializable()]
public class ViewBoxRectangle
{
[XmlAttribute(attributeName: "x")]
public float X { get; set; }
[XmlAttribute(attributeName: "rx")]
public float RX { get; set; }
[XmlAttribute(attributeName: "y")]
public float Y { get; set; }
[XmlAttribute(attributeName: "ry")]
public float RY { get; set; }
[XmlAttribute(attributeName: "width")]
public float Width { get; set; }
[XmlAttribute(attributeName: "height")]
public float Height { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,33 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace FigmaSharp.Views
{
public class Transform
{
public float RotateAngle { get; set; }
public float Scale { get; set; }
public Point Translation { get; set; } = new Point ();
}
}

Просмотреть файл

@ -0,0 +1,120 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Reflection;
using FigmaSharp.Converters;
using FigmaSharp.PropertyConfigure;
using FigmaSharp.Views;
namespace FigmaSharp
{
/// <summary>
/// An AppContext contains configuration (such as the authentication token)
/// and code converters for the current application.
/// </summary>
public class AppContext : IFigmaDelegate
{
public bool IsApiConfigured => !string.IsNullOrEmpty (Api.Token);
IFigmaDelegate figmaDelegate;
public string Version => System.Diagnostics.FileVersionInfo.GetVersionInfo(this.GetType ().Assembly.Location).FileVersion;
AppContext()
{
}
public void Configuration(IFigmaDelegate currentDelegate, string token)
{
SetAccessToken(token);
Configuration(currentDelegate);
}
public void Configuration(IFigmaDelegate currentDelegate) => figmaDelegate = currentDelegate;
public void SetAccessToken(string token)
{
Api.Token = token;
}
public void BeginInvoke(Action handler) => figmaDelegate.BeginInvoke(handler);
public IView CreateEmptyView() => figmaDelegate.CreateEmptyView();
public NodeConverter[] GetFigmaConverters() => figmaDelegate.GetFigmaConverters();
public IImage GetImage(string url) => figmaDelegate.GetImage(url);
public string GetSvgData(string url) => figmaDelegate.GetSvgData(url);
public IImage GetImageFromFilePath(string filePath) =>
figmaDelegate.GetImageFromFilePath(filePath);
//public FigmaResponse GetFigmaResponseFromContent(string template) =>
// Api. FigmaApiHelper.GetFigmaResponseFromContent(template);
public IImage GetImageFromManifest(Assembly assembly, string imageRef) =>
figmaDelegate.GetImageFromManifest(assembly, imageRef);
public string GetManifestResource(Assembly assembly, string file) =>
figmaDelegate.GetManifestResource(assembly, file);
public IImageView GetImageView(IImage image)
{
return figmaDelegate.GetImageView(image);
}
#region Static
static AppContext current;
/// <summary>
/// The shared AppContext for the application.
/// </summary>
/// <value>The current.</value>
public static AppContext Current
{
get
{
if (current == null)
{
current = new AppContext();
}
return current;
}
}
public static FigmaApi Api { get; } = new FigmaApi ();
public bool IsVerticalAxisFlipped => figmaDelegate.IsVerticalAxisFlipped;
public ViewPropertyConfigureBase GetViewPropertyConfigure() => figmaDelegate.GetViewPropertyConfigure();
public CodePropertyConfigureBase GetCodePropertyConfigure ()
=> figmaDelegate.GetCodePropertyConfigure();
#endregion
}
}

Просмотреть файл

@ -0,0 +1,47 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class ElipseConverterBase : NodeConverter
{
public class Properties
{
public static string FillColor = "FillColor";
public static string StrokeColor = "StrokeColor";
public static string StrokeDashes = "StrokeDashes";
public static string LineWidth = "LineWidth";
public static string Opacity = "AlphaValue";
}
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode.GetType() == typeof(FigmaElipse);
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class FrameConverterBase : NodeConverter
{
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode is FigmaFrame;
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class LineConverterBase : NodeConverter
{
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode.GetType () == typeof (FigmaLine) || (currentNode.type == "VECTOR" && currentNode.name == "sep");
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class PointConverterBase : NodeConverter
{
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode.GetType() == typeof(FigmaPoint);
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class RectangleVectorConverterBase : NodeConverter
{
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode.GetType() == typeof(RectangleVector);
}
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class RegularPolygonConverterBase : NodeConverter
{
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode.GetType() == typeof(FigmaRegularPolygon);
}
}
}

Просмотреть файл

@ -0,0 +1,39 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class VectorConverterBase : NodeConverter
{
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode.GetType() == typeof(FigmaVector)
|| currentNode.GetType() == typeof(FigmaStar);
}
}
}

Просмотреть файл

@ -0,0 +1,143 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using FigmaSharp.Models;
using FigmaSharp.Services;
using FigmaSharp.Views;
namespace FigmaSharp.Converters
{
public abstract class NodeConverter
{
public abstract Type GetControlType (FigmaNode currentNode);
public virtual bool IsLayer { get; }
public virtual string Name { get; } = CodeRenderService.DefaultViewName;
public virtual bool ScanChildren (FigmaNode currentNode)
{
return true;
//return !(currentNode is FigmaInstance);
}
protected T ToEnum<T> (string value)
{
try {
foreach (T suit in (T[])Enum.GetValues (typeof (T))) {
if (suit.ToString ().ToLower ().Equals (value, StringComparison.InvariantCultureIgnoreCase)) {
return suit;
}
}
} catch (System.Exception ex) {
LoggingService.LogError("[FIGMA] Error", ex);
}
return default (T);
}
protected Dictionary<string, string> GetKeyValues (FigmaNode currentNode)
{
Dictionary<string, string> ids = new Dictionary<string, string>();
var index = currentNode.name.IndexOf ($"type:", System.StringComparison.InvariantCultureIgnoreCase);
if (index > -1) {
var properties = currentNode.name.Split (' ');
foreach (var property in properties) {
var data = property.Split (':');
if (data.Length != 2) {
LoggingService.LogError ($"Error format in parameter: '{property}'");
continue;
}
ids.Add (data[0], data[1]);
}
} else {
ids.Add ("type", currentNode.name);
}
return ids;
}
string RemoveQuotes(string data, bool enable = false)
{
if (enable)
return data.Replace("\"", "");
return data;
}
protected string GetIdentifierValue (string data, string parameter, bool removeQuotes = false)
{
var index = data.IndexOf($"{parameter}:", System.StringComparison.InvariantCultureIgnoreCase);
if (index > -1)
{
var delta = data.Substring(index + $"{parameter}=".Length);
var endIndex = delta.IndexOf(" ", System.StringComparison.InvariantCultureIgnoreCase);
if (endIndex == -1)
return RemoveQuotes (delta, removeQuotes);
return RemoveQuotes (delta.Substring(0, endIndex), removeQuotes);
}
return null;
}
internal virtual bool HasWidthConstraint ()
{
return true;
}
internal virtual bool HasHeightConstraint()
{
return true;
}
internal virtual bool IsFlexibleHorizontal(FigmaNode node)
{
if (node is IConstraints constrainedNode)
return constrainedNode != null && constrainedNode.constraints.IsFlexibleHorizontal;
return false;
}
internal virtual bool IsFlexibleVertical(FigmaNode node)
{
if (node is IConstraints constrainedNode)
return constrainedNode != null && constrainedNode.constraints.IsFlexibleVertical;
return false;
}
protected bool ContainsType (FigmaNode currentNode, string name)
{
var identifier = GetIdentifierValue (currentNode.name, "type") ?? currentNode.name;
return identifier == name;
}
public abstract bool CanConvert (FigmaNode currentNode);
public virtual bool CanCodeConvert(FigmaNode currentNode) => CanConvert(currentNode);
public abstract IView ConvertToView (FigmaNode currentNode, ViewNode parent, ViewRenderService rendererService);
public abstract string ConvertToCode (CodeNode currentNode, CodeNode parentNode, ICodeRenderService rendererService);
}
}

Просмотреть файл

@ -0,0 +1,42 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class StackViewBase : NodeConverter
{
public static class Properties
{
public static string EdgeInsets = "EdgeInsets";
public static string Spacing = "Spacing";
public static string Orientation = "Orientation";
public static string Distribution = "Distribution";
}
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode) => currentNode.IsStackView();
}
}

Просмотреть файл

@ -0,0 +1,38 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using FigmaSharp.Models;
namespace FigmaSharp.Converters
{
public abstract class TextConverterBase : NodeConverter
{
public override bool IsLayer => true;
public override bool CanConvert(FigmaNode currentNode)
{
return currentNode.GetType() == typeof(FigmaText);
}
}
}

Просмотреть файл

@ -0,0 +1,36 @@
// Authors:
// Jose Medrano <josmed@microsoft.com>
//
// Copyright (C) 2018 Microsoft, Corp
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
using System.Text;
namespace FigmaSharp
{
public static class CodeGenerationExtensions
{
public static void ReplaceDefaultNameTag (this StringBuilder builder, string value)
{
builder.Replace(Resources.Ids.Conversion.NameIdentifier, value);
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше