using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using UnityEngine;

public class salaScene_labels : gridView, IEventHandler
{
    int nowselect = 0;
    List<string> alldata = new List<string>{ "All", "Hot" };
    void IEventHandler.onEventHandler(string eventName, List<UnityEngine.Object> uobjects, List<System.Object> objects)
    {
        if(eventName == "switchImageLabel")
        {
            string name = objects[0] as string;
            int idx = alldata.IndexOf(name);
            var lItem = getObjectById(nowselect).GetComponent<labelItem>();
            lItem.select = false;
            lItem = getObjectById(idx).GetComponent<labelItem>();
            lItem.select = true;
            nowselect = idx;
            utilsTools.sendEventObjectParams("setImageViewLable", name);
        }
    }

    // Start is called before the first frame update
    void Start()
    {
        this.setData(alldata.Count, (GameObject item, int idx, ListViewBackTypeEnum typeEnum) =>
        {
            if (typeEnum == ListViewBackTypeEnum.update || typeEnum == ListViewBackTypeEnum.create)
            {
                var label = item.GetComponent<labelItem>();
                label.Title = alldata[idx];
                label.select = nowselect == idx;
                if (nowselect == idx)
                {
                    utilsTools.sendEventObjectParams("setImageViewLable", alldata[idx]);
                }
                
            }
        },false);
        utilsTools.onEvent(this, "switchImageLabel");
    }
    void Update()
    {
    }
}
