using System;
using UnityEngine;
using UnityEngine.UI;

namespace MyGame.Scenes.Main.Scripts
{
    public class AutoCookPopcornView : MonoBehaviour
    {
        [SerializeField] private Transform target;
        [SerializeField] private Text amountText;
        private Color redColor;
        private void Awake()
        {
            ColorUtility.TryParseHtmlString(Const.RedColorString, out redColor);
        }

        public void SetView(ProductData data, bool red = false)
        {
            target.DestroyAllChildrens();
            Instantiate(data.GetIconPrefab(), target);
            amountText.text = $"×{data.volume}";
            if (red)
            {
                amountText.color = redColor;
            }
        }

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