// Copyright © Selmo Technology GmbH. All Rights Reserved

using Microsoft.AspNetCore.Components;
using SelmoStudio.Hmi.Server.Service;

namespace SelmoStudio.Hmi.Server.Shared.Pages
{
    public partial class NavMenu
    {
        private bool _debug = false;
        private bool collapseNavMenu = true;
        private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

        private void ToggleNavMenu()
        {
            collapseNavMenu = !collapseNavMenu;
        }

        [Inject]
        private IHmiLanguageService _hmiLanguageService { get; set; }

        protected override void OnInitialized()
        {
#if DEBUG
            _debug = true;
#endif
            _hmiLanguageService.OnLanguageSet += OnLanguageSet;

            base.OnInitialized();
        }

        private void OnLanguageSet()
        {
            InvokeAsync(() => StateHasChanged());
        }

        public void Dispose()
        {
            if (_hmiLanguageService != null)
            {
                _hmiLanguageService.OnLanguageSet -= OnLanguageSet;
            }
        }
    }
}