using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.U2D;
using UnityEngine.UI;

public class CashOutCell : BasePanel
{
    Color ChooseColor;

    public WithDrawItemBean bean;
    public override void OnHide(object data = null)
    {
        throw new System.NotImplementedException();
    }

    public override void OnInit(object data = null)
    {
        WithDrawItemBean bean = data as WithDrawItemBean;
        this.bean = bean;

        ChooseColor = new Color(44f / 255, 218f / 255, 162f / 255);

        GetComponent<Toggle>().group = GetComponentInParent<ToggleGroup>();
        GetComponent<Toggle>().onValueChanged.AddListener(value => 
        {
            if (value)
            {
                GetControl<Text>("txtMoney").color = ChooseColor;
                UIMgr.Getinstance().GetPanel<CashOutPanel>().UpdateNowCell(this);
            }
            else
            {
                GetControl<Text>("txtMoney").color = Color.black;
            }
        });
        int ConditionID = 1;
        //根据描述判断需要加载哪个右上角标签
        switch (bean.desc)
        {
            case "合成椰子":
                ConditionID = 1;
                break;
            case "连续登录":
                ConditionID = 2;
                break;
            case "合成西瓜":
                ConditionID = 3;
                break;
            case "大额提现":
                ConditionID = 4;
                break;
            case "合成歌曲":
                ConditionID = 5;
                break;
            case "新人专享":
                ConditionID = 6;
                break;
        }
        GetControl<Image>("imgCondition").sprite = ResMgr.Getinstance().Load<SpriteAtlas>("Atlas/CashOutAtlas").GetSprite(ConditionID.ToString());

        GetControl<Text>("txtMoney").text = bean.cashStr + bean.unit;

    }

    public override void OnRefresh(object data = null)
    {
        
    }

}
