using System;
using UniRx;
using UnityEngine;
using UnityEngine.UI;

public class ShopHistoryItemView : MonoBehaviour
{
    private static readonly string levelTextFormat = "Lv.{0}";
    [SerializeField] private Text levelText;
    [SerializeField] private Text achievementText;
    [SerializeField] private Button playButton;
    [SerializeField] private GameObject oddColorBG;
    [SerializeField] private GameObject viewObject;
    [SerializeField] private GameObject unreleasedObject;
    public IObservable<Unit> PlayButton => playButton.OnClickAsObservable().TakeUntilDestroy(this);

    private void Awake()
    {
        levelText.text = String.Empty;
    }

    public void SetData(ShopLevelData levelData)
    {
        SetAchievementText(levelData.Achievement);
        levelText.text = String.Format(levelTextFormat, levelData.shopLevel);
    }

    public void SetAchievementText(string text)
    {
        achievementText.text = $"{text}";
    }

    public void SetUnreleased(bool active)
    {
        viewObject.SetActive(!active);
        unreleasedObject.SetActive(active);
    }

    public void SetButtonAcive(bool active)
    {
        playButton.gameObject.SetActive(active);
    }

    public void SetOddBG(bool active)
    {
        oddColorBG.SetActive(active);
    }
}