using Front.Program.Views.Project; using Microsoft.AspNetCore.Components; namespace Front.Program.Services; public class LoadingService { public bool IsLoading { get; private set; } public IndicateType CurrentType { get; private set; } = IndicateType.Page; private bool isNavigationLoading { get; set; } public event Action? OnChange; public void ShowLoading(IndicateType type = IndicateType.Page, bool isNavigation = false) { IsLoading = true; CurrentType = type; isNavigationLoading = isNavigation; NotifyStateChanged(); } public void HideLoading() { if (!isNavigationLoading) { IsLoading = false; NotifyStateChanged(); } } public void HideNavigationLoading() { if (isNavigationLoading) { IsLoading = false; isNavigationLoading = false; NotifyStateChanged(); } } private void NotifyStateChanged() => OnChange?.Invoke(); }