Files
mapo-core/MP.Land/Shared/MainLayout.razor.cs
Samuele Locatelli 29079a578f LAND:
- spostamento servizio AppAuth i proj generico
2025-04-16 12:57:21 +02:00

90 lines
2.1 KiB
C#

using Microsoft.AspNetCore.Components;
using MP.AppAuth.Services;
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
}
}