using Cryville.EEW.Core;
using Cryville.EEW.Report;
using UnityEngine;

namespace Cryville.EEW.Unity.UI {
	class EventListView : MonoBehaviour {
		[SerializeField]
		EventView m_prefabEventView;

		public void Set(ReportUnit unit) {
			foreach (Transform child in transform) {
				Destroy(child.gameObject);
			}
			foreach (var e in unit) {
				Add(e);
			}
		}
		void Add(ReportViewModel e) {
			var child = Instantiate(m_prefabEventView);
			child.Set(e);
			child.transform.SetParent(transform, false);
			child.transform.SetSiblingIndex(0);
		}
	}
}
