@inherits LayoutComponentBase
@inject IProjectService ProjectService
@inject ISettingsService SettingsService
@inject IThemeService ThemeService
@inject OllamaSettings OllamaSettings
@Body
@code {
private string? activeSection;
private bool showProjectList;
private List? projects;
private string statusText = "Bereit";
private bool isBusy;
private double operationProgress;
[Inject]
private NavigationManager Navigation { get; set; } = default!;
protected override async Task OnInitializedAsync()
{
await LoadProjects();
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await SettingsService.InitializeAsync();
var theme = OllamaSettings.Theme;
if (!string.IsNullOrEmpty(theme))
await ThemeService.ApplyTheme(theme);
}
}
private async Task LoadProjects()
{
try
{
projects = await ProjectService.GetAllProjectsAsync();
}
catch
{
projects = new();
}
}
private void ToggleSection(string section)
{
activeSection = activeSection == section ? null : section;
}
private void ExitApp()
{
activeSection = null;
Navigation.NavigateTo("/");
}
private void CreateNewProject()
{
activeSection = null;
Navigation.NavigateTo("/editor?action=newproject");
}
private void OpenProject()
{
activeSection = null;
Navigation.NavigateTo("/editor?action=open");
}
private void OpenEditor()
{
activeSection = null;
Navigation.NavigateTo("/editor");
}
private void NavigateTo(string path)
{
activeSection = null;
Navigation.NavigateTo(path);
}
private void SelectProject(Project project)
{
activeSection = null;
Navigation.NavigateTo($"/editor?projectId={project.Id}");
}
public void SetStatus(string text, bool busy = false, double progress = 0)
{
statusText = text;
isBusy = busy;
operationProgress = progress;
StateHasChanged();
}
}