помоги с рефакторингом 
using InputSignal;
using System;
using UI.Panel;
using UnityEngine.EventSystems;
using Zenject;

namespace UI
{
    public class UINavigator : IDisposable
    {
        public event Action<NamePopupItem> OnNextScreen;
        public event Action OnPreviousScreen;

        private PopupItem currentPanel = null;
        private int selectedPopupIndex = 0;
        private bool isEmptyScreen = false;
        private int selectedCurrentPopupIndex = 0;

        private KeyInputCheck keyInputCheck;

        public UINavigator(KeyInputCheck keyInputCheck)
        {
            this.keyInputCheck = keyInputCheck;

            keyInputCheck.OnUpArrowKeyPressed += UpArrowKeyPressed;
            keyInputCheck.OnDownArrowKeyPressed += DownArrowKeyPressed;
            keyInputCheck.OnRightArrowKeyPressed += RightArrowKeyPressed;
            keyInputCheck.OnLeftArrowKeyPressed += LeftArrowKeyPressed;
        }

        public void SetCurrentPopup(PopupItem panelItem)
        {
            panelItem.Initialize(currentPanel);
            currentPanel = panelItem;

            if (currentPanel.Popup.Length != 0)
            {
                ResetPopupSelection();
                EventSystem.current.SetSelectedGameObject(currentPanel.Popup[currentPanel.SelectedPopupIndex].gameObject);
                currentPanel.Popup[currentPanel.SelectedPopupIndex].Highlight();
                selectedCurrentPopupIndex = currentPanel.SelectedPopupIndex;
            }
            else
            {
                isEmptyScreen = true;
            }
        }

        public void Dispose()
        {
            keyInputCheck.OnUpArrowKeyPressed -= UpArrowKeyPressed;
            keyInputCheck.OnDownArrowKeyPressed -= DownArrowKeyPressed;
            keyInputCheck.OnRightArrowKeyPressed -= RightArrowKeyPressed;
            keyInputCheck.OnLeftArrowKeyPressed -= LeftArrowKeyPressed;
        }

        private void UpArrowKeyPressed()
        {
            if (!isEmptyScreen)
            {
                CheckCurrentSelectedElement();
                selectedPopupIndex = selectedCurrentPopupIndex;
                SelectFocus(-1);
            }
        }

        private void DownArrowKeyPressed()
        {
            if (!isEmptyScreen)
            {
                CheckCurrentSelectedElement();
                selectedPopupIndex = selectedCurrentPopupIndex;
                SelectFocus(1);
            }
        }

        private void LeftArrowKeyPressed()
        {
            if (isEmptyScreen)
            {
                OnPreviousScreen?.Invoke();
            }
            else
            {
                CheckCurrentSelectedElement();
                OnPreviousScreen?.Invoke();
            }
        }

        private void RightArrowKeyPressed()
        {
            if (isEmptyScreen)
            {
                if (currentPanel.NextItemName != NamePopupItem.None)
                {
                    OnNextScreen?.Invoke(currentPanel.NextItemName);
                }
            }
            else
            {
                CheckCurrentSelectedElement();

                selectedPopupIndex = selectedCurrentPopupIndex;
                currentPanel.Popup[selectedPopupIndex].Select();
                currentPanel.SelectedPopupIndex = selectedPopupIndex;
                OnNextScreen?.Invoke(currentPanel.Popup[selectedPopupIndex].ScreenItem);
            }
        }

        private void SelectFocus(int direction)
        {
            EventSystem.current.SetSelectedGameObject(null);

            ResetPopupSelection();

            selectedPopupIndex = (selectedPopupIndex + direction + currentPanel.Popup.Length) % currentPanel.Popup.Length;
            EventSystem.current.SetSelectedGameObject(currentPanel.Popup[selectedPopupIndex].gameObject);
            currentPanel.Popup[selectedPopupIndex].Highlight();
            selectedCurrentPopupIndex = selectedPopupIndex;
        }

        private void ResetPopupSelection()
        {
            isEmptyScreen = false;

            EventSystem.current.SetSelectedGameObject(null);

            foreach (var item in currentPanel.Popup)
            {
                item.Deselect();
            }
        }

        private void CheckCurrentSelectedElement()
        {
            if (EventSystem.current.currentSelectedGameObject == null)
            {
                EventSystem.current.SetSelectedGameObject(currentPanel.Popup[selectedPopupIndex].gameObject);
            }
        }
    }
}