Files
mapo-core/MP.Land/Shared/MainLayout.razor.cs
T
2024-10-31 11:04:15 +01:00

89 lines
2.1 KiB
C#

using Microsoft.AspNetCore.Components;
using MP.Land.Data;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MP.Land.Shared
{
public partial class MainLayout
{
#region Public Methods
public void Dispose()
{
AppMService.EA_ShowSearch -= OnShowSearch;
AppMService.EA_ShowSearch -= OnHideSearch;
GC.Collect();
}
public void OnHideSearch()
{
ShowSearch = false;
InvokeAsync(() =>
{
StateHasChanged();
});
}
public void OnShowSearch()
{
ShowSearch = true;
InvokeAsync(() =>
{
StateHasChanged();
});
}
#endregion Public Methods
#region Protected Properties
protected bool annualAuthOk { get; set; } = false;
protected string cssRow { get; set; } = "bottom-row bg-primary";
[Inject]
protected AppAuthService DataService { get; set; }
protected bool navLarge { get; set; } = true;
protected string sideClass { get; set; } = "sidebar";
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
AppMService.EA_ShowSearch += OnShowSearch;
AppMService.EA_HideSearch += OnHideSearch;
AppMService.EA_UpdateLic += SetYrAuth;
await Task.Delay(1);
}
protected void SetYrAuth()
{
annualAuthOk = AppMService.YearAuth;
cssRow = annualAuthOk ? "bottom-row" : "bottom-row bg-danger";
InvokeAsync(() =>
{
StateHasChanged();
});
}
protected void UpdateNavDisplay()
{
navLarge = !navLarge;
sideClass = navLarge ? "sidebar" : "sidebarSmall";
}
#endregion Protected Methods
#region Private Properties
private bool ShowSearch { get; set; } = false;
#endregion Private Properties
}
}