import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { zhao_xi_jie_data, zhao_xi_jie_item_data } from '../../../data/data';
import { shouji_item } from './shouji_item';
import { gameManager } from '../gameManager';
const { ccclass, property } = _decorator;

@ccclass('tip_type_all')
export class tip_type_all extends Component {
    @property(Node) content:Node = null;
    @property(Prefab) itemPrefab:Prefab = null;
    private mData:zhao_xi_jie_data = null;
    @property(Node) btn_tip:Node = null;
    private mCallBack = null;
    public initView(data:zhao_xi_jie_data,call_back){
        this.mData = data;
        this.mCallBack = call_back;
        this.content.removeAllChildren()
        for (let index = 0; index < this.mData.widget_id_list.length; index++) {
            const widget:zhao_xi_jie_item_data = this.mData.widget_id_list[index];
            let item = instantiate(this.itemPrefab)
            item.parent = this.content;
            item.getComponent(shouji_item).initAllTipView(widget)
        }
        this.btn_tip.on(Node.EventType.TOUCH_END,()=>{
            if(this.mCallBack!=null){
                this.mCallBack()
            }
            gameManager.Singleton.sys_click_button_music()
        })
    }

    showFinishIcon(widget_id:number){
        for (let index = 0; index < this.content.children.length; index++) {
            const element = this.content.children[index];
            if(element.getComponent(shouji_item).getData().widget_id===widget_id){
                element.getComponent(shouji_item).showTipIcon()
            }
        }
    }

}


