Made create project button aware of user input's state
This commit is contained in:
parent
d77994b18b
commit
c867514211
@ -24,7 +24,7 @@
|
||||
<Assistant HeaderText="Create new project" IconName="add-project.svg" BaseHeight="new Assistant.Height(40, 55, 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">
|
||||
<input type="text" class="form-control" id="projectName" placeholder="Type a project name" @bind="this.newProjectName" @bind:event="oninput" @onkeydown="this.ReevaluateState">
|
||||
</div>
|
||||
|
||||
@if (DeviceInfo.Idiom == DeviceIdiom.Desktop)
|
||||
@ -38,5 +38,5 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<button class="btn btn-secondary" type="button" @onclick="this.CreateProject">Create project</button>
|
||||
<button class="btn btn-secondary" type="button" @onclick="this.CreateProject" disabled="@this.CannotCreateProject()">Create project</button>
|
||||
</Assistant>
|
@ -7,6 +7,7 @@ public partial class LoadProject
|
||||
{
|
||||
private readonly List<RecentProject> recentProjects = new();
|
||||
|
||||
private string newProjectName = string.Empty;
|
||||
private string newProjectDestination = string.Empty;
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
@ -39,17 +40,36 @@ public partial class LoadProject
|
||||
|
||||
private Task ChooseProjectDestination()
|
||||
{
|
||||
try
|
||||
{
|
||||
#if WINDOWS
|
||||
return this.ChooseProjectDestinationWindows();
|
||||
return this.ChooseProjectDestinationWindows();
|
||||
#elif MACCATALYST
|
||||
return this.ChooseProjectDestinationMacOS();
|
||||
return this.ChooseProjectDestinationMacOS();
|
||||
#else
|
||||
return Task.CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
#endif
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private Task CreateProject()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user