WIP: Add load project page
This commit is contained in:
parent
6207b81e08
commit
7a37e024e2
37
I18N Commander/UI MAUI/Pages/LoadProject.razor
Normal file
37
I18N Commander/UI MAUI/Pages/LoadProject.razor
Normal file
@ -0,0 +1,37 @@
|
||||
@page "/load"
|
||||
|
||||
<h1>Load a Project</h1>
|
||||
|
||||
<ul>
|
||||
@foreach (var recentProject in this.recentProjects)
|
||||
{
|
||||
<li>@recentProject.Path</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<button class="btn btn-secondary" type="button" data-bs-toggle="offcanvas" data-bs-target="#Assistant">
|
||||
<Icon Filename="add-project.svg" Size="25" AltText="Icon: Create new project"/>
|
||||
Create new project
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<Assistant HeaderText="Create new project" IconName="add-project.svg" BaseHeight="new Assistant.Height(40, 40, 40)">
|
||||
<div class="mb-3">
|
||||
<label for="projectName" class="form-label fw-bold">Project Name:</label>
|
||||
<input type="text" class="form-control" id="projectName" placeholder="Type a project name">
|
||||
</div>
|
||||
|
||||
@if (DeviceInfo.Idiom == DeviceIdiom.Desktop)
|
||||
{
|
||||
<div class="mb-3">
|
||||
<label for="projectPath" class="form-label fw-bold">Project destination:</label>
|
||||
<div class="input-group" id="projectPath">
|
||||
<button class="btn btn-primary" type="button" @onclick="@this.ChooseProjectDestination">Choose destination</button>
|
||||
<input type="text" class="form-control" value="@this.newProjectDestination" aria-label="The chosen project path" disabled readonly>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<button class="btn btn-secondary" type="button">Create project</button>
|
||||
</Assistant>
|
52
I18N Commander/UI MAUI/Pages/LoadProject.razor.cs
Normal file
52
I18N Commander/UI MAUI/Pages/LoadProject.razor.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace UI_MAUI.Pages;
|
||||
|
||||
public partial class LoadProject
|
||||
{
|
||||
private readonly List<RecentProject> recentProjects = new();
|
||||
|
||||
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 async Task ChooseProjectDestination()
|
||||
{
|
||||
var projectDestination = await FilePicker.PickAsync(new PickOptions
|
||||
{
|
||||
PickerTitle = "Choose the project destination",
|
||||
});
|
||||
|
||||
if(projectDestination is null)
|
||||
return;
|
||||
|
||||
this.newProjectDestination = projectDestination!.FullPath;
|
||||
}
|
||||
}
|
@ -62,8 +62,4 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Pages" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user