using UnityEngine.UIElements;

namespace LiveOpsExamples
{
  public class ToastView
  {
    private const string ToneInfoClass = "tone-info";
    private const string ToneSuccessClass = "tone-success";
    private const string ToneErrorClass = "tone-error";

    private readonly Label _titleLabel;
    private readonly Label _messageLabel;

    public ToastView(VisualElement root)
    {
      Root = root;
      _titleLabel = root.Q<Label>("toast-title");
      _messageLabel = root.Q<Label>("toast-message");
    }

    public VisualElement Root { get; }

    public void Set(string title, string message, CozyToastTone tone)
    {
      _titleLabel.text = title;
      _messageLabel.text = message;
      Root.EnableInClassList(ToneInfoClass, tone == CozyToastTone.Info);
      Root.EnableInClassList(ToneSuccessClass, tone == CozyToastTone.Success);
      Root.EnableInClassList(ToneErrorClass, tone == CozyToastTone.Error);
    }
  }
}
