import { _decorator, Component, Node } from 'cc';
import JNLayerBase from '../../../../extensions/ngame/assets/ngame/ui/base/JNLayerBase';
import JNScrollView from '../../../../extensions/ngame/assets/ngame/util/components/scrollview/JNScrollView';
import PetEquipData from '../../data/PetEquipData';
import { NodeEventType } from 'cc';
import { app } from '../../App';
import { GUI } from '../UIConfig';
import { PetEquip } from '../../consts/API';
const { ccclass, property } = _decorator;

@ccclass('PetEquipView')
export class PetEquipView extends JNLayerBase {

    //装备列表
    @property(JNScrollView)
    list:JNScrollView

    onJNLoad(data?: any): void {
        super.onJNLoad(data);

        //添加子节点事件
        this.list.addItemEvent(NodeEventType.TOUCH_END,this.onClickItem.bind(this));
    }

    onJNLoadAnimEnd(): void {
        console.log("onJNLoadAnimEnd");
        super.onJNLoadAnimEnd();
        this.onUpdateView();
    }

    onClickItem(index:number){

        app.layer.Open(GUI.PetEquipForgingPopupView,this.list.getData<PetEquip>()[index])

    }

    onUpdateView(){

        this.list.refreshData(PetEquipData.getIns().equips);

    }

}


