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

public class ShopHistoryItemView : MonoBehaviour
{
    private static readonly string acivementFormat = "Lv.{0}　{1}";
    [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);
    public void SetData(ShopLevelData levelData)
    {
        achievementText.text = String.Format(acivementFormat, levelData.shopLevel, levelData.achievement);
    }

    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);
    }
}