using System;
using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace DialogueSystem.Notes
{
    public class NoteContentUI : MonoBehaviour
    {
        public enum NoteType
        {
            SmallNote,
            BigNote
        }

        public GameObject smallNote;
        public GameObject bigNote;

        public NoteScriptableObject currentNote;
        
        [Header("Small Note")]
        public TextMeshProUGUI smallNoteHeader;
        public TextMeshProUGUI smallNoteContentText;
        public Button smallNoteExitButton;
        
        [Header("Big Note")]
        public TextMeshProUGUI bigNoteHeader;
        public TextMeshProUGUI bigNoteContentText;
        public Button bigNoteExitButton;
        
        private void OnEnable()
        {
            smallNoteExitButton.onClick.AddListener(CloseNote);
            bigNoteExitButton.onClick.AddListener(CloseNote);
            
            bigNoteExitButton.transform
                .DOScale(1.2f, 0.5f)
                .SetLoops(-1, LoopType.Yoyo)
                .SetEase(Ease.InOutSine)
                .SetUpdate(true);
            
            smallNoteExitButton.transform
                .DOScale(1.2f, 0.5f)
                .SetLoops(-1, LoopType.Yoyo)
                .SetEase(Ease.InOutSine)
                .SetUpdate(true);
            
        }

        public void OpenSmallNote(string header, string content)
        {
            smallNoteHeader.text = header;
            smallNoteContentText.text = content;
            
            smallNote.SetActive(true);
            bigNote.SetActive(false);
        }

        public void OpenBigNote(string header, string content)
        {
            bigNoteHeader.text = header;
            bigNoteContentText.text = content;
            
            smallNote.SetActive(false);
            bigNote.SetActive(true);
        }

        private void CloseNote()
        {
            DialogueManager.Instance.CloseNoteWindow();
        }
        
    }
}
