using UnityEngine;
using UnityEngine.UIElements;

namespace LiveOpsExamples
{
  public class LogRowView
  {
    private readonly Label _timeLabel;
    private readonly Label _tagLabel;
    private readonly Label _messageLabel;
    private readonly Label _detailLabel;

    public LogRowView(VisualElement root)
    {
      _timeLabel = root.Q<Label>("log-time");
      _tagLabel = root.Q<Label>("log-tag");
      _messageLabel = root.Q<Label>("log-message");
      _detailLabel = root.Q<Label>("log-detail");
    }

    public void Set(string time, string tag, Color tagColor, string message, string detail)
    {
      _timeLabel.text = time;
      _tagLabel.text = tag;
      _tagLabel.style.color = tagColor;
      _tagLabel.style.backgroundColor = new Color(tagColor.r, tagColor.g, tagColor.b, 0.18f);
      _messageLabel.text = message;
      _detailLabel.text = detail;
    }
  }
}
