using QuizPleaseTest.Common.UI;
using UnityEngine;
using UnityEngine.UI;

namespace QuizPleaseTest.Boot.UI
{
    public class MenuUIView : UIView<MenuUIViewModel>
    {
        [field: SerializeField] public Button RestartButton { get; private set; }

        public override void Initialize()
        {
            base.Initialize();

            if (RestartButton == null)
            {
                return;
            }

            RestartButton.onClick.RemoveListener(OnRestartClicked);
            RestartButton.onClick.AddListener(OnRestartClicked);
        }

        public override void Release()
        {
            if (RestartButton != null)
            {
                RestartButton.onClick.RemoveListener(OnRestartClicked);
            }

            base.Release();
        }

        private void OnRestartClicked()
        {
            ViewModel.Restart();
        }
    }
}
