using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class OnlineGamesPanelUI : GamesScrollController {
    
    private RectTransform[] parents;
    private RectTransform OnlineGamesPanelRectTransform;
    private RectTransform titleRect;
    private Image img;
    private RectTransform finishedGamesRT;
    private ScrollRect scrollRect;

    private void Start() {
        parents = GetComponentsInParent<RectTransform>();
        OnlineGamesPanelRectTransform = parents[1];
        titleRect = gameObject.GetComponent<RectTransform>();
        img = gameObject.GetComponentInChildren<Image>();

        finishedGamesRT = GameObject.Find("FinishedGamesPanel").GetComponent<RectTransform>();
        scrollRect = OnlineGamesPanelRectTransform.GetComponentInChildren<ScrollRect>();
        if (OnlineGamesPanelRectTransform.rect.height != titleRect.rect.height) {
            img.sprite = downArrow;
        } else {
            img.sprite = upArrow;
        }
    }

    /*
    public void OnPointerClick(PointerEventData eventData) {
        // Check if parent is expanded, if so minimize else maximize
        float finishedGamesPanelHeight = finishedGamesRT.rect.height;
        if (OnlineGamesPanelRectTransform.rect.height != titleRect.rect.height) {
            minimize();
        } else {
            // Maximera 
            if (finishedGamesRT.GetComponentInChildren<finishedGamesUI>().Expanded) {
                OnlineGamesPanelRectTransform.sizeDelta = new Vector2(OnlineGamesPanelRectTransform.rect.width, GamesPanel.GetComponent<RectTransform>().rect.height - finishedGamesPanelHeight);
            } else {
                OnlineGamesPanelRectTransform.sizeDelta = new Vector2(OnlineGamesPanelRectTransform.rect.width, GamesPanel.GetComponent<RectTransform>().rect.height - finishedGamesPanelHeight);
            }
            scrollRect.enabled = true;
            img.sprite = downArrow;
            Expanded = true;
        }
    }
    */
}
