using UnityEngine;
using UnityEngine.UIElements;

namespace LiveOpsExamples
{
  public class BackpackItemRowView
  {
    private readonly VisualElement _icon;
    private readonly Label _nameLabel;
    private readonly Label _metaLabel;
    private readonly Label _amountLabel;

    public BackpackItemRowView(VisualElement root)
    {
      _icon = root.Q<VisualElement>("item-icon");
      _nameLabel = root.Q<Label>("item-name");
      _metaLabel = root.Q<Label>("item-meta");
      _amountLabel = root.Q<Label>("item-amount");
    }

    public void Set(Sprite icon, string itemName, string slug, int amount)
    {
      _icon.style.backgroundImage = new StyleBackground(icon);
      _nameLabel.text = itemName;
      _metaLabel.text = slug;
      _amountLabel.text = $"×{amount}";
    }
  }
}
