using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Routing; namespace Lux.Report.Manager.Components.Layout { public partial class NavMenu { #region Public Properties [Parameter] public EventCallback EC_compressUpdated { get; set; } #endregion Public Properties #region Public Methods public void Dispose() { NavigationManager.LocationChanged -= OnLocationChanged; } #endregion Public Methods #region Protected Properties protected string hideText { get => showText ? "" : "invisible"; } protected string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; protected string? TextCss => onlyIcon ? "d-none" : ""; #endregion Protected Properties #region Protected Methods protected override void OnInitialized() { currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri); NavigationManager.LocationChanged += OnLocationChanged; } protected void ToggleCompress() { showText = !showText; EC_compressUpdated.InvokeAsync(showText); } protected void ToggleNavMenu() { collapseNavMenu = !collapseNavMenu; } #endregion Protected Methods #region Private Fields private bool collapseNavMenu = false; private string? currentUrl; private bool onlyIcon = false; #endregion Private Fields #region Private Properties private bool showText { get; set; } = true; #endregion Private Properties #region Private Methods private void OnLocationChanged(object? sender, LocationChangedEventArgs e) { currentUrl = NavigationManager.ToBaseRelativePath(e.Location); StateHasChanged(); } #endregion Private Methods } }