@using CommunityToolkit.Mvvm.Messaging
@using SteUp.Shared.Core.Interface.System.Network
@using SteUp.Shared.Core.Messages.Scheda
@inject INetworkService NetworkService
@inject IDialogService Dialog
@inject IMessenger Messenger
@code
{
private bool IsVisible { get; set; } = true;
private bool PlusVisible { get; set; } = true;
private bool SchedaVisible { get; set; }
protected override Task OnInitializedAsync()
{
NavigationManager.LocationChanged += (_, args) =>
{
var location = args.Location.Remove(0, NavigationManager.BaseUri.Length);
var newIsVisible = new List { "ispezioni", "ispezione", "user" }
.Contains(location);
var newPlusVisible = new List { "ispezioni", "ispezione", "user" }
.Contains(location);
if (IsVisible == newIsVisible && PlusVisible == newPlusVisible) return;
IsVisible = newIsVisible;
PlusVisible = newPlusVisible;
StateHasChanged();
};
return Task.CompletedTask;
}
private void NewActivity()
{
_ = ModalHelper.OpenSelectShop(Dialog);
}
private async Task NewScheda()
{
var ispezione = SteupDataService.InspectionPageState.Ispezione;
var modal = await ModalHelper.OpenFormScheda(Dialog, ispezione.CodMdep, ispezione.Data, true);
if (modal is { Canceled: false })
Messenger.Send(new NewSchedaMessage());
}
private void OnOpenMenu()
{
var location = NavigationManager.Uri.Remove(0, NavigationManager.BaseUri.Length);
SchedaVisible = new List { "ispezione" }.Contains(location);
StateHasChanged();
}
}