80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using System.Text;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace UI_MAUI.Pages;
|
|
|
|
public partial class LoadProject
|
|
{
|
|
private readonly List<RecentProject> recentProjects = new();
|
|
|
|
private string newProjectName = string.Empty;
|
|
private string newProjectDestination = string.Empty;
|
|
|
|
#region Overrides of ComponentBase
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
await this.LoadRecentProjects();
|
|
}
|
|
|
|
#endregion
|
|
|
|
private readonly record struct RecentProject(string Path, string Name, bool Available);
|
|
|
|
private async Task LoadRecentProjects()
|
|
{
|
|
var appDataDirectory = FileSystem.Current.AppDataDirectory;
|
|
var recentProjectsFile = Path.Join(appDataDirectory, "recentProjects.json");
|
|
if (!File.Exists(recentProjectsFile))
|
|
await File.WriteAllTextAsync(recentProjectsFile, string.Empty, Encoding.UTF8);
|
|
|
|
// Read the JSON data from that file & decode it to an array of recent projects:
|
|
}
|
|
|
|
private async Task WriteRecentProjects()
|
|
{
|
|
|
|
}
|
|
|
|
private Task ChooseProjectDestination()
|
|
{
|
|
try
|
|
{
|
|
#if WINDOWS
|
|
return this.ChooseProjectDestinationWindows();
|
|
#elif MACCATALYST
|
|
return this.ChooseProjectDestinationMacOS();
|
|
#else
|
|
return Task.CompletedTask;
|
|
#endif
|
|
}
|
|
finally
|
|
{
|
|
this.StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private Task CreateProject()
|
|
{
|
|
#if WINDOWS
|
|
return this.CreateProjectWindows();
|
|
#elif MACCATALYST
|
|
return Task.CompletedTask;
|
|
#else
|
|
return Task.CompletedTask;
|
|
#endif
|
|
}
|
|
|
|
private bool CannotCreateProject()
|
|
{
|
|
if (DeviceInfo.Idiom == DeviceIdiom.Desktop)
|
|
return string.IsNullOrWhiteSpace(this.newProjectName) || string.IsNullOrWhiteSpace(this.newProjectDestination);
|
|
else if (DeviceInfo.Idiom == DeviceIdiom.Phone || DeviceInfo.Idiom == DeviceIdiom.Tablet)
|
|
return string.IsNullOrWhiteSpace(this.newProjectName);
|
|
else
|
|
return true;
|
|
}
|
|
|
|
private void ReevaluateState() => this.StateHasChanged();
|
|
} |