feat(Navigation) Improved desktop navigation UI

This commit is contained in:
2022-04-12 11:32:02 -04:00
parent 13e2d5d5eb
commit 16223cd010
17 changed files with 308 additions and 271 deletions
+17 -1
View File
@@ -4,13 +4,18 @@ namespace Services.Website;
public class NavigationService : INavigationService {
private string navigationStateType = NavigationStateType.Default;
private int navigationStateId = -1;
private NavSelectionType navSelectionType = NavSelectionType.None;
private Type renderType = null!;
private int webPageType;
private int webSectionType;
public void Subscribe(Action action) {
OnChange += action;
}
@@ -19,6 +24,17 @@ public class NavigationService : INavigationService {
OnChange += action;
}
public void ChangeNavigationSectionId(int newState)
{
navigationStateId = newState;
NotifyDataChanged();
}
public int GetNavigationSectionId()
{
return navigationStateId;
}
public void ChangeNavigationState(string newState) {
if (newState.Equals(navigationStateType))
return;
+17 -35
View File
@@ -1,10 +1,5 @@
using System.Net.Http.Json;
#if !NO_SQL
using Contexts;
using Microsoft.EntityFrameworkCore;
#endif
using Model.Website;
namespace Services.Development;
@@ -24,17 +19,8 @@ public class WebsiteService : IWebsiteService {
#if NO_SQL
public List<WebSectionModel> WebSectionModels { get; set; } = default!;
public List<WebPageModel> WebPageModels { get; set; } = default!;
#else
private DatabaseContext Database { get; set; }
public DbSet<WebSectionModel> WebSectionModels => Database.WebSectionModels;
public DbSet<WebPageModel> WebPageModels => Database.WebPageModels;
#endif
public void Subscribe(Action action) {
@@ -49,39 +35,35 @@ public class WebsiteService : IWebsiteService {
return isLoaded;
}
#if NO_SQL
public async Task Load() {
if (isLoaded) {return;}
WebPageModels = ((await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json"))!).ToList();
WebSectionModels =((await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json"))!).ToList();
isLoaded = true;
SortSql();
NotifyDataChanged();
}
#else
public async Task Load(DatabaseContext database) {
Database = database;
if (isLoaded) {return;}
Database.WebPageModels.AddRange(await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json"));
Database.WebSectionModels.AddRange(
await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json"));
Database.SaveChanges();
isLoaded = true;
NotifyDataChanged();
}
#endif
void SortSql()
{
foreach (var page in WebPageModels)
{
if (page.WebSectionModelId != null)
{
WebSectionModel webSection =
WebSectionModels.Find(webSection => webSection.Id == page.WebSectionModelId);
webSection.WebPageModels.Add(page);
}
}
}
public void Update() {
NotifyDataChanged();
}