async Task <ProjectFile> CreateBundleView(FigmaBundleViewBase figmaBundleView, Project currentProject, INodeProvider fileProvider, bool translateStrings) { var bundle = figmaBundleView.Bundle; await fileProvider.LoadAsync(bundle.DocumentFilePath); var converters = FigmaControlsContext.Current.GetConverters(); var codePropertyConverter = FigmaControlsContext.Current.GetCodePropertyConverter(); var codeRendererService = new NativeViewCodeService(fileProvider, converters, codePropertyConverter) { TranslationService = new Services.MonoDevelopTranslationService() }; figmaBundleView.Generate(outputDirectory, codeRendererService, namesSpace: bundle.Namespace, translateStrings: translateStrings); var partialDesignerClassFilePath = Path.Combine(outputDirectory, figmaBundleView.PartialDesignerClassName); var publicCsClassFilePath = Path.Combine(outputDirectory, figmaBundleView.PublicCsClassName); var designerProjectFile = currentProject.AddFile(partialDesignerClassFilePath); var csProjectFile = currentProject.AddFile(publicCsClassFilePath); designerProjectFile.DependsOn = csProjectFile.FilePath; designerProjectFile.Metadata.SetValue(FigmaFile.FigmaPackageId, bundle.FileId); if (!figmaBundleView.FigmaNode.TryGetNodeCustomName(out string customName)) { customName = figmaBundleView.FigmaNode.name; } designerProjectFile.Metadata.SetValue(FigmaFile.FigmaNodeCustomName, customName); return(csProjectFile); }
public static async Task AddFigmaBundleViewAsync(this Project sender, FigmaBundleViewBase figmaBundleView, bool savesInProject = true) { await sender.FormatFileAsync(figmaBundleView.PublicCsClassFilePath); await sender.FormatFileAsync(figmaBundleView.PartialDesignerClassFilePath); if (!sender.PathExistsInProject(figmaBundleView.PublicCsClassFilePath)) { sender.AddFile(figmaBundleView.PublicCsClassFilePath); } if (!sender.PathExistsInProject(figmaBundleView.PartialDesignerClassFilePath)) { var partialFilePath = sender.AddFile(figmaBundleView.PartialDesignerClassFilePath); partialFilePath.DependsOn = figmaBundleView.PublicCsClassFilePath; partialFilePath.Metadata.SetValue(FigmaFile.FigmaPackageId, figmaBundleView.Bundle.FileId); if (!figmaBundleView.FigmaNode.TryGetNodeCustomName(out var customName)) { customName = figmaBundleView.FigmaNode.name; } partialFilePath.Metadata.SetValue(FigmaFile.FigmaNodeCustomName, customName); } if (savesInProject) { await IdeApp.ProjectOperations.SaveAsync(sender); } }
public static async Task AddFigmaBundleViewAsync(this Project sender, FigmaBundleViewBase figmaBundleView, bool savesInProject = true) { if (!sender.PathExistsInProject(figmaBundleView.PublicCsClassFilePath)) { sender.AddFile(figmaBundleView.PublicCsClassFilePath); } if (!sender.PathExistsInProject(figmaBundleView.PartialDesignerClassFilePath)) { var partialFilePath = sender.AddFile(figmaBundleView.PartialDesignerClassFilePath); partialFilePath.DependsOn = figmaBundleView.PublicCsClassFilePath; partialFilePath.Metadata.SetValue(FigmaFile.FigmaPackageId, figmaBundleView.Bundle.FileId); partialFilePath.Metadata.SetValue(FigmaFile.FigmaNodeId, figmaBundleView.FigmaNode.id); } if (savesInProject) { await IdeApp.ProjectOperations.SaveAsync(sender); } }
public ValueData(FigmaBundleViewBase view, INodeProvider fileProvider) { this.View = view; this.fileProvider = fileProvider; }